babylon.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependncies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the ressource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the ressource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the ressource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the ressource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** 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 */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** 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 */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** 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 */
  708. static readonly GEQUAL: number;
  709. /** 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 */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * 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.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * 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.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailled logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve albedo index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1130. /**
  1131. * Prefixes used by the engine for custom effects
  1132. */
  1133. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface HardwareTextureWrapper {
  1139. underlyingResource: any;
  1140. set(hardwareTexture: any): void;
  1141. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1142. reset(): void;
  1143. release(): void;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /**
  1148. * This represents the required contract to create a new type of texture loader.
  1149. */
  1150. export interface IInternalTextureLoader {
  1151. /**
  1152. * Defines wether the loader supports cascade loading the different faces.
  1153. */
  1154. supportCascades: boolean;
  1155. /**
  1156. * This returns if the loader support the current file information.
  1157. * @param extension defines the file extension of the file being loaded
  1158. * @param mimeType defines the optional mime type of the file being loaded
  1159. * @returns true if the loader can load the specified file
  1160. */
  1161. canLoad(extension: string, mimeType?: string): boolean;
  1162. /**
  1163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1164. * @param data contains the texture data
  1165. * @param texture defines the BabylonJS internal texture
  1166. * @param createPolynomials will be true if polynomials have been requested
  1167. * @param onLoad defines the callback to trigger once the texture is ready
  1168. * @param onError defines the callback to trigger in case of error
  1169. * @param options options to be passed to the loader
  1170. */
  1171. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1172. /**
  1173. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1174. * @param data contains the texture data
  1175. * @param texture defines the BabylonJS internal texture
  1176. * @param callback defines the method to call once ready to upload
  1177. * @param options options to be passed to the loader
  1178. */
  1179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /**
  1184. * @hidden
  1185. */
  1186. export interface IColor4Like {
  1187. r: float;
  1188. g: float;
  1189. b: float;
  1190. a: float;
  1191. }
  1192. /**
  1193. * @hidden
  1194. */
  1195. export interface IColor3Like {
  1196. r: float;
  1197. g: float;
  1198. b: float;
  1199. }
  1200. /**
  1201. * @hidden
  1202. */
  1203. export interface IVector4Like {
  1204. x: float;
  1205. y: float;
  1206. z: float;
  1207. w: float;
  1208. }
  1209. /**
  1210. * @hidden
  1211. */
  1212. export interface IVector3Like {
  1213. x: float;
  1214. y: float;
  1215. z: float;
  1216. }
  1217. /**
  1218. * @hidden
  1219. */
  1220. export interface IVector2Like {
  1221. x: float;
  1222. y: float;
  1223. }
  1224. /**
  1225. * @hidden
  1226. */
  1227. export interface IMatrixLike {
  1228. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1229. updateFlag: int;
  1230. }
  1231. /**
  1232. * @hidden
  1233. */
  1234. export interface IViewportLike {
  1235. x: float;
  1236. y: float;
  1237. width: float;
  1238. height: float;
  1239. }
  1240. /**
  1241. * @hidden
  1242. */
  1243. export interface IPlaneLike {
  1244. normal: IVector3Like;
  1245. d: float;
  1246. normalize(): void;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to store and describe the pipeline context associated with an effect
  1252. */
  1253. export interface IPipelineContext {
  1254. /**
  1255. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1256. */
  1257. isAsync: boolean;
  1258. /**
  1259. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1260. */
  1261. isReady: boolean;
  1262. /** @hidden */
  1263. _name?: string;
  1264. /** @hidden */
  1265. _getVertexShaderCode(): string | null;
  1266. /** @hidden */
  1267. _getFragmentShaderCode(): string | null;
  1268. /** @hidden */
  1269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1270. /** @hidden */
  1271. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1272. [key: string]: number;
  1273. }, uniformsNames: string[], uniforms: {
  1274. [key: string]: Nullable<WebGLUniformLocation>;
  1275. }, samplerList: string[], samplers: {
  1276. [key: string]: number;
  1277. }, attributesNames: string[], attributes: number[]): void;
  1278. /** Releases the resources associated with the pipeline. */
  1279. dispose(): void;
  1280. /**
  1281. * Sets an integer value on a uniform variable.
  1282. * @param uniformName Name of the variable.
  1283. * @param value Value to be set.
  1284. */
  1285. setInt(uniformName: string, value: number): void;
  1286. /**
  1287. * Sets an int2 value on a uniform variable.
  1288. * @param uniformName Name of the variable.
  1289. * @param x First int in int2.
  1290. * @param y Second int in int2.
  1291. */
  1292. setInt2(uniformName: string, x: number, y: number): void;
  1293. /**
  1294. * Sets an int3 value on a uniform variable.
  1295. * @param uniformName Name of the variable.
  1296. * @param x First int in int3.
  1297. * @param y Second int in int3.
  1298. * @param z Third int in int3.
  1299. */
  1300. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1301. /**
  1302. * Sets an int4 value on a uniform variable.
  1303. * @param uniformName Name of the variable.
  1304. * @param x First int in int4.
  1305. * @param y Second int in int4.
  1306. * @param z Third int in int4.
  1307. * @param w Fourth int in int4.
  1308. */
  1309. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1310. /**
  1311. * Sets an int array on a uniform variable.
  1312. * @param uniformName Name of the variable.
  1313. * @param array array to be set.
  1314. */
  1315. setIntArray(uniformName: string, array: Int32Array): void;
  1316. /**
  1317. * 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)
  1318. * @param uniformName Name of the variable.
  1319. * @param array array to be set.
  1320. */
  1321. setIntArray2(uniformName: string, array: Int32Array): void;
  1322. /**
  1323. * 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)
  1324. * @param uniformName Name of the variable.
  1325. * @param array array to be set.
  1326. */
  1327. setIntArray3(uniformName: string, array: Int32Array): void;
  1328. /**
  1329. * 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)
  1330. * @param uniformName Name of the variable.
  1331. * @param array array to be set.
  1332. */
  1333. setIntArray4(uniformName: string, array: Int32Array): void;
  1334. /**
  1335. * Sets an array on a uniform variable.
  1336. * @param uniformName Name of the variable.
  1337. * @param array array to be set.
  1338. */
  1339. setArray(uniformName: string, array: number[] | Float32Array): void;
  1340. /**
  1341. * 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)
  1342. * @param uniformName Name of the variable.
  1343. * @param array array to be set.
  1344. */
  1345. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1346. /**
  1347. * 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)
  1348. * @param uniformName Name of the variable.
  1349. * @param array array to be set.
  1350. */
  1351. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1352. /**
  1353. * 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)
  1354. * @param uniformName Name of the variable.
  1355. * @param array array to be set.
  1356. */
  1357. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1358. /**
  1359. * Sets matrices on a uniform variable.
  1360. * @param uniformName Name of the variable.
  1361. * @param matrices matrices to be set.
  1362. */
  1363. setMatrices(uniformName: string, matrices: Float32Array): void;
  1364. /**
  1365. * Sets matrix on a uniform variable.
  1366. * @param uniformName Name of the variable.
  1367. * @param matrix matrix to be set.
  1368. */
  1369. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1370. /**
  1371. * 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)
  1372. * @param uniformName Name of the variable.
  1373. * @param matrix matrix to be set.
  1374. */
  1375. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1376. /**
  1377. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1378. * @param uniformName Name of the variable.
  1379. * @param matrix matrix to be set.
  1380. */
  1381. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1382. /**
  1383. * Sets a float on a uniform variable.
  1384. * @param uniformName Name of the variable.
  1385. * @param value value to be set.
  1386. */
  1387. setFloat(uniformName: string, value: number): void;
  1388. /**
  1389. * Sets a Vector2 on a uniform variable.
  1390. * @param uniformName Name of the variable.
  1391. * @param vector2 vector2 to be set.
  1392. */
  1393. setVector2(uniformName: string, vector2: IVector2Like): void;
  1394. /**
  1395. * Sets a float2 on a uniform variable.
  1396. * @param uniformName Name of the variable.
  1397. * @param x First float in float2.
  1398. * @param y Second float in float2.
  1399. */
  1400. setFloat2(uniformName: string, x: number, y: number): void;
  1401. /**
  1402. * Sets a Vector3 on a uniform variable.
  1403. * @param uniformName Name of the variable.
  1404. * @param vector3 Value to be set.
  1405. */
  1406. setVector3(uniformName: string, vector3: IVector3Like): void;
  1407. /**
  1408. * Sets a float3 on a uniform variable.
  1409. * @param uniformName Name of the variable.
  1410. * @param x First float in float3.
  1411. * @param y Second float in float3.
  1412. * @param z Third float in float3.
  1413. */
  1414. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1415. /**
  1416. * Sets a Vector4 on a uniform variable.
  1417. * @param uniformName Name of the variable.
  1418. * @param vector4 Value to be set.
  1419. */
  1420. setVector4(uniformName: string, vector4: IVector4Like): void;
  1421. /**
  1422. * Sets a float4 on a uniform variable.
  1423. * @param uniformName Name of the variable.
  1424. * @param x First float in float4.
  1425. * @param y Second float in float4.
  1426. * @param z Third float in float4.
  1427. * @param w Fourth float in float4.
  1428. */
  1429. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1430. /**
  1431. * Sets a Color3 on a uniform variable.
  1432. * @param uniformName Name of the variable.
  1433. * @param color3 Value to be set.
  1434. */
  1435. setColor3(uniformName: string, color3: IColor3Like): void;
  1436. /**
  1437. * Sets a Color4 on a uniform variable.
  1438. * @param uniformName Name of the variable.
  1439. * @param color3 Value to be set.
  1440. * @param alpha Alpha value to be set.
  1441. */
  1442. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1443. /**
  1444. * Sets a Color4 on a uniform variable
  1445. * @param uniformName defines the name of the variable
  1446. * @param color4 defines the value to be set
  1447. */
  1448. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1449. }
  1450. }
  1451. declare module BABYLON {
  1452. /**
  1453. * Class used to store gfx data (like WebGLBuffer)
  1454. */
  1455. export class DataBuffer {
  1456. private static _Counter;
  1457. /**
  1458. * Gets or sets the number of objects referencing this buffer
  1459. */
  1460. references: number;
  1461. /** Gets or sets the size of the underlying buffer */
  1462. capacity: number;
  1463. /**
  1464. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1465. */
  1466. is32Bits: boolean;
  1467. /**
  1468. * Gets the underlying buffer
  1469. */
  1470. get underlyingResource(): any;
  1471. /**
  1472. * Gets the unique id of this buffer
  1473. */
  1474. readonly uniqueId: number;
  1475. /**
  1476. * Constructs the buffer
  1477. */
  1478. constructor();
  1479. }
  1480. }
  1481. declare module BABYLON {
  1482. /** @hidden */
  1483. export interface IShaderProcessor {
  1484. attributeProcessor?: (attribute: string, preProcessors: {
  1485. [key: string]: string;
  1486. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1487. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1488. [key: string]: string;
  1489. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1490. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1491. [key: string]: string;
  1492. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1493. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1494. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1496. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1497. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1498. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1499. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1500. vertexCode: string;
  1501. fragmentCode: string;
  1502. };
  1503. }
  1504. }
  1505. declare module BABYLON {
  1506. /** @hidden */
  1507. export interface ShaderProcessingContext {
  1508. }
  1509. /** @hidden */
  1510. export interface ProcessingOptions {
  1511. defines: string[];
  1512. indexParameters: any;
  1513. isFragment: boolean;
  1514. shouldUseHighPrecisionShader: boolean;
  1515. supportsUniformBuffers: boolean;
  1516. shadersRepository: string;
  1517. includesShadersStore: {
  1518. [key: string]: string;
  1519. };
  1520. processor: Nullable<IShaderProcessor>;
  1521. version: string;
  1522. platformName: string;
  1523. lookForClosingBracketForUniformBuffer?: boolean;
  1524. processingContext: Nullable<ShaderProcessingContext>;
  1525. }
  1526. }
  1527. declare module BABYLON {
  1528. /** @hidden */
  1529. export class ShaderCodeNode {
  1530. line: string;
  1531. children: ShaderCodeNode[];
  1532. additionalDefineKey?: string;
  1533. additionalDefineValue?: string;
  1534. isValid(preprocessors: {
  1535. [key: string]: string;
  1536. }): boolean;
  1537. process(preprocessors: {
  1538. [key: string]: string;
  1539. }, options: ProcessingOptions): string;
  1540. }
  1541. }
  1542. declare module BABYLON {
  1543. /** @hidden */
  1544. export class ShaderCodeCursor {
  1545. private _lines;
  1546. lineIndex: number;
  1547. get currentLine(): string;
  1548. get canRead(): boolean;
  1549. set lines(value: string[]);
  1550. }
  1551. }
  1552. declare module BABYLON {
  1553. /** @hidden */
  1554. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1555. process(preprocessors: {
  1556. [key: string]: string;
  1557. }, options: ProcessingOptions): string;
  1558. }
  1559. }
  1560. declare module BABYLON {
  1561. /** @hidden */
  1562. export class ShaderDefineExpression {
  1563. isTrue(preprocessors: {
  1564. [key: string]: string;
  1565. }): boolean;
  1566. private static _OperatorPriority;
  1567. private static _Stack;
  1568. static postfixToInfix(postfix: string[]): string;
  1569. static infixToPostfix(infix: string): string[];
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /** @hidden */
  1574. export class ShaderCodeTestNode extends ShaderCodeNode {
  1575. testExpression: ShaderDefineExpression;
  1576. isValid(preprocessors: {
  1577. [key: string]: string;
  1578. }): boolean;
  1579. }
  1580. }
  1581. declare module BABYLON {
  1582. /** @hidden */
  1583. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1584. define: string;
  1585. not: boolean;
  1586. constructor(define: string, not?: boolean);
  1587. isTrue(preprocessors: {
  1588. [key: string]: string;
  1589. }): boolean;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /** @hidden */
  1594. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1595. leftOperand: ShaderDefineExpression;
  1596. rightOperand: ShaderDefineExpression;
  1597. isTrue(preprocessors: {
  1598. [key: string]: string;
  1599. }): boolean;
  1600. }
  1601. }
  1602. declare module BABYLON {
  1603. /** @hidden */
  1604. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1605. leftOperand: ShaderDefineExpression;
  1606. rightOperand: ShaderDefineExpression;
  1607. isTrue(preprocessors: {
  1608. [key: string]: string;
  1609. }): boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /** @hidden */
  1614. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1615. define: string;
  1616. operand: string;
  1617. testValue: string;
  1618. constructor(define: string, operand: string, testValue: string);
  1619. isTrue(preprocessors: {
  1620. [key: string]: string;
  1621. }): boolean;
  1622. }
  1623. }
  1624. declare module BABYLON {
  1625. /**
  1626. * Class used to enable access to offline support
  1627. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1628. */
  1629. export interface IOfflineProvider {
  1630. /**
  1631. * Gets a boolean indicating if scene must be saved in the database
  1632. */
  1633. enableSceneOffline: boolean;
  1634. /**
  1635. * Gets a boolean indicating if textures must be saved in the database
  1636. */
  1637. enableTexturesOffline: boolean;
  1638. /**
  1639. * Open the offline support and make it available
  1640. * @param successCallback defines the callback to call on success
  1641. * @param errorCallback defines the callback to call on error
  1642. */
  1643. open(successCallback: () => void, errorCallback: () => void): void;
  1644. /**
  1645. * Loads an image from the offline support
  1646. * @param url defines the url to load from
  1647. * @param image defines the target DOM image
  1648. */
  1649. loadImage(url: string, image: HTMLImageElement): void;
  1650. /**
  1651. * Loads a file from offline support
  1652. * @param url defines the URL to load from
  1653. * @param sceneLoaded defines a callback to call on success
  1654. * @param progressCallBack defines a callback to call when progress changed
  1655. * @param errorCallback defines a callback to call on error
  1656. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1657. */
  1658. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1659. }
  1660. }
  1661. declare module BABYLON {
  1662. /**
  1663. * Class used to help managing file picking and drag'n'drop
  1664. * File Storage
  1665. */
  1666. export class FilesInputStore {
  1667. /**
  1668. * List of files ready to be loaded
  1669. */
  1670. static FilesToLoad: {
  1671. [key: string]: File;
  1672. };
  1673. }
  1674. }
  1675. declare module BABYLON {
  1676. /**
  1677. * Class used to define a retry strategy when error happens while loading assets
  1678. */
  1679. export class RetryStrategy {
  1680. /**
  1681. * Function used to defines an exponential back off strategy
  1682. * @param maxRetries defines the maximum number of retries (3 by default)
  1683. * @param baseInterval defines the interval between retries
  1684. * @returns the strategy function to use
  1685. */
  1686. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1687. }
  1688. }
  1689. declare module BABYLON {
  1690. /**
  1691. * @ignore
  1692. * Application error to support additional information when loading a file
  1693. */
  1694. export abstract class BaseError extends Error {
  1695. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1696. }
  1697. }
  1698. declare module BABYLON {
  1699. /** @ignore */
  1700. export class LoadFileError extends BaseError {
  1701. request?: WebRequest;
  1702. file?: File;
  1703. /**
  1704. * Creates a new LoadFileError
  1705. * @param message defines the message of the error
  1706. * @param request defines the optional web request
  1707. * @param file defines the optional file
  1708. */
  1709. constructor(message: string, object?: WebRequest | File);
  1710. }
  1711. /** @ignore */
  1712. export class RequestFileError extends BaseError {
  1713. request: WebRequest;
  1714. /**
  1715. * Creates a new LoadFileError
  1716. * @param message defines the message of the error
  1717. * @param request defines the optional web request
  1718. */
  1719. constructor(message: string, request: WebRequest);
  1720. }
  1721. /** @ignore */
  1722. export class ReadFileError extends BaseError {
  1723. file: File;
  1724. /**
  1725. * Creates a new ReadFileError
  1726. * @param message defines the message of the error
  1727. * @param file defines the optional file
  1728. */
  1729. constructor(message: string, file: File);
  1730. }
  1731. /**
  1732. * @hidden
  1733. */
  1734. export class FileTools {
  1735. /**
  1736. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1737. */
  1738. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1739. /**
  1740. * Gets or sets the base URL to use to load assets
  1741. */
  1742. static BaseUrl: string;
  1743. /**
  1744. * Default behaviour for cors in the application.
  1745. * It can be a string if the expected behavior is identical in the entire app.
  1746. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1747. */
  1748. static CorsBehavior: string | ((url: string | string[]) => string);
  1749. /**
  1750. * Gets or sets a function used to pre-process url before using them to load assets
  1751. */
  1752. static PreprocessUrl: (url: string) => string;
  1753. /**
  1754. * Removes unwanted characters from an url
  1755. * @param url defines the url to clean
  1756. * @returns the cleaned url
  1757. */
  1758. private static _CleanUrl;
  1759. /**
  1760. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1761. * @param url define the url we are trying
  1762. * @param element define the dom element where to configure the cors policy
  1763. */
  1764. static SetCorsBehavior(url: string | string[], element: {
  1765. crossOrigin: string | null;
  1766. }): void;
  1767. /**
  1768. * Loads an image as an HTMLImageElement.
  1769. * @param input url string, ArrayBuffer, or Blob to load
  1770. * @param onLoad callback called when the image successfully loads
  1771. * @param onError callback called when the image fails to load
  1772. * @param offlineProvider offline provider for caching
  1773. * @param mimeType optional mime type
  1774. * @returns the HTMLImageElement of the loaded image
  1775. */
  1776. 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>;
  1777. /**
  1778. * Reads a file from a File object
  1779. * @param file defines the file to load
  1780. * @param onSuccess defines the callback to call when data is loaded
  1781. * @param onProgress defines the callback to call during loading process
  1782. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1783. * @param onError defines the callback to call when an error occurs
  1784. * @returns a file request object
  1785. */
  1786. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1787. /**
  1788. * Loads a file from a url
  1789. * @param url url to load
  1790. * @param onSuccess callback called when the file successfully loads
  1791. * @param onProgress callback called while file is loading (if the server supports this mode)
  1792. * @param offlineProvider defines the offline provider for caching
  1793. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1794. * @param onError callback called when the file fails to load
  1795. * @returns a file request object
  1796. */
  1797. 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;
  1798. /**
  1799. * Loads a file
  1800. * @param url url to load
  1801. * @param onSuccess callback called when the file successfully loads
  1802. * @param onProgress callback called while file is loading (if the server supports this mode)
  1803. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1804. * @param onError callback called when the file fails to load
  1805. * @param onOpened callback called when the web request is opened
  1806. * @returns a file request object
  1807. */
  1808. 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;
  1809. /**
  1810. * Checks if the loaded document was accessed via `file:`-Protocol.
  1811. * @returns boolean
  1812. */
  1813. static IsFileURL(): boolean;
  1814. }
  1815. }
  1816. declare module BABYLON {
  1817. /** @hidden */
  1818. export class ShaderProcessor {
  1819. static Initialize(options: ProcessingOptions): void;
  1820. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1821. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1822. vertexCode: string;
  1823. fragmentCode: string;
  1824. };
  1825. private static _ProcessPrecision;
  1826. private static _ExtractOperation;
  1827. private static _BuildSubExpression;
  1828. private static _BuildExpression;
  1829. private static _MoveCursorWithinIf;
  1830. private static _MoveCursor;
  1831. private static _EvaluatePreProcessors;
  1832. private static _PreparePreProcessors;
  1833. private static _ProcessShaderConversion;
  1834. private static _ProcessIncludes;
  1835. /**
  1836. * Loads a file from a url
  1837. * @param url url to load
  1838. * @param onSuccess callback called when the file successfully loads
  1839. * @param onProgress callback called while file is loading (if the server supports this mode)
  1840. * @param offlineProvider defines the offline provider for caching
  1841. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1842. * @param onError callback called when the file fails to load
  1843. * @returns a file request object
  1844. * @hidden
  1845. */
  1846. 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;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Interface used to define common properties for effect fallbacks
  1852. */
  1853. export interface IEffectFallbacks {
  1854. /**
  1855. * Removes the defines that should be removed when falling back.
  1856. * @param currentDefines defines the current define statements for the shader.
  1857. * @param effect defines the current effect we try to compile
  1858. * @returns The resulting defines with defines of the current rank removed.
  1859. */
  1860. reduce(currentDefines: string, effect: Effect): string;
  1861. /**
  1862. * Removes the fallback from the bound mesh.
  1863. */
  1864. unBindMesh(): void;
  1865. /**
  1866. * Checks to see if more fallbacks are still availible.
  1867. */
  1868. hasMoreFallbacks: boolean;
  1869. }
  1870. }
  1871. declare module BABYLON {
  1872. /**
  1873. * Interface for the size containing width and height
  1874. */
  1875. export interface ISize {
  1876. /**
  1877. * Width
  1878. */
  1879. width: number;
  1880. /**
  1881. * Heighht
  1882. */
  1883. height: number;
  1884. }
  1885. /**
  1886. * Size containing widht and height
  1887. */
  1888. export class Size implements ISize {
  1889. /**
  1890. * Width
  1891. */
  1892. width: number;
  1893. /**
  1894. * Height
  1895. */
  1896. height: number;
  1897. /**
  1898. * Creates a Size object from the given width and height (floats).
  1899. * @param width width of the new size
  1900. * @param height height of the new size
  1901. */
  1902. constructor(width: number, height: number);
  1903. /**
  1904. * Returns a string with the Size width and height
  1905. * @returns a string with the Size width and height
  1906. */
  1907. toString(): string;
  1908. /**
  1909. * "Size"
  1910. * @returns the string "Size"
  1911. */
  1912. getClassName(): string;
  1913. /**
  1914. * Returns the Size hash code.
  1915. * @returns a hash code for a unique width and height
  1916. */
  1917. getHashCode(): number;
  1918. /**
  1919. * Updates the current size from the given one.
  1920. * @param src the given size
  1921. */
  1922. copyFrom(src: Size): void;
  1923. /**
  1924. * Updates in place the current Size from the given floats.
  1925. * @param width width of the new size
  1926. * @param height height of the new size
  1927. * @returns the updated Size.
  1928. */
  1929. copyFromFloats(width: number, height: number): Size;
  1930. /**
  1931. * Updates in place the current Size from the given floats.
  1932. * @param width width to set
  1933. * @param height height to set
  1934. * @returns the updated Size.
  1935. */
  1936. set(width: number, height: number): Size;
  1937. /**
  1938. * Multiplies the width and height by numbers
  1939. * @param w factor to multiple the width by
  1940. * @param h factor to multiple the height by
  1941. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1942. */
  1943. multiplyByFloats(w: number, h: number): Size;
  1944. /**
  1945. * Clones the size
  1946. * @returns a new Size copied from the given one.
  1947. */
  1948. clone(): Size;
  1949. /**
  1950. * True if the current Size and the given one width and height are strictly equal.
  1951. * @param other the other size to compare against
  1952. * @returns True if the current Size and the given one width and height are strictly equal.
  1953. */
  1954. equals(other: Size): boolean;
  1955. /**
  1956. * The surface of the Size : width * height (float).
  1957. */
  1958. get surface(): number;
  1959. /**
  1960. * Create a new size of zero
  1961. * @returns a new Size set to (0.0, 0.0)
  1962. */
  1963. static Zero(): Size;
  1964. /**
  1965. * Sums the width and height of two sizes
  1966. * @param otherSize size to add to this size
  1967. * @returns a new Size set as the addition result of the current Size and the given one.
  1968. */
  1969. add(otherSize: Size): Size;
  1970. /**
  1971. * Subtracts the width and height of two
  1972. * @param otherSize size to subtract to this size
  1973. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1974. */
  1975. subtract(otherSize: Size): Size;
  1976. /**
  1977. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1978. * @param start starting size to lerp between
  1979. * @param end end size to lerp between
  1980. * @param amount amount to lerp between the start and end values
  1981. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1982. */
  1983. static Lerp(start: Size, end: Size, amount: number): Size;
  1984. }
  1985. }
  1986. declare module BABYLON {
  1987. /**
  1988. * Base class of all the textures in babylon.
  1989. * It groups all the common properties required to work with Thin Engine.
  1990. */
  1991. export class ThinTexture {
  1992. protected _wrapU: number;
  1993. /**
  1994. * | Value | Type | Description |
  1995. * | ----- | ------------------ | ----------- |
  1996. * | 0 | CLAMP_ADDRESSMODE | |
  1997. * | 1 | WRAP_ADDRESSMODE | |
  1998. * | 2 | MIRROR_ADDRESSMODE | |
  1999. */
  2000. get wrapU(): number;
  2001. set wrapU(value: number);
  2002. protected _wrapV: number;
  2003. /**
  2004. * | Value | Type | Description |
  2005. * | ----- | ------------------ | ----------- |
  2006. * | 0 | CLAMP_ADDRESSMODE | |
  2007. * | 1 | WRAP_ADDRESSMODE | |
  2008. * | 2 | MIRROR_ADDRESSMODE | |
  2009. */
  2010. get wrapV(): number;
  2011. set wrapV(value: number);
  2012. /**
  2013. * | Value | Type | Description |
  2014. * | ----- | ------------------ | ----------- |
  2015. * | 0 | CLAMP_ADDRESSMODE | |
  2016. * | 1 | WRAP_ADDRESSMODE | |
  2017. * | 2 | MIRROR_ADDRESSMODE | |
  2018. */
  2019. wrapR: number;
  2020. /**
  2021. * With compliant hardware and browser (supporting anisotropic filtering)
  2022. * this defines the level of anisotropic filtering in the texture.
  2023. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2024. */
  2025. anisotropicFilteringLevel: number;
  2026. /**
  2027. * Define the current state of the loading sequence when in delayed load mode.
  2028. */
  2029. delayLoadState: number;
  2030. /**
  2031. * How a texture is mapped.
  2032. * Unused in thin texture mode.
  2033. */
  2034. get coordinatesMode(): number;
  2035. /**
  2036. * Define if the texture is a cube texture or if false a 2d texture.
  2037. */
  2038. get isCube(): boolean;
  2039. set isCube(value: boolean);
  2040. /**
  2041. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2042. */
  2043. get is3D(): boolean;
  2044. set is3D(value: boolean);
  2045. /**
  2046. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is2DArray(): boolean;
  2049. set is2DArray(value: boolean);
  2050. /**
  2051. * Get the class name of the texture.
  2052. * @returns "ThinTexture"
  2053. */
  2054. getClassName(): string;
  2055. /** @hidden */
  2056. _texture: Nullable<InternalTexture>;
  2057. protected _engine: Nullable<ThinEngine>;
  2058. private _cachedSize;
  2059. private _cachedBaseSize;
  2060. /**
  2061. * Instantiates a new ThinTexture.
  2062. * Base class of all the textures in babylon.
  2063. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2064. * @param internalTexture Define the internalTexture to wrap
  2065. */
  2066. constructor(internalTexture: Nullable<InternalTexture>);
  2067. /**
  2068. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2069. * @returns true if fully ready
  2070. */
  2071. isReady(): boolean;
  2072. /**
  2073. * Triggers the load sequence in delayed load mode.
  2074. */
  2075. delayLoad(): void;
  2076. /**
  2077. * Get the underlying lower level texture from Babylon.
  2078. * @returns the insternal texture
  2079. */
  2080. getInternalTexture(): Nullable<InternalTexture>;
  2081. /**
  2082. * Get the size of the texture.
  2083. * @returns the texture size.
  2084. */
  2085. getSize(): ISize;
  2086. /**
  2087. * Get the base size of the texture.
  2088. * It can be different from the size if the texture has been resized for POT for instance
  2089. * @returns the base size
  2090. */
  2091. getBaseSize(): ISize;
  2092. /**
  2093. * Update the sampling mode of the texture.
  2094. * Default is Trilinear mode.
  2095. *
  2096. * | Value | Type | Description |
  2097. * | ----- | ------------------ | ----------- |
  2098. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2099. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2100. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2101. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2102. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2103. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2104. * | 7 | NEAREST_LINEAR | |
  2105. * | 8 | NEAREST_NEAREST | |
  2106. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2107. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2108. * | 11 | LINEAR_LINEAR | |
  2109. * | 12 | LINEAR_NEAREST | |
  2110. *
  2111. * > _mag_: magnification filter (close to the viewer)
  2112. * > _min_: minification filter (far from the viewer)
  2113. * > _mip_: filter used between mip map levels
  2114. *@param samplingMode Define the new sampling mode of the texture
  2115. */
  2116. updateSamplingMode(samplingMode: number): void;
  2117. /**
  2118. * Release and destroy the underlying lower level texture aka internalTexture.
  2119. */
  2120. releaseInternalTexture(): void;
  2121. /**
  2122. * Dispose the texture and release its associated resources.
  2123. */
  2124. dispose(): void;
  2125. }
  2126. }
  2127. declare module BABYLON {
  2128. /**
  2129. * Defines an array and its length.
  2130. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2131. */
  2132. export interface ISmartArrayLike<T> {
  2133. /**
  2134. * The data of the array.
  2135. */
  2136. data: Array<T>;
  2137. /**
  2138. * The active length of the array.
  2139. */
  2140. length: number;
  2141. }
  2142. /**
  2143. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2144. */
  2145. export class SmartArray<T> implements ISmartArrayLike<T> {
  2146. /**
  2147. * The full set of data from the array.
  2148. */
  2149. data: Array<T>;
  2150. /**
  2151. * The active length of the array.
  2152. */
  2153. length: number;
  2154. protected _id: number;
  2155. /**
  2156. * Instantiates a Smart Array.
  2157. * @param capacity defines the default capacity of the array.
  2158. */
  2159. constructor(capacity: number);
  2160. /**
  2161. * Pushes a value at the end of the active data.
  2162. * @param value defines the object to push in the array.
  2163. */
  2164. push(value: T): void;
  2165. /**
  2166. * Iterates over the active data and apply the lambda to them.
  2167. * @param func defines the action to apply on each value.
  2168. */
  2169. forEach(func: (content: T) => void): void;
  2170. /**
  2171. * Sorts the full sets of data.
  2172. * @param compareFn defines the comparison function to apply.
  2173. */
  2174. sort(compareFn: (a: T, b: T) => number): void;
  2175. /**
  2176. * Resets the active data to an empty array.
  2177. */
  2178. reset(): void;
  2179. /**
  2180. * Releases all the data from the array as well as the array.
  2181. */
  2182. dispose(): void;
  2183. /**
  2184. * Concats the active data with a given array.
  2185. * @param array defines the data to concatenate with.
  2186. */
  2187. concat(array: any): void;
  2188. /**
  2189. * Returns the position of a value in the active data.
  2190. * @param value defines the value to find the index for
  2191. * @returns the index if found in the active data otherwise -1
  2192. */
  2193. indexOf(value: T): number;
  2194. /**
  2195. * Returns whether an element is part of the active data.
  2196. * @param value defines the value to look for
  2197. * @returns true if found in the active data otherwise false
  2198. */
  2199. contains(value: T): boolean;
  2200. private static _GlobalId;
  2201. }
  2202. /**
  2203. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2204. * The data in this array can only be present once
  2205. */
  2206. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2207. private _duplicateId;
  2208. /**
  2209. * Pushes a value at the end of the active data.
  2210. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2211. * @param value defines the object to push in the array.
  2212. */
  2213. push(value: T): void;
  2214. /**
  2215. * Pushes a value at the end of the active data.
  2216. * If the data is already present, it won t be added again
  2217. * @param value defines the object to push in the array.
  2218. * @returns true if added false if it was already present
  2219. */
  2220. pushNoDuplicate(value: T): boolean;
  2221. /**
  2222. * Resets the active data to an empty array.
  2223. */
  2224. reset(): void;
  2225. /**
  2226. * Concats the active data with a given array.
  2227. * This ensures no dupplicate will be present in the result.
  2228. * @param array defines the data to concatenate with.
  2229. */
  2230. concatWithNoDuplicate(array: any): void;
  2231. }
  2232. }
  2233. declare module BABYLON {
  2234. /**
  2235. * Class used to evalaute queries containing `and` and `or` operators
  2236. */
  2237. export class AndOrNotEvaluator {
  2238. /**
  2239. * Evaluate a query
  2240. * @param query defines the query to evaluate
  2241. * @param evaluateCallback defines the callback used to filter result
  2242. * @returns true if the query matches
  2243. */
  2244. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2245. private static _HandleParenthesisContent;
  2246. private static _SimplifyNegation;
  2247. }
  2248. }
  2249. declare module BABYLON {
  2250. /**
  2251. * Class used to store custom tags
  2252. */
  2253. export class Tags {
  2254. /**
  2255. * Adds support for tags on the given object
  2256. * @param obj defines the object to use
  2257. */
  2258. static EnableFor(obj: any): void;
  2259. /**
  2260. * Removes tags support
  2261. * @param obj defines the object to use
  2262. */
  2263. static DisableFor(obj: any): void;
  2264. /**
  2265. * Gets a boolean indicating if the given object has tags
  2266. * @param obj defines the object to use
  2267. * @returns a boolean
  2268. */
  2269. static HasTags(obj: any): boolean;
  2270. /**
  2271. * Gets the tags available on a given object
  2272. * @param obj defines the object to use
  2273. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2274. * @returns the tags
  2275. */
  2276. static GetTags(obj: any, asString?: boolean): any;
  2277. /**
  2278. * Adds tags to an object
  2279. * @param obj defines the object to use
  2280. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2281. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2282. */
  2283. static AddTagsTo(obj: any, tagsString: string): void;
  2284. /**
  2285. * @hidden
  2286. */
  2287. static _AddTagTo(obj: any, tag: string): void;
  2288. /**
  2289. * Removes specific tags from a specific object
  2290. * @param obj defines the object to use
  2291. * @param tagsString defines the tags to remove
  2292. */
  2293. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2294. /**
  2295. * @hidden
  2296. */
  2297. static _RemoveTagFrom(obj: any, tag: string): void;
  2298. /**
  2299. * Defines if tags hosted on an object match a given query
  2300. * @param obj defines the object to use
  2301. * @param tagsQuery defines the tag query
  2302. * @returns a boolean
  2303. */
  2304. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2305. }
  2306. }
  2307. declare module BABYLON {
  2308. /**
  2309. * Scalar computation library
  2310. */
  2311. export class Scalar {
  2312. /**
  2313. * Two pi constants convenient for computation.
  2314. */
  2315. static TwoPi: number;
  2316. /**
  2317. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2318. * @param a number
  2319. * @param b number
  2320. * @param epsilon (default = 1.401298E-45)
  2321. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2322. */
  2323. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2324. /**
  2325. * Returns a string : the upper case translation of the number i to hexadecimal.
  2326. * @param i number
  2327. * @returns the upper case translation of the number i to hexadecimal.
  2328. */
  2329. static ToHex(i: number): string;
  2330. /**
  2331. * Returns -1 if value is negative and +1 is value is positive.
  2332. * @param value the value
  2333. * @returns the value itself if it's equal to zero.
  2334. */
  2335. static Sign(value: number): number;
  2336. /**
  2337. * Returns the value itself if it's between min and max.
  2338. * Returns min if the value is lower than min.
  2339. * Returns max if the value is greater than max.
  2340. * @param value the value to clmap
  2341. * @param min the min value to clamp to (default: 0)
  2342. * @param max the max value to clamp to (default: 1)
  2343. * @returns the clamped value
  2344. */
  2345. static Clamp(value: number, min?: number, max?: number): number;
  2346. /**
  2347. * the log2 of value.
  2348. * @param value the value to compute log2 of
  2349. * @returns the log2 of value.
  2350. */
  2351. static Log2(value: number): number;
  2352. /**
  2353. * the floor part of a log2 value.
  2354. * @param value the value to compute log2 of
  2355. * @returns the log2 of value.
  2356. */
  2357. static ILog2(value: number): number;
  2358. /**
  2359. * Loops the value, so that it is never larger than length and never smaller than 0.
  2360. *
  2361. * This is similar to the modulo operator but it works with floating point numbers.
  2362. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2363. * With t = 5 and length = 2.5, the result would be 0.0.
  2364. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2365. * @param value the value
  2366. * @param length the length
  2367. * @returns the looped value
  2368. */
  2369. static Repeat(value: number, length: number): number;
  2370. /**
  2371. * Normalize the value between 0.0 and 1.0 using min and max values
  2372. * @param value value to normalize
  2373. * @param min max to normalize between
  2374. * @param max min to normalize between
  2375. * @returns the normalized value
  2376. */
  2377. static Normalize(value: number, min: number, max: number): number;
  2378. /**
  2379. * Denormalize the value from 0.0 and 1.0 using min and max values
  2380. * @param normalized value to denormalize
  2381. * @param min max to denormalize between
  2382. * @param max min to denormalize between
  2383. * @returns the denormalized value
  2384. */
  2385. static Denormalize(normalized: number, min: number, max: number): number;
  2386. /**
  2387. * Calculates the shortest difference between two given angles given in degrees.
  2388. * @param current current angle in degrees
  2389. * @param target target angle in degrees
  2390. * @returns the delta
  2391. */
  2392. static DeltaAngle(current: number, target: number): number;
  2393. /**
  2394. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2395. * @param tx value
  2396. * @param length length
  2397. * @returns The returned value will move back and forth between 0 and length
  2398. */
  2399. static PingPong(tx: number, length: number): number;
  2400. /**
  2401. * Interpolates between min and max with smoothing at the limits.
  2402. *
  2403. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2404. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2405. * @param from from
  2406. * @param to to
  2407. * @param tx value
  2408. * @returns the smooth stepped value
  2409. */
  2410. static SmoothStep(from: number, to: number, tx: number): number;
  2411. /**
  2412. * Moves a value current towards target.
  2413. *
  2414. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2415. * Negative values of maxDelta pushes the value away from target.
  2416. * @param current current value
  2417. * @param target target value
  2418. * @param maxDelta max distance to move
  2419. * @returns resulting value
  2420. */
  2421. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2422. /**
  2423. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2424. *
  2425. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2426. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2427. * @param current current value
  2428. * @param target target value
  2429. * @param maxDelta max distance to move
  2430. * @returns resulting angle
  2431. */
  2432. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2433. /**
  2434. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2435. * @param start start value
  2436. * @param end target value
  2437. * @param amount amount to lerp between
  2438. * @returns the lerped value
  2439. */
  2440. static Lerp(start: number, end: number, amount: number): number;
  2441. /**
  2442. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2443. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2444. * @param start start value
  2445. * @param end target value
  2446. * @param amount amount to lerp between
  2447. * @returns the lerped value
  2448. */
  2449. static LerpAngle(start: number, end: number, amount: number): number;
  2450. /**
  2451. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2452. * @param a start value
  2453. * @param b target value
  2454. * @param value value between a and b
  2455. * @returns the inverseLerp value
  2456. */
  2457. static InverseLerp(a: number, b: number, value: number): number;
  2458. /**
  2459. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2460. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2461. * @param value1 spline value
  2462. * @param tangent1 spline value
  2463. * @param value2 spline value
  2464. * @param tangent2 spline value
  2465. * @param amount input value
  2466. * @returns hermite result
  2467. */
  2468. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2469. /**
  2470. * Returns a random float number between and min and max values
  2471. * @param min min value of random
  2472. * @param max max value of random
  2473. * @returns random value
  2474. */
  2475. static RandomRange(min: number, max: number): number;
  2476. /**
  2477. * This function returns percentage of a number in a given range.
  2478. *
  2479. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2480. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2481. * @param number to convert to percentage
  2482. * @param min min range
  2483. * @param max max range
  2484. * @returns the percentage
  2485. */
  2486. static RangeToPercent(number: number, min: number, max: number): number;
  2487. /**
  2488. * This function returns number that corresponds to the percentage in a given range.
  2489. *
  2490. * PercentToRange(0.34,0,100) will return 34.
  2491. * @param percent to convert to number
  2492. * @param min min range
  2493. * @param max max range
  2494. * @returns the number
  2495. */
  2496. static PercentToRange(percent: number, min: number, max: number): number;
  2497. /**
  2498. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2499. * @param angle The angle to normalize in radian.
  2500. * @return The converted angle.
  2501. */
  2502. static NormalizeRadians(angle: number): number;
  2503. }
  2504. }
  2505. declare module BABYLON {
  2506. /**
  2507. * Constant used to convert a value to gamma space
  2508. * @ignorenaming
  2509. */
  2510. export const ToGammaSpace: number;
  2511. /**
  2512. * Constant used to convert a value to linear space
  2513. * @ignorenaming
  2514. */
  2515. export const ToLinearSpace = 2.2;
  2516. /**
  2517. * Constant used to define the minimal number value in Babylon.js
  2518. * @ignorenaming
  2519. */
  2520. let Epsilon: number;
  2521. }
  2522. declare module BABYLON {
  2523. /**
  2524. * Class used to represent a viewport on screen
  2525. */
  2526. export class Viewport {
  2527. /** viewport left coordinate */
  2528. x: number;
  2529. /** viewport top coordinate */
  2530. y: number;
  2531. /**viewport width */
  2532. width: number;
  2533. /** viewport height */
  2534. height: number;
  2535. /**
  2536. * Creates a Viewport object located at (x, y) and sized (width, height)
  2537. * @param x defines viewport left coordinate
  2538. * @param y defines viewport top coordinate
  2539. * @param width defines the viewport width
  2540. * @param height defines the viewport height
  2541. */
  2542. constructor(
  2543. /** viewport left coordinate */
  2544. x: number,
  2545. /** viewport top coordinate */
  2546. y: number,
  2547. /**viewport width */
  2548. width: number,
  2549. /** viewport height */
  2550. height: number);
  2551. /**
  2552. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2553. * @param renderWidth defines the rendering width
  2554. * @param renderHeight defines the rendering height
  2555. * @returns a new Viewport
  2556. */
  2557. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2558. /**
  2559. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2560. * @param renderWidth defines the rendering width
  2561. * @param renderHeight defines the rendering height
  2562. * @param ref defines the target viewport
  2563. * @returns the current viewport
  2564. */
  2565. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2566. /**
  2567. * Returns a new Viewport copied from the current one
  2568. * @returns a new Viewport
  2569. */
  2570. clone(): Viewport;
  2571. }
  2572. }
  2573. declare module BABYLON {
  2574. /**
  2575. * Class containing a set of static utilities functions for arrays.
  2576. */
  2577. export class ArrayTools {
  2578. /**
  2579. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2580. * @param size the number of element to construct and put in the array
  2581. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2582. * @returns a new array filled with new objects
  2583. */
  2584. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2585. }
  2586. }
  2587. declare module BABYLON {
  2588. /**
  2589. * Represents a plane by the equation ax + by + cz + d = 0
  2590. */
  2591. export class Plane {
  2592. private static _TmpMatrix;
  2593. /**
  2594. * Normal of the plane (a,b,c)
  2595. */
  2596. normal: Vector3;
  2597. /**
  2598. * d component of the plane
  2599. */
  2600. d: number;
  2601. /**
  2602. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2603. * @param a a component of the plane
  2604. * @param b b component of the plane
  2605. * @param c c component of the plane
  2606. * @param d d component of the plane
  2607. */
  2608. constructor(a: number, b: number, c: number, d: number);
  2609. /**
  2610. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2611. */
  2612. asArray(): number[];
  2613. /**
  2614. * @returns a new plane copied from the current Plane.
  2615. */
  2616. clone(): Plane;
  2617. /**
  2618. * @returns the string "Plane".
  2619. */
  2620. getClassName(): string;
  2621. /**
  2622. * @returns the Plane hash code.
  2623. */
  2624. getHashCode(): number;
  2625. /**
  2626. * Normalize the current Plane in place.
  2627. * @returns the updated Plane.
  2628. */
  2629. normalize(): Plane;
  2630. /**
  2631. * Applies a transformation the plane and returns the result
  2632. * @param transformation the transformation matrix to be applied to the plane
  2633. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2634. */
  2635. transform(transformation: DeepImmutable<Matrix>): Plane;
  2636. /**
  2637. * Compute the dot product between the point and the plane normal
  2638. * @param point point to calculate the dot product with
  2639. * @returns the dot product (float) of the point coordinates and the plane normal.
  2640. */
  2641. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2642. /**
  2643. * Updates the current Plane from the plane defined by the three given points.
  2644. * @param point1 one of the points used to contruct the plane
  2645. * @param point2 one of the points used to contruct the plane
  2646. * @param point3 one of the points used to contruct the plane
  2647. * @returns the updated Plane.
  2648. */
  2649. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2650. /**
  2651. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2652. * Note that for this function to work as expected you should make sure that:
  2653. * - direction and the plane normal are normalized
  2654. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2655. * @param direction the direction to check if the plane is facing
  2656. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2657. * @returns True if the plane is facing the given direction
  2658. */
  2659. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2660. /**
  2661. * Calculates the distance to a point
  2662. * @param point point to calculate distance to
  2663. * @returns the signed distance (float) from the given point to the Plane.
  2664. */
  2665. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2666. /**
  2667. * Creates a plane from an array
  2668. * @param array the array to create a plane from
  2669. * @returns a new Plane from the given array.
  2670. */
  2671. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2672. /**
  2673. * Creates a plane from three points
  2674. * @param point1 point used to create the plane
  2675. * @param point2 point used to create the plane
  2676. * @param point3 point used to create the plane
  2677. * @returns a new Plane defined by the three given points.
  2678. */
  2679. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2680. /**
  2681. * Creates a plane from an origin point and a normal
  2682. * @param origin origin of the plane to be constructed
  2683. * @param normal normal of the plane to be constructed
  2684. * @returns a new Plane the normal vector to this plane at the given origin point.
  2685. * Note : the vector "normal" is updated because normalized.
  2686. */
  2687. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2688. /**
  2689. * Calculates the distance from a plane and a point
  2690. * @param origin origin of the plane to be constructed
  2691. * @param normal normal of the plane to be constructed
  2692. * @param point point to calculate distance to
  2693. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2694. */
  2695. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2696. }
  2697. }
  2698. declare module BABYLON {
  2699. /** @hidden */
  2700. export class PerformanceConfigurator {
  2701. /** @hidden */
  2702. static MatrixUse64Bits: boolean;
  2703. /** @hidden */
  2704. static MatrixTrackPrecisionChange: boolean;
  2705. /** @hidden */
  2706. static MatrixCurrentType: any;
  2707. /** @hidden */
  2708. static MatrixTrackedMatrices: Array<any> | null;
  2709. /** @hidden */
  2710. static SetMatrixPrecision(use64bits: boolean): void;
  2711. }
  2712. }
  2713. declare module BABYLON {
  2714. /**
  2715. * Class representing a vector containing 2 coordinates
  2716. */
  2717. export class Vector2 {
  2718. /** defines the first coordinate */
  2719. x: number;
  2720. /** defines the second coordinate */
  2721. y: number;
  2722. /**
  2723. * Creates a new Vector2 from the given x and y coordinates
  2724. * @param x defines the first coordinate
  2725. * @param y defines the second coordinate
  2726. */
  2727. constructor(
  2728. /** defines the first coordinate */
  2729. x?: number,
  2730. /** defines the second coordinate */
  2731. y?: number);
  2732. /**
  2733. * Gets a string with the Vector2 coordinates
  2734. * @returns a string with the Vector2 coordinates
  2735. */
  2736. toString(): string;
  2737. /**
  2738. * Gets class name
  2739. * @returns the string "Vector2"
  2740. */
  2741. getClassName(): string;
  2742. /**
  2743. * Gets current vector hash code
  2744. * @returns the Vector2 hash code as a number
  2745. */
  2746. getHashCode(): number;
  2747. /**
  2748. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2749. * @param array defines the source array
  2750. * @param index defines the offset in source array
  2751. * @returns the current Vector2
  2752. */
  2753. toArray(array: FloatArray, index?: number): Vector2;
  2754. /**
  2755. * Update the current vector from an array
  2756. * @param array defines the destination array
  2757. * @param index defines the offset in the destination array
  2758. * @returns the current Vector3
  2759. */
  2760. fromArray(array: FloatArray, index?: number): Vector2;
  2761. /**
  2762. * Copy the current vector to an array
  2763. * @returns a new array with 2 elements: the Vector2 coordinates.
  2764. */
  2765. asArray(): number[];
  2766. /**
  2767. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2768. * @param source defines the source Vector2
  2769. * @returns the current updated Vector2
  2770. */
  2771. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2772. /**
  2773. * Sets the Vector2 coordinates with the given floats
  2774. * @param x defines the first coordinate
  2775. * @param y defines the second coordinate
  2776. * @returns the current updated Vector2
  2777. */
  2778. copyFromFloats(x: number, y: number): Vector2;
  2779. /**
  2780. * Sets the Vector2 coordinates with the given floats
  2781. * @param x defines the first coordinate
  2782. * @param y defines the second coordinate
  2783. * @returns the current updated Vector2
  2784. */
  2785. set(x: number, y: number): Vector2;
  2786. /**
  2787. * Add another vector with the current one
  2788. * @param otherVector defines the other vector
  2789. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2790. */
  2791. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2792. /**
  2793. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2794. * @param otherVector defines the other vector
  2795. * @param result defines the target vector
  2796. * @returns the unmodified current Vector2
  2797. */
  2798. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2799. /**
  2800. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2801. * @param otherVector defines the other vector
  2802. * @returns the current updated Vector2
  2803. */
  2804. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2805. /**
  2806. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2807. * @param otherVector defines the other vector
  2808. * @returns a new Vector2
  2809. */
  2810. addVector3(otherVector: Vector3): Vector2;
  2811. /**
  2812. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2813. * @param otherVector defines the other vector
  2814. * @returns a new Vector2
  2815. */
  2816. subtract(otherVector: Vector2): Vector2;
  2817. /**
  2818. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2819. * @param otherVector defines the other vector
  2820. * @param result defines the target vector
  2821. * @returns the unmodified current Vector2
  2822. */
  2823. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2824. /**
  2825. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2826. * @param otherVector defines the other vector
  2827. * @returns the current updated Vector2
  2828. */
  2829. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2830. /**
  2831. * Multiplies in place the current Vector2 coordinates by the given ones
  2832. * @param otherVector defines the other vector
  2833. * @returns the current updated Vector2
  2834. */
  2835. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2836. /**
  2837. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2838. * @param otherVector defines the other vector
  2839. * @returns a new Vector2
  2840. */
  2841. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2842. /**
  2843. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2844. * @param otherVector defines the other vector
  2845. * @param result defines the target vector
  2846. * @returns the unmodified current Vector2
  2847. */
  2848. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2849. /**
  2850. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2851. * @param x defines the first coordinate
  2852. * @param y defines the second coordinate
  2853. * @returns a new Vector2
  2854. */
  2855. multiplyByFloats(x: number, y: number): Vector2;
  2856. /**
  2857. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2858. * @param otherVector defines the other vector
  2859. * @returns a new Vector2
  2860. */
  2861. divide(otherVector: Vector2): Vector2;
  2862. /**
  2863. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2864. * @param otherVector defines the other vector
  2865. * @param result defines the target vector
  2866. * @returns the unmodified current Vector2
  2867. */
  2868. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2869. /**
  2870. * Divides the current Vector2 coordinates by the given ones
  2871. * @param otherVector defines the other vector
  2872. * @returns the current updated Vector2
  2873. */
  2874. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2875. /**
  2876. * Gets a new Vector2 with current Vector2 negated coordinates
  2877. * @returns a new Vector2
  2878. */
  2879. negate(): Vector2;
  2880. /**
  2881. * Negate this vector in place
  2882. * @returns this
  2883. */
  2884. negateInPlace(): Vector2;
  2885. /**
  2886. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2887. * @param result defines the Vector3 object where to store the result
  2888. * @returns the current Vector2
  2889. */
  2890. negateToRef(result: Vector2): Vector2;
  2891. /**
  2892. * Multiply the Vector2 coordinates by scale
  2893. * @param scale defines the scaling factor
  2894. * @returns the current updated Vector2
  2895. */
  2896. scaleInPlace(scale: number): Vector2;
  2897. /**
  2898. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2899. * @param scale defines the scaling factor
  2900. * @returns a new Vector2
  2901. */
  2902. scale(scale: number): Vector2;
  2903. /**
  2904. * Scale the current Vector2 values by a factor to a given Vector2
  2905. * @param scale defines the scale factor
  2906. * @param result defines the Vector2 object where to store the result
  2907. * @returns the unmodified current Vector2
  2908. */
  2909. scaleToRef(scale: number, result: Vector2): Vector2;
  2910. /**
  2911. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2912. * @param scale defines the scale factor
  2913. * @param result defines the Vector2 object where to store the result
  2914. * @returns the unmodified current Vector2
  2915. */
  2916. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2917. /**
  2918. * Gets a boolean if two vectors are equals
  2919. * @param otherVector defines the other vector
  2920. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2921. */
  2922. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2923. /**
  2924. * Gets a boolean if two vectors are equals (using an epsilon value)
  2925. * @param otherVector defines the other vector
  2926. * @param epsilon defines the minimal distance to consider equality
  2927. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2928. */
  2929. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2930. /**
  2931. * Gets a new Vector2 from current Vector2 floored values
  2932. * @returns a new Vector2
  2933. */
  2934. floor(): Vector2;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. fract(): Vector2;
  2940. /**
  2941. * Gets the length of the vector
  2942. * @returns the vector length (float)
  2943. */
  2944. length(): number;
  2945. /**
  2946. * Gets the vector squared length
  2947. * @returns the vector squared length (float)
  2948. */
  2949. lengthSquared(): number;
  2950. /**
  2951. * Normalize the vector
  2952. * @returns the current updated Vector2
  2953. */
  2954. normalize(): Vector2;
  2955. /**
  2956. * Gets a new Vector2 copied from the Vector2
  2957. * @returns a new Vector2
  2958. */
  2959. clone(): Vector2;
  2960. /**
  2961. * Gets a new Vector2(0, 0)
  2962. * @returns a new Vector2
  2963. */
  2964. static Zero(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(1, 1)
  2967. * @returns a new Vector2
  2968. */
  2969. static One(): Vector2;
  2970. /**
  2971. * Gets a new Vector2 set from the given index element of the given array
  2972. * @param array defines the data source
  2973. * @param offset defines the offset in the data source
  2974. * @returns a new Vector2
  2975. */
  2976. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2977. /**
  2978. * Sets "result" from the given index element of the given array
  2979. * @param array defines the data source
  2980. * @param offset defines the offset in the data source
  2981. * @param result defines the target vector
  2982. */
  2983. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2984. /**
  2985. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2986. * @param value1 defines 1st point of control
  2987. * @param value2 defines 2nd point of control
  2988. * @param value3 defines 3rd point of control
  2989. * @param value4 defines 4th point of control
  2990. * @param amount defines the interpolation factor
  2991. * @returns a new Vector2
  2992. */
  2993. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2994. /**
  2995. * 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".
  2996. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2997. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2998. * @param value defines the value to clamp
  2999. * @param min defines the lower limit
  3000. * @param max defines the upper limit
  3001. * @returns a new Vector2
  3002. */
  3003. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3004. /**
  3005. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3006. * @param value1 defines the 1st control point
  3007. * @param tangent1 defines the outgoing tangent
  3008. * @param value2 defines the 2nd control point
  3009. * @param tangent2 defines the incoming tangent
  3010. * @param amount defines the interpolation factor
  3011. * @returns a new Vector2
  3012. */
  3013. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3014. /**
  3015. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3016. * @param start defines the start vector
  3017. * @param end defines the end vector
  3018. * @param amount defines the interpolation factor
  3019. * @returns a new Vector2
  3020. */
  3021. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3022. /**
  3023. * Gets the dot product of the vector "left" and the vector "right"
  3024. * @param left defines first vector
  3025. * @param right defines second vector
  3026. * @returns the dot product (float)
  3027. */
  3028. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3029. /**
  3030. * Returns a new Vector2 equal to the normalized given vector
  3031. * @param vector defines the vector to normalize
  3032. * @returns a new Vector2
  3033. */
  3034. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3035. /**
  3036. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3037. * @param left defines 1st vector
  3038. * @param right defines 2nd vector
  3039. * @returns a new Vector2
  3040. */
  3041. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3042. /**
  3043. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3044. * @param left defines 1st vector
  3045. * @param right defines 2nd vector
  3046. * @returns a new Vector2
  3047. */
  3048. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3049. /**
  3050. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3051. * @param vector defines the vector to transform
  3052. * @param transformation defines the matrix to apply
  3053. * @returns a new Vector2
  3054. */
  3055. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3056. /**
  3057. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3058. * @param vector defines the vector to transform
  3059. * @param transformation defines the matrix to apply
  3060. * @param result defines the target vector
  3061. */
  3062. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3063. /**
  3064. * Determines if a given vector is included in a triangle
  3065. * @param p defines the vector to test
  3066. * @param p0 defines 1st triangle point
  3067. * @param p1 defines 2nd triangle point
  3068. * @param p2 defines 3rd triangle point
  3069. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3070. */
  3071. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3072. /**
  3073. * Gets the distance between the vectors "value1" and "value2"
  3074. * @param value1 defines first vector
  3075. * @param value2 defines second vector
  3076. * @returns the distance between vectors
  3077. */
  3078. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3079. /**
  3080. * Returns the squared distance between the vectors "value1" and "value2"
  3081. * @param value1 defines first vector
  3082. * @param value2 defines second vector
  3083. * @returns the squared distance between vectors
  3084. */
  3085. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3086. /**
  3087. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3088. * @param value1 defines first vector
  3089. * @param value2 defines second vector
  3090. * @returns a new Vector2
  3091. */
  3092. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3093. /**
  3094. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3095. * @param value1 defines first vector
  3096. * @param value2 defines second vector
  3097. * @param ref defines third vector
  3098. * @returns ref
  3099. */
  3100. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3101. /**
  3102. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3103. * @param p defines the middle point
  3104. * @param segA defines one point of the segment
  3105. * @param segB defines the other point of the segment
  3106. * @returns the shortest distance
  3107. */
  3108. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3109. }
  3110. /**
  3111. * Class used to store (x,y,z) vector representation
  3112. * A Vector3 is the main object used in 3D geometry
  3113. * It can represent etiher the coordinates of a point the space, either a direction
  3114. * Reminder: js uses a left handed forward facing system
  3115. */
  3116. export class Vector3 {
  3117. private static _UpReadOnly;
  3118. private static _ZeroReadOnly;
  3119. /** @hidden */
  3120. _x: number;
  3121. /** @hidden */
  3122. _y: number;
  3123. /** @hidden */
  3124. _z: number;
  3125. /** @hidden */
  3126. _isDirty: boolean;
  3127. /** Gets or sets the x coordinate */
  3128. get x(): number;
  3129. set x(value: number);
  3130. /** Gets or sets the y coordinate */
  3131. get y(): number;
  3132. set y(value: number);
  3133. /** Gets or sets the z coordinate */
  3134. get z(): number;
  3135. set z(value: number);
  3136. /**
  3137. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3138. * @param x defines the first coordinates (on X axis)
  3139. * @param y defines the second coordinates (on Y axis)
  3140. * @param z defines the third coordinates (on Z axis)
  3141. */
  3142. constructor(x?: number, y?: number, z?: number);
  3143. /**
  3144. * Creates a string representation of the Vector3
  3145. * @returns a string with the Vector3 coordinates.
  3146. */
  3147. toString(): string;
  3148. /**
  3149. * Gets the class name
  3150. * @returns the string "Vector3"
  3151. */
  3152. getClassName(): string;
  3153. /**
  3154. * Creates the Vector3 hash code
  3155. * @returns a number which tends to be unique between Vector3 instances
  3156. */
  3157. getHashCode(): number;
  3158. /**
  3159. * Creates an array containing three elements : the coordinates of the Vector3
  3160. * @returns a new array of numbers
  3161. */
  3162. asArray(): number[];
  3163. /**
  3164. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3165. * @param array defines the destination array
  3166. * @param index defines the offset in the destination array
  3167. * @returns the current Vector3
  3168. */
  3169. toArray(array: FloatArray, index?: number): Vector3;
  3170. /**
  3171. * Update the current vector from an array
  3172. * @param array defines the destination array
  3173. * @param index defines the offset in the destination array
  3174. * @returns the current Vector3
  3175. */
  3176. fromArray(array: FloatArray, index?: number): Vector3;
  3177. /**
  3178. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3179. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3180. */
  3181. toQuaternion(): Quaternion;
  3182. /**
  3183. * Adds the given vector to the current Vector3
  3184. * @param otherVector defines the second operand
  3185. * @returns the current updated Vector3
  3186. */
  3187. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * Adds the given coordinates to the current Vector3
  3190. * @param x defines the x coordinate of the operand
  3191. * @param y defines the y coordinate of the operand
  3192. * @param z defines the z coordinate of the operand
  3193. * @returns the current updated Vector3
  3194. */
  3195. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3196. /**
  3197. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3198. * @param otherVector defines the second operand
  3199. * @returns the resulting Vector3
  3200. */
  3201. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3204. * @param otherVector defines the second operand
  3205. * @param result defines the Vector3 object where to store the result
  3206. * @returns the current Vector3
  3207. */
  3208. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3209. /**
  3210. * Subtract the given vector from the current Vector3
  3211. * @param otherVector defines the second operand
  3212. * @returns the current updated Vector3
  3213. */
  3214. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3215. /**
  3216. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3217. * @param otherVector defines the second operand
  3218. * @returns the resulting Vector3
  3219. */
  3220. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3221. /**
  3222. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3223. * @param otherVector defines the second operand
  3224. * @param result defines the Vector3 object where to store the result
  3225. * @returns the current Vector3
  3226. */
  3227. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3228. /**
  3229. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3230. * @param x defines the x coordinate of the operand
  3231. * @param y defines the y coordinate of the operand
  3232. * @param z defines the z coordinate of the operand
  3233. * @returns the resulting Vector3
  3234. */
  3235. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3236. /**
  3237. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3238. * @param x defines the x coordinate of the operand
  3239. * @param y defines the y coordinate of the operand
  3240. * @param z defines the z coordinate of the operand
  3241. * @param result defines the Vector3 object where to store the result
  3242. * @returns the current Vector3
  3243. */
  3244. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3245. /**
  3246. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3247. * @returns a new Vector3
  3248. */
  3249. negate(): Vector3;
  3250. /**
  3251. * Negate this vector in place
  3252. * @returns this
  3253. */
  3254. negateInPlace(): Vector3;
  3255. /**
  3256. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3257. * @param result defines the Vector3 object where to store the result
  3258. * @returns the current Vector3
  3259. */
  3260. negateToRef(result: Vector3): Vector3;
  3261. /**
  3262. * Multiplies the Vector3 coordinates by the float "scale"
  3263. * @param scale defines the multiplier factor
  3264. * @returns the current updated Vector3
  3265. */
  3266. scaleInPlace(scale: number): Vector3;
  3267. /**
  3268. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3269. * @param scale defines the multiplier factor
  3270. * @returns a new Vector3
  3271. */
  3272. scale(scale: number): Vector3;
  3273. /**
  3274. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3275. * @param scale defines the multiplier factor
  3276. * @param result defines the Vector3 object where to store the result
  3277. * @returns the current Vector3
  3278. */
  3279. scaleToRef(scale: number, result: Vector3): Vector3;
  3280. /**
  3281. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3282. * @param scale defines the scale factor
  3283. * @param result defines the Vector3 object where to store the result
  3284. * @returns the unmodified current Vector3
  3285. */
  3286. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3287. /**
  3288. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3289. * @param origin defines the origin of the projection ray
  3290. * @param plane defines the plane to project to
  3291. * @returns the projected vector3
  3292. */
  3293. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3294. /**
  3295. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3296. * @param origin defines the origin of the projection ray
  3297. * @param plane defines the plane to project to
  3298. * @param result defines the Vector3 where to store the result
  3299. */
  3300. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3301. /**
  3302. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3303. * @param otherVector defines the second operand
  3304. * @returns true if both vectors are equals
  3305. */
  3306. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3307. /**
  3308. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3309. * @param otherVector defines the second operand
  3310. * @param epsilon defines the minimal distance to define values as equals
  3311. * @returns true if both vectors are distant less than epsilon
  3312. */
  3313. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3314. /**
  3315. * Returns true if the current Vector3 coordinates equals the given floats
  3316. * @param x defines the x coordinate of the operand
  3317. * @param y defines the y coordinate of the operand
  3318. * @param z defines the z coordinate of the operand
  3319. * @returns true if both vectors are equals
  3320. */
  3321. equalsToFloats(x: number, y: number, z: number): boolean;
  3322. /**
  3323. * Multiplies the current Vector3 coordinates by the given ones
  3324. * @param otherVector defines the second operand
  3325. * @returns the current updated Vector3
  3326. */
  3327. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3328. /**
  3329. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3330. * @param otherVector defines the second operand
  3331. * @returns the new Vector3
  3332. */
  3333. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3334. /**
  3335. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3336. * @param otherVector defines the second operand
  3337. * @param result defines the Vector3 object where to store the result
  3338. * @returns the current Vector3
  3339. */
  3340. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3341. /**
  3342. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3343. * @param x defines the x coordinate of the operand
  3344. * @param y defines the y coordinate of the operand
  3345. * @param z defines the z coordinate of the operand
  3346. * @returns the new Vector3
  3347. */
  3348. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3349. /**
  3350. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3351. * @param otherVector defines the second operand
  3352. * @returns the new Vector3
  3353. */
  3354. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3355. /**
  3356. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3357. * @param otherVector defines the second operand
  3358. * @param result defines the Vector3 object where to store the result
  3359. * @returns the current Vector3
  3360. */
  3361. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3362. /**
  3363. * Divides the current Vector3 coordinates by the given ones.
  3364. * @param otherVector defines the second operand
  3365. * @returns the current updated Vector3
  3366. */
  3367. divideInPlace(otherVector: Vector3): Vector3;
  3368. /**
  3369. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3370. * @param other defines the second operand
  3371. * @returns the current updated Vector3
  3372. */
  3373. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3374. /**
  3375. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3376. * @param other defines the second operand
  3377. * @returns the current updated Vector3
  3378. */
  3379. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3380. /**
  3381. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3382. * @param x defines the x coordinate of the operand
  3383. * @param y defines the y coordinate of the operand
  3384. * @param z defines the z coordinate of the operand
  3385. * @returns the current updated Vector3
  3386. */
  3387. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3388. /**
  3389. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3390. * @param x defines the x coordinate of the operand
  3391. * @param y defines the y coordinate of the operand
  3392. * @param z defines the z coordinate of the operand
  3393. * @returns the current updated Vector3
  3394. */
  3395. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3396. /**
  3397. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3398. * Check if is non uniform within a certain amount of decimal places to account for this
  3399. * @param epsilon the amount the values can differ
  3400. * @returns if the the vector is non uniform to a certain number of decimal places
  3401. */
  3402. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3403. /**
  3404. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3405. */
  3406. get isNonUniform(): boolean;
  3407. /**
  3408. * Gets a new Vector3 from current Vector3 floored values
  3409. * @returns a new Vector3
  3410. */
  3411. floor(): Vector3;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. fract(): Vector3;
  3417. /**
  3418. * Gets the length of the Vector3
  3419. * @returns the length of the Vector3
  3420. */
  3421. length(): number;
  3422. /**
  3423. * Gets the squared length of the Vector3
  3424. * @returns squared length of the Vector3
  3425. */
  3426. lengthSquared(): number;
  3427. /**
  3428. * Normalize the current Vector3.
  3429. * Please note that this is an in place operation.
  3430. * @returns the current updated Vector3
  3431. */
  3432. normalize(): Vector3;
  3433. /**
  3434. * Reorders the x y z properties of the vector in place
  3435. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3436. * @returns the current updated vector
  3437. */
  3438. reorderInPlace(order: string): this;
  3439. /**
  3440. * Rotates the vector around 0,0,0 by a quaternion
  3441. * @param quaternion the rotation quaternion
  3442. * @param result vector to store the result
  3443. * @returns the resulting vector
  3444. */
  3445. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3446. /**
  3447. * Rotates a vector around a given point
  3448. * @param quaternion the rotation quaternion
  3449. * @param point the point to rotate around
  3450. * @param result vector to store the result
  3451. * @returns the resulting vector
  3452. */
  3453. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3454. /**
  3455. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3456. * The cross product is then orthogonal to both current and "other"
  3457. * @param other defines the right operand
  3458. * @returns the cross product
  3459. */
  3460. cross(other: Vector3): Vector3;
  3461. /**
  3462. * Normalize the current Vector3 with the given input length.
  3463. * Please note that this is an in place operation.
  3464. * @param len the length of the vector
  3465. * @returns the current updated Vector3
  3466. */
  3467. normalizeFromLength(len: number): Vector3;
  3468. /**
  3469. * Normalize the current Vector3 to a new vector
  3470. * @returns the new Vector3
  3471. */
  3472. normalizeToNew(): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to the reference
  3475. * @param reference define the Vector3 to update
  3476. * @returns the updated Vector3
  3477. */
  3478. normalizeToRef(reference: Vector3): Vector3;
  3479. /**
  3480. * Creates a new Vector3 copied from the current Vector3
  3481. * @returns the new Vector3
  3482. */
  3483. clone(): Vector3;
  3484. /**
  3485. * Copies the given vector coordinates to the current Vector3 ones
  3486. * @param source defines the source Vector3
  3487. * @returns the current updated Vector3
  3488. */
  3489. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3490. /**
  3491. * Copies the given floats to the current Vector3 coordinates
  3492. * @param x defines the x coordinate of the operand
  3493. * @param y defines the y coordinate of the operand
  3494. * @param z defines the z coordinate of the operand
  3495. * @returns the current updated Vector3
  3496. */
  3497. copyFromFloats(x: number, y: number, z: number): Vector3;
  3498. /**
  3499. * Copies the given floats to the current Vector3 coordinates
  3500. * @param x defines the x coordinate of the operand
  3501. * @param y defines the y coordinate of the operand
  3502. * @param z defines the z coordinate of the operand
  3503. * @returns the current updated Vector3
  3504. */
  3505. set(x: number, y: number, z: number): Vector3;
  3506. /**
  3507. * Copies the given float to the current Vector3 coordinates
  3508. * @param v defines the x, y and z coordinates of the operand
  3509. * @returns the current updated Vector3
  3510. */
  3511. setAll(v: number): Vector3;
  3512. /**
  3513. * Get the clip factor between two vectors
  3514. * @param vector0 defines the first operand
  3515. * @param vector1 defines the second operand
  3516. * @param axis defines the axis to use
  3517. * @param size defines the size along the axis
  3518. * @returns the clip factor
  3519. */
  3520. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3521. /**
  3522. * Get angle between two vectors
  3523. * @param vector0 angle between vector0 and vector1
  3524. * @param vector1 angle between vector0 and vector1
  3525. * @param normal direction of the normal
  3526. * @return the angle between vector0 and vector1
  3527. */
  3528. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3529. /**
  3530. * Returns a new Vector3 set from the index "offset" of the given array
  3531. * @param array defines the source array
  3532. * @param offset defines the offset in the source array
  3533. * @returns the new Vector3
  3534. */
  3535. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3536. /**
  3537. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3538. * @param array defines the source array
  3539. * @param offset defines the offset in the source array
  3540. * @returns the new Vector3
  3541. * @deprecated Please use FromArray instead.
  3542. */
  3543. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3544. /**
  3545. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3546. * @param array defines the source array
  3547. * @param offset defines the offset in the source array
  3548. * @param result defines the Vector3 where to store the result
  3549. */
  3550. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3551. /**
  3552. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3553. * @param array defines the source array
  3554. * @param offset defines the offset in the source array
  3555. * @param result defines the Vector3 where to store the result
  3556. * @deprecated Please use FromArrayToRef instead.
  3557. */
  3558. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3559. /**
  3560. * Sets the given vector "result" with the given floats.
  3561. * @param x defines the x coordinate of the source
  3562. * @param y defines the y coordinate of the source
  3563. * @param z defines the z coordinate of the source
  3564. * @param result defines the Vector3 where to store the result
  3565. */
  3566. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3567. /**
  3568. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3569. * @returns a new empty Vector3
  3570. */
  3571. static Zero(): Vector3;
  3572. /**
  3573. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3574. * @returns a new unit Vector3
  3575. */
  3576. static One(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3579. * @returns a new up Vector3
  3580. */
  3581. static Up(): Vector3;
  3582. /**
  3583. * Gets a up Vector3 that must not be updated
  3584. */
  3585. static get UpReadOnly(): DeepImmutable<Vector3>;
  3586. /**
  3587. * Gets a zero Vector3 that must not be updated
  3588. */
  3589. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3590. /**
  3591. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3592. * @returns a new down Vector3
  3593. */
  3594. static Down(): Vector3;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3597. * @param rightHandedSystem is the scene right-handed (negative z)
  3598. * @returns a new forward Vector3
  3599. */
  3600. static Forward(rightHandedSystem?: boolean): Vector3;
  3601. /**
  3602. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3603. * @param rightHandedSystem is the scene right-handed (negative-z)
  3604. * @returns a new forward Vector3
  3605. */
  3606. static Backward(rightHandedSystem?: boolean): Vector3;
  3607. /**
  3608. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3609. * @returns a new right Vector3
  3610. */
  3611. static Right(): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3614. * @returns a new left Vector3
  3615. */
  3616. static Left(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3619. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3620. * @param vector defines the Vector3 to transform
  3621. * @param transformation defines the transformation matrix
  3622. * @returns the transformed Vector3
  3623. */
  3624. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3625. /**
  3626. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3627. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3628. * @param vector defines the Vector3 to transform
  3629. * @param transformation defines the transformation matrix
  3630. * @param result defines the Vector3 where to store the result
  3631. */
  3632. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3633. /**
  3634. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3635. * This method computes tranformed coordinates only, not transformed direction vectors
  3636. * @param x define the x coordinate of the source vector
  3637. * @param y define the y coordinate of the source vector
  3638. * @param z define the z coordinate of the source vector
  3639. * @param transformation defines the transformation matrix
  3640. * @param result defines the Vector3 where to store the result
  3641. */
  3642. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3643. /**
  3644. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3645. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3646. * @param vector defines the Vector3 to transform
  3647. * @param transformation defines the transformation matrix
  3648. * @returns the new Vector3
  3649. */
  3650. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3651. /**
  3652. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3653. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3654. * @param vector defines the Vector3 to transform
  3655. * @param transformation defines the transformation matrix
  3656. * @param result defines the Vector3 where to store the result
  3657. */
  3658. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3659. /**
  3660. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3661. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3662. * @param x define the x coordinate of the source vector
  3663. * @param y define the y coordinate of the source vector
  3664. * @param z define the z coordinate of the source vector
  3665. * @param transformation defines the transformation matrix
  3666. * @param result defines the Vector3 where to store the result
  3667. */
  3668. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3669. /**
  3670. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3671. * @param value1 defines the first control point
  3672. * @param value2 defines the second control point
  3673. * @param value3 defines the third control point
  3674. * @param value4 defines the fourth control point
  3675. * @param amount defines the amount on the spline to use
  3676. * @returns the new Vector3
  3677. */
  3678. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3679. /**
  3680. * 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"
  3681. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3682. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3683. * @param value defines the current value
  3684. * @param min defines the lower range value
  3685. * @param max defines the upper range value
  3686. * @returns the new Vector3
  3687. */
  3688. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3689. /**
  3690. * 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"
  3691. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3692. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3693. * @param value defines the current value
  3694. * @param min defines the lower range value
  3695. * @param max defines the upper range value
  3696. * @param result defines the Vector3 where to store the result
  3697. */
  3698. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3699. /**
  3700. * Checks if a given vector is inside a specific range
  3701. * @param v defines the vector to test
  3702. * @param min defines the minimum range
  3703. * @param max defines the maximum range
  3704. */
  3705. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3706. /**
  3707. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3708. * @param value1 defines the first control point
  3709. * @param tangent1 defines the first tangent vector
  3710. * @param value2 defines the second control point
  3711. * @param tangent2 defines the second tangent vector
  3712. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3713. * @returns the new Vector3
  3714. */
  3715. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3716. /**
  3717. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3718. * @param start defines the start value
  3719. * @param end defines the end value
  3720. * @param amount max defines amount between both (between 0 and 1)
  3721. * @returns the new Vector3
  3722. */
  3723. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3724. /**
  3725. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3726. * @param start defines the start value
  3727. * @param end defines the end value
  3728. * @param amount max defines amount between both (between 0 and 1)
  3729. * @param result defines the Vector3 where to store the result
  3730. */
  3731. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3732. /**
  3733. * Returns the dot product (float) between the vectors "left" and "right"
  3734. * @param left defines the left operand
  3735. * @param right defines the right operand
  3736. * @returns the dot product
  3737. */
  3738. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3739. /**
  3740. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3741. * The cross product is then orthogonal to both "left" and "right"
  3742. * @param left defines the left operand
  3743. * @param right defines the right operand
  3744. * @returns the cross product
  3745. */
  3746. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3747. /**
  3748. * Sets the given vector "result" with the cross product of "left" and "right"
  3749. * The cross product is then orthogonal to both "left" and "right"
  3750. * @param left defines the left operand
  3751. * @param right defines the right operand
  3752. * @param result defines the Vector3 where to store the result
  3753. */
  3754. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3755. /**
  3756. * Returns a new Vector3 as the normalization of the given vector
  3757. * @param vector defines the Vector3 to normalize
  3758. * @returns the new Vector3
  3759. */
  3760. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3761. /**
  3762. * Sets the given vector "result" with the normalization of the given first vector
  3763. * @param vector defines the Vector3 to normalize
  3764. * @param result defines the Vector3 where to store the result
  3765. */
  3766. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3767. /**
  3768. * Project a Vector3 onto screen space
  3769. * @param vector defines the Vector3 to project
  3770. * @param world defines the world matrix to use
  3771. * @param transform defines the transform (view x projection) matrix to use
  3772. * @param viewport defines the screen viewport to use
  3773. * @returns the new Vector3
  3774. */
  3775. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3776. /**
  3777. * Project a Vector3 onto screen space to reference
  3778. * @param vector defines the Vector3 to project
  3779. * @param world defines the world matrix to use
  3780. * @param transform defines the transform (view x projection) matrix to use
  3781. * @param viewport defines the screen viewport to use
  3782. * @param result the vector in which the screen space will be stored
  3783. * @returns the new Vector3
  3784. */
  3785. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3786. /** @hidden */
  3787. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3788. /**
  3789. * Unproject from screen space to object space
  3790. * @param source defines the screen space Vector3 to use
  3791. * @param viewportWidth defines the current width of the viewport
  3792. * @param viewportHeight defines the current height of the viewport
  3793. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3794. * @param transform defines the transform (view x projection) matrix to use
  3795. * @returns the new Vector3
  3796. */
  3797. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3798. /**
  3799. * Unproject from screen space to object space
  3800. * @param source defines the screen space Vector3 to use
  3801. * @param viewportWidth defines the current width of the viewport
  3802. * @param viewportHeight defines the current height of the viewport
  3803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3804. * @param view defines the view matrix to use
  3805. * @param projection defines the projection matrix to use
  3806. * @returns the new Vector3
  3807. */
  3808. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3809. /**
  3810. * Unproject from screen space to object space
  3811. * @param source defines the screen space Vector3 to use
  3812. * @param viewportWidth defines the current width of the viewport
  3813. * @param viewportHeight defines the current height of the viewport
  3814. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3815. * @param view defines the view matrix to use
  3816. * @param projection defines the projection matrix to use
  3817. * @param result defines the Vector3 where to store the result
  3818. */
  3819. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3820. /**
  3821. * Unproject from screen space to object space
  3822. * @param sourceX defines the screen space x coordinate to use
  3823. * @param sourceY defines the screen space y coordinate to use
  3824. * @param sourceZ defines the screen space z coordinate to use
  3825. * @param viewportWidth defines the current width of the viewport
  3826. * @param viewportHeight defines the current height of the viewport
  3827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3828. * @param view defines the view matrix to use
  3829. * @param projection defines the projection matrix to use
  3830. * @param result defines the Vector3 where to store the result
  3831. */
  3832. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3833. /**
  3834. * Gets the minimal coordinate values between two Vector3
  3835. * @param left defines the first operand
  3836. * @param right defines the second operand
  3837. * @returns the new Vector3
  3838. */
  3839. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3840. /**
  3841. * Gets the maximal coordinate values between two Vector3
  3842. * @param left defines the first operand
  3843. * @param right defines the second operand
  3844. * @returns the new Vector3
  3845. */
  3846. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3847. /**
  3848. * Returns the distance between the vectors "value1" and "value2"
  3849. * @param value1 defines the first operand
  3850. * @param value2 defines the second operand
  3851. * @returns the distance
  3852. */
  3853. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3854. /**
  3855. * Returns the squared distance between the vectors "value1" and "value2"
  3856. * @param value1 defines the first operand
  3857. * @param value2 defines the second operand
  3858. * @returns the squared distance
  3859. */
  3860. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3861. /**
  3862. * Returns a new Vector3 located at the center between "value1" and "value2"
  3863. * @param value1 defines the first operand
  3864. * @param value2 defines the second operand
  3865. * @returns the new Vector3
  3866. */
  3867. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3868. /**
  3869. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3870. * @param value1 defines first vector
  3871. * @param value2 defines second vector
  3872. * @param ref defines third vector
  3873. * @returns ref
  3874. */
  3875. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3876. /**
  3877. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3878. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3879. * to something in order to rotate it from its local system to the given target system
  3880. * Note: axis1, axis2 and axis3 are normalized during this operation
  3881. * @param axis1 defines the first axis
  3882. * @param axis2 defines the second axis
  3883. * @param axis3 defines the third axis
  3884. * @returns a new Vector3
  3885. */
  3886. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3887. /**
  3888. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3889. * @param axis1 defines the first axis
  3890. * @param axis2 defines the second axis
  3891. * @param axis3 defines the third axis
  3892. * @param ref defines the Vector3 where to store the result
  3893. */
  3894. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3895. }
  3896. /**
  3897. * Vector4 class created for EulerAngle class conversion to Quaternion
  3898. */
  3899. export class Vector4 {
  3900. /** x value of the vector */
  3901. x: number;
  3902. /** y value of the vector */
  3903. y: number;
  3904. /** z value of the vector */
  3905. z: number;
  3906. /** w value of the vector */
  3907. w: number;
  3908. /**
  3909. * Creates a Vector4 object from the given floats.
  3910. * @param x x value of the vector
  3911. * @param y y value of the vector
  3912. * @param z z value of the vector
  3913. * @param w w value of the vector
  3914. */
  3915. constructor(
  3916. /** x value of the vector */
  3917. x: number,
  3918. /** y value of the vector */
  3919. y: number,
  3920. /** z value of the vector */
  3921. z: number,
  3922. /** w value of the vector */
  3923. w: number);
  3924. /**
  3925. * Returns the string with the Vector4 coordinates.
  3926. * @returns a string containing all the vector values
  3927. */
  3928. toString(): string;
  3929. /**
  3930. * Returns the string "Vector4".
  3931. * @returns "Vector4"
  3932. */
  3933. getClassName(): string;
  3934. /**
  3935. * Returns the Vector4 hash code.
  3936. * @returns a unique hash code
  3937. */
  3938. getHashCode(): number;
  3939. /**
  3940. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3941. * @returns the resulting array
  3942. */
  3943. asArray(): number[];
  3944. /**
  3945. * Populates the given array from the given index with the Vector4 coordinates.
  3946. * @param array array to populate
  3947. * @param index index of the array to start at (default: 0)
  3948. * @returns the Vector4.
  3949. */
  3950. toArray(array: FloatArray, index?: number): Vector4;
  3951. /**
  3952. * Update the current vector from an array
  3953. * @param array defines the destination array
  3954. * @param index defines the offset in the destination array
  3955. * @returns the current Vector3
  3956. */
  3957. fromArray(array: FloatArray, index?: number): Vector4;
  3958. /**
  3959. * Adds the given vector to the current Vector4.
  3960. * @param otherVector the vector to add
  3961. * @returns the updated Vector4.
  3962. */
  3963. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3964. /**
  3965. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3966. * @param otherVector the vector to add
  3967. * @returns the resulting vector
  3968. */
  3969. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3970. /**
  3971. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3972. * @param otherVector the vector to add
  3973. * @param result the vector to store the result
  3974. * @returns the current Vector4.
  3975. */
  3976. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3977. /**
  3978. * Subtract in place the given vector from the current Vector4.
  3979. * @param otherVector the vector to subtract
  3980. * @returns the updated Vector4.
  3981. */
  3982. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3983. /**
  3984. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3985. * @param otherVector the vector to add
  3986. * @returns the new vector with the result
  3987. */
  3988. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3989. /**
  3990. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3991. * @param otherVector the vector to subtract
  3992. * @param result the vector to store the result
  3993. * @returns the current Vector4.
  3994. */
  3995. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3996. /**
  3997. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3998. */
  3999. /**
  4000. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4001. * @param x value to subtract
  4002. * @param y value to subtract
  4003. * @param z value to subtract
  4004. * @param w value to subtract
  4005. * @returns new vector containing the result
  4006. */
  4007. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4008. /**
  4009. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4010. * @param x value to subtract
  4011. * @param y value to subtract
  4012. * @param z value to subtract
  4013. * @param w value to subtract
  4014. * @param result the vector to store the result in
  4015. * @returns the current Vector4.
  4016. */
  4017. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4018. /**
  4019. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4020. * @returns a new vector with the negated values
  4021. */
  4022. negate(): Vector4;
  4023. /**
  4024. * Negate this vector in place
  4025. * @returns this
  4026. */
  4027. negateInPlace(): Vector4;
  4028. /**
  4029. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4030. * @param result defines the Vector3 object where to store the result
  4031. * @returns the current Vector4
  4032. */
  4033. negateToRef(result: Vector4): Vector4;
  4034. /**
  4035. * Multiplies the current Vector4 coordinates by scale (float).
  4036. * @param scale the number to scale with
  4037. * @returns the updated Vector4.
  4038. */
  4039. scaleInPlace(scale: number): Vector4;
  4040. /**
  4041. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4042. * @param scale the number to scale with
  4043. * @returns a new vector with the result
  4044. */
  4045. scale(scale: number): Vector4;
  4046. /**
  4047. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4048. * @param scale the number to scale with
  4049. * @param result a vector to store the result in
  4050. * @returns the current Vector4.
  4051. */
  4052. scaleToRef(scale: number, result: Vector4): Vector4;
  4053. /**
  4054. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4055. * @param scale defines the scale factor
  4056. * @param result defines the Vector4 object where to store the result
  4057. * @returns the unmodified current Vector4
  4058. */
  4059. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4060. /**
  4061. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4062. * @param otherVector the vector to compare against
  4063. * @returns true if they are equal
  4064. */
  4065. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4066. /**
  4067. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4068. * @param otherVector vector to compare against
  4069. * @param epsilon (Default: very small number)
  4070. * @returns true if they are equal
  4071. */
  4072. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4073. /**
  4074. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4075. * @param x x value to compare against
  4076. * @param y y value to compare against
  4077. * @param z z value to compare against
  4078. * @param w w value to compare against
  4079. * @returns true if equal
  4080. */
  4081. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4082. /**
  4083. * Multiplies in place the current Vector4 by the given one.
  4084. * @param otherVector vector to multiple with
  4085. * @returns the updated Vector4.
  4086. */
  4087. multiplyInPlace(otherVector: Vector4): Vector4;
  4088. /**
  4089. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4090. * @param otherVector vector to multiple with
  4091. * @returns resulting new vector
  4092. */
  4093. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4094. /**
  4095. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4096. * @param otherVector vector to multiple with
  4097. * @param result vector to store the result
  4098. * @returns the current Vector4.
  4099. */
  4100. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4101. /**
  4102. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4103. * @param x x value multiply with
  4104. * @param y y value multiply with
  4105. * @param z z value multiply with
  4106. * @param w w value multiply with
  4107. * @returns resulting new vector
  4108. */
  4109. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4110. /**
  4111. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4112. * @param otherVector vector to devide with
  4113. * @returns resulting new vector
  4114. */
  4115. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4116. /**
  4117. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4118. * @param otherVector vector to devide with
  4119. * @param result vector to store the result
  4120. * @returns the current Vector4.
  4121. */
  4122. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4123. /**
  4124. * Divides the current Vector3 coordinates by the given ones.
  4125. * @param otherVector vector to devide with
  4126. * @returns the updated Vector3.
  4127. */
  4128. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4129. /**
  4130. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4131. * @param other defines the second operand
  4132. * @returns the current updated Vector4
  4133. */
  4134. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4135. /**
  4136. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4137. * @param other defines the second operand
  4138. * @returns the current updated Vector4
  4139. */
  4140. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4141. /**
  4142. * Gets a new Vector4 from current Vector4 floored values
  4143. * @returns a new Vector4
  4144. */
  4145. floor(): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector3 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. fract(): Vector4;
  4151. /**
  4152. * Returns the Vector4 length (float).
  4153. * @returns the length
  4154. */
  4155. length(): number;
  4156. /**
  4157. * Returns the Vector4 squared length (float).
  4158. * @returns the length squared
  4159. */
  4160. lengthSquared(): number;
  4161. /**
  4162. * Normalizes in place the Vector4.
  4163. * @returns the updated Vector4.
  4164. */
  4165. normalize(): Vector4;
  4166. /**
  4167. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4168. * @returns this converted to a new vector3
  4169. */
  4170. toVector3(): Vector3;
  4171. /**
  4172. * Returns a new Vector4 copied from the current one.
  4173. * @returns the new cloned vector
  4174. */
  4175. clone(): Vector4;
  4176. /**
  4177. * Updates the current Vector4 with the given one coordinates.
  4178. * @param source the source vector to copy from
  4179. * @returns the updated Vector4.
  4180. */
  4181. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4182. /**
  4183. * Updates the current Vector4 coordinates with the given floats.
  4184. * @param x float to copy from
  4185. * @param y float to copy from
  4186. * @param z float to copy from
  4187. * @param w float to copy from
  4188. * @returns the updated Vector4.
  4189. */
  4190. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4191. /**
  4192. * Updates the current Vector4 coordinates with the given floats.
  4193. * @param x float to set from
  4194. * @param y float to set from
  4195. * @param z float to set from
  4196. * @param w float to set from
  4197. * @returns the updated Vector4.
  4198. */
  4199. set(x: number, y: number, z: number, w: number): Vector4;
  4200. /**
  4201. * Copies the given float to the current Vector3 coordinates
  4202. * @param v defines the x, y, z and w coordinates of the operand
  4203. * @returns the current updated Vector3
  4204. */
  4205. setAll(v: number): Vector4;
  4206. /**
  4207. * Returns a new Vector4 set from the starting index of the given array.
  4208. * @param array the array to pull values from
  4209. * @param offset the offset into the array to start at
  4210. * @returns the new vector
  4211. */
  4212. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4213. /**
  4214. * Updates the given vector "result" from the starting index of the given array.
  4215. * @param array the array to pull values from
  4216. * @param offset the offset into the array to start at
  4217. * @param result the vector to store the result in
  4218. */
  4219. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4220. /**
  4221. * Updates the given vector "result" from the starting index of the given Float32Array.
  4222. * @param array the array to pull values from
  4223. * @param offset the offset into the array to start at
  4224. * @param result the vector to store the result in
  4225. */
  4226. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4227. /**
  4228. * Updates the given vector "result" coordinates from the given floats.
  4229. * @param x float to set from
  4230. * @param y float to set from
  4231. * @param z float to set from
  4232. * @param w float to set from
  4233. * @param result the vector to the floats in
  4234. */
  4235. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4236. /**
  4237. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4238. * @returns the new vector
  4239. */
  4240. static Zero(): Vector4;
  4241. /**
  4242. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4243. * @returns the new vector
  4244. */
  4245. static One(): Vector4;
  4246. /**
  4247. * Returns a new normalized Vector4 from the given one.
  4248. * @param vector the vector to normalize
  4249. * @returns the vector
  4250. */
  4251. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4252. /**
  4253. * Updates the given vector "result" from the normalization of the given one.
  4254. * @param vector the vector to normalize
  4255. * @param result the vector to store the result in
  4256. */
  4257. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4258. /**
  4259. * Returns a vector with the minimum values from the left and right vectors
  4260. * @param left left vector to minimize
  4261. * @param right right vector to minimize
  4262. * @returns a new vector with the minimum of the left and right vector values
  4263. */
  4264. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4265. /**
  4266. * Returns a vector with the maximum values from the left and right vectors
  4267. * @param left left vector to maximize
  4268. * @param right right vector to maximize
  4269. * @returns a new vector with the maximum of the left and right vector values
  4270. */
  4271. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4272. /**
  4273. * Returns the distance (float) between the vectors "value1" and "value2".
  4274. * @param value1 value to calulate the distance between
  4275. * @param value2 value to calulate the distance between
  4276. * @return the distance between the two vectors
  4277. */
  4278. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4279. /**
  4280. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4281. * @param value1 value to calulate the distance between
  4282. * @param value2 value to calulate the distance between
  4283. * @return the distance between the two vectors squared
  4284. */
  4285. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4286. /**
  4287. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4288. * @param value1 value to calulate the center between
  4289. * @param value2 value to calulate the center between
  4290. * @return the center between the two vectors
  4291. */
  4292. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4293. /**
  4294. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4295. * @param value1 defines first vector
  4296. * @param value2 defines second vector
  4297. * @param ref defines third vector
  4298. * @returns ref
  4299. */
  4300. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4301. /**
  4302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4303. * This methods computes transformed normalized direction vectors only.
  4304. * @param vector the vector to transform
  4305. * @param transformation the transformation matrix to apply
  4306. * @returns the new vector
  4307. */
  4308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4309. /**
  4310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4311. * This methods computes transformed normalized direction vectors only.
  4312. * @param vector the vector to transform
  4313. * @param transformation the transformation matrix to apply
  4314. * @param result the vector to store the result in
  4315. */
  4316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4317. /**
  4318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4319. * This methods computes transformed normalized direction vectors only.
  4320. * @param x value to transform
  4321. * @param y value to transform
  4322. * @param z value to transform
  4323. * @param w value to transform
  4324. * @param transformation the transformation matrix to apply
  4325. * @param result the vector to store the results in
  4326. */
  4327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4328. /**
  4329. * Creates a new Vector4 from a Vector3
  4330. * @param source defines the source data
  4331. * @param w defines the 4th component (default is 0)
  4332. * @returns a new Vector4
  4333. */
  4334. static FromVector3(source: Vector3, w?: number): Vector4;
  4335. }
  4336. /**
  4337. * Class used to store quaternion data
  4338. * @see https://en.wikipedia.org/wiki/Quaternion
  4339. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4340. */
  4341. export class Quaternion {
  4342. /** @hidden */
  4343. _x: number;
  4344. /** @hidden */
  4345. _y: number;
  4346. /** @hidden */
  4347. _z: number;
  4348. /** @hidden */
  4349. _w: number;
  4350. /** @hidden */
  4351. _isDirty: boolean;
  4352. /** Gets or sets the x coordinate */
  4353. get x(): number;
  4354. set x(value: number);
  4355. /** Gets or sets the y coordinate */
  4356. get y(): number;
  4357. set y(value: number);
  4358. /** Gets or sets the z coordinate */
  4359. get z(): number;
  4360. set z(value: number);
  4361. /** Gets or sets the w coordinate */
  4362. get w(): number;
  4363. set w(value: number);
  4364. /**
  4365. * Creates a new Quaternion from the given floats
  4366. * @param x defines the first component (0 by default)
  4367. * @param y defines the second component (0 by default)
  4368. * @param z defines the third component (0 by default)
  4369. * @param w defines the fourth component (1.0 by default)
  4370. */
  4371. constructor(x?: number, y?: number, z?: number, w?: number);
  4372. /**
  4373. * Gets a string representation for the current quaternion
  4374. * @returns a string with the Quaternion coordinates
  4375. */
  4376. toString(): string;
  4377. /**
  4378. * Gets the class name of the quaternion
  4379. * @returns the string "Quaternion"
  4380. */
  4381. getClassName(): string;
  4382. /**
  4383. * Gets a hash code for this quaternion
  4384. * @returns the quaternion hash code
  4385. */
  4386. getHashCode(): number;
  4387. /**
  4388. * Copy the quaternion to an array
  4389. * @returns a new array populated with 4 elements from the quaternion coordinates
  4390. */
  4391. asArray(): number[];
  4392. /**
  4393. * Check if two quaternions are equals
  4394. * @param otherQuaternion defines the second operand
  4395. * @return true if the current quaternion and the given one coordinates are strictly equals
  4396. */
  4397. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4398. /**
  4399. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4400. * @param otherQuaternion defines the other quaternion
  4401. * @param epsilon defines the minimal distance to consider equality
  4402. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4403. */
  4404. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4405. /**
  4406. * Clone the current quaternion
  4407. * @returns a new quaternion copied from the current one
  4408. */
  4409. clone(): Quaternion;
  4410. /**
  4411. * Copy a quaternion to the current one
  4412. * @param other defines the other quaternion
  4413. * @returns the updated current quaternion
  4414. */
  4415. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4416. /**
  4417. * Updates the current quaternion with the given float coordinates
  4418. * @param x defines the x coordinate
  4419. * @param y defines the y coordinate
  4420. * @param z defines the z coordinate
  4421. * @param w defines the w coordinate
  4422. * @returns the updated current quaternion
  4423. */
  4424. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4425. /**
  4426. * Updates the current quaternion from the given float coordinates
  4427. * @param x defines the x coordinate
  4428. * @param y defines the y coordinate
  4429. * @param z defines the z coordinate
  4430. * @param w defines the w coordinate
  4431. * @returns the updated current quaternion
  4432. */
  4433. set(x: number, y: number, z: number, w: number): Quaternion;
  4434. /**
  4435. * Adds two quaternions
  4436. * @param other defines the second operand
  4437. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4438. */
  4439. add(other: DeepImmutable<Quaternion>): Quaternion;
  4440. /**
  4441. * Add a quaternion to the current one
  4442. * @param other defines the quaternion to add
  4443. * @returns the current quaternion
  4444. */
  4445. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4446. /**
  4447. * Subtract two quaternions
  4448. * @param other defines the second operand
  4449. * @returns a new quaternion as the subtraction result of the given one from the current one
  4450. */
  4451. subtract(other: Quaternion): Quaternion;
  4452. /**
  4453. * Multiplies the current quaternion by a scale factor
  4454. * @param value defines the scale factor
  4455. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4456. */
  4457. scale(value: number): Quaternion;
  4458. /**
  4459. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4460. * @param scale defines the scale factor
  4461. * @param result defines the Quaternion object where to store the result
  4462. * @returns the unmodified current quaternion
  4463. */
  4464. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4465. /**
  4466. * Multiplies in place the current quaternion by a scale factor
  4467. * @param value defines the scale factor
  4468. * @returns the current modified quaternion
  4469. */
  4470. scaleInPlace(value: number): Quaternion;
  4471. /**
  4472. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4473. * @param scale defines the scale factor
  4474. * @param result defines the Quaternion object where to store the result
  4475. * @returns the unmodified current quaternion
  4476. */
  4477. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4478. /**
  4479. * Multiplies two quaternions
  4480. * @param q1 defines the second operand
  4481. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4482. */
  4483. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4484. /**
  4485. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4486. * @param q1 defines the second operand
  4487. * @param result defines the target quaternion
  4488. * @returns the current quaternion
  4489. */
  4490. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4491. /**
  4492. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4493. * @param q1 defines the second operand
  4494. * @returns the currentupdated quaternion
  4495. */
  4496. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4497. /**
  4498. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4499. * @param ref defines the target quaternion
  4500. * @returns the current quaternion
  4501. */
  4502. conjugateToRef(ref: Quaternion): Quaternion;
  4503. /**
  4504. * Conjugates in place (1-q) the current quaternion
  4505. * @returns the current updated quaternion
  4506. */
  4507. conjugateInPlace(): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns a new quaternion
  4511. */
  4512. conjugate(): Quaternion;
  4513. /**
  4514. * Gets length of current quaternion
  4515. * @returns the quaternion length (float)
  4516. */
  4517. length(): number;
  4518. /**
  4519. * Normalize in place the current quaternion
  4520. * @returns the current updated quaternion
  4521. */
  4522. normalize(): Quaternion;
  4523. /**
  4524. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4525. * @param order is a reserved parameter and is ignored for now
  4526. * @returns a new Vector3 containing the Euler angles
  4527. */
  4528. toEulerAngles(order?: string): Vector3;
  4529. /**
  4530. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4531. * @param result defines the vector which will be filled with the Euler angles
  4532. * @returns the current unchanged quaternion
  4533. */
  4534. toEulerAnglesToRef(result: Vector3): Quaternion;
  4535. /**
  4536. * Updates the given rotation matrix with the current quaternion values
  4537. * @param result defines the target matrix
  4538. * @returns the current unchanged quaternion
  4539. */
  4540. toRotationMatrix(result: Matrix): Quaternion;
  4541. /**
  4542. * Updates the current quaternion from the given rotation matrix values
  4543. * @param matrix defines the source matrix
  4544. * @returns the current updated quaternion
  4545. */
  4546. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4547. /**
  4548. * Creates a new quaternion from a rotation matrix
  4549. * @param matrix defines the source matrix
  4550. * @returns a new quaternion created from the given rotation matrix values
  4551. */
  4552. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4553. /**
  4554. * Updates the given quaternion with the given rotation matrix values
  4555. * @param matrix defines the source matrix
  4556. * @param result defines the target quaternion
  4557. */
  4558. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4559. /**
  4560. * Returns the dot product (float) between the quaternions "left" and "right"
  4561. * @param left defines the left operand
  4562. * @param right defines the right operand
  4563. * @returns the dot product
  4564. */
  4565. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4566. /**
  4567. * Checks if the two quaternions are close to each other
  4568. * @param quat0 defines the first quaternion to check
  4569. * @param quat1 defines the second quaternion to check
  4570. * @returns true if the two quaternions are close to each other
  4571. */
  4572. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4573. /**
  4574. * Creates an empty quaternion
  4575. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4576. */
  4577. static Zero(): Quaternion;
  4578. /**
  4579. * Inverse a given quaternion
  4580. * @param q defines the source quaternion
  4581. * @returns a new quaternion as the inverted current quaternion
  4582. */
  4583. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4584. /**
  4585. * Inverse a given quaternion
  4586. * @param q defines the source quaternion
  4587. * @param result the quaternion the result will be stored in
  4588. * @returns the result quaternion
  4589. */
  4590. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4591. /**
  4592. * Creates an identity quaternion
  4593. * @returns the identity quaternion
  4594. */
  4595. static Identity(): Quaternion;
  4596. /**
  4597. * Gets a boolean indicating if the given quaternion is identity
  4598. * @param quaternion defines the quaternion to check
  4599. * @returns true if the quaternion is identity
  4600. */
  4601. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4602. /**
  4603. * Creates a quaternion from a rotation around an axis
  4604. * @param axis defines the axis to use
  4605. * @param angle defines the angle to use
  4606. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4607. */
  4608. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4609. /**
  4610. * Creates a rotation around an axis and stores it into the given quaternion
  4611. * @param axis defines the axis to use
  4612. * @param angle defines the angle to use
  4613. * @param result defines the target quaternion
  4614. * @returns the target quaternion
  4615. */
  4616. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4617. /**
  4618. * Creates a new quaternion from data stored into an array
  4619. * @param array defines the data source
  4620. * @param offset defines the offset in the source array where the data starts
  4621. * @returns a new quaternion
  4622. */
  4623. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4624. /**
  4625. * Updates the given quaternion "result" from the starting index of the given array.
  4626. * @param array the array to pull values from
  4627. * @param offset the offset into the array to start at
  4628. * @param result the quaternion to store the result in
  4629. */
  4630. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4631. /**
  4632. * Create a quaternion from Euler rotation angles
  4633. * @param x Pitch
  4634. * @param y Yaw
  4635. * @param z Roll
  4636. * @returns the new Quaternion
  4637. */
  4638. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4639. /**
  4640. * Updates a quaternion from Euler rotation angles
  4641. * @param x Pitch
  4642. * @param y Yaw
  4643. * @param z Roll
  4644. * @param result the quaternion to store the result
  4645. * @returns the updated quaternion
  4646. */
  4647. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4648. /**
  4649. * Create a quaternion from Euler rotation vector
  4650. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4651. * @returns the new Quaternion
  4652. */
  4653. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4654. /**
  4655. * Updates a quaternion from Euler rotation vector
  4656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4657. * @param result the quaternion to store the result
  4658. * @returns the updated quaternion
  4659. */
  4660. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4661. /**
  4662. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4663. * @param vecFrom defines the direction vector from which to rotate
  4664. * @param vecTo defines the direction vector to which to rotate
  4665. * @param result the quaternion to store the result
  4666. * @returns the updated quaternion
  4667. */
  4668. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4669. /**
  4670. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4671. * @param yaw defines the rotation around Y axis
  4672. * @param pitch defines the rotation around X axis
  4673. * @param roll defines the rotation around Z axis
  4674. * @returns the new quaternion
  4675. */
  4676. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4677. /**
  4678. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4679. * @param yaw defines the rotation around Y axis
  4680. * @param pitch defines the rotation around X axis
  4681. * @param roll defines the rotation around Z axis
  4682. * @param result defines the target quaternion
  4683. */
  4684. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4685. /**
  4686. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4687. * @param alpha defines the rotation around first axis
  4688. * @param beta defines the rotation around second axis
  4689. * @param gamma defines the rotation around third axis
  4690. * @returns the new quaternion
  4691. */
  4692. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4693. /**
  4694. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4695. * @param alpha defines the rotation around first axis
  4696. * @param beta defines the rotation around second axis
  4697. * @param gamma defines the rotation around third axis
  4698. * @param result defines the target quaternion
  4699. */
  4700. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4701. /**
  4702. * 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)
  4703. * @param axis1 defines the first axis
  4704. * @param axis2 defines the second axis
  4705. * @param axis3 defines the third axis
  4706. * @returns the new quaternion
  4707. */
  4708. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4709. /**
  4710. * 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
  4711. * @param axis1 defines the first axis
  4712. * @param axis2 defines the second axis
  4713. * @param axis3 defines the third axis
  4714. * @param ref defines the target quaternion
  4715. */
  4716. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4717. /**
  4718. * Interpolates between two quaternions
  4719. * @param left defines first quaternion
  4720. * @param right defines second quaternion
  4721. * @param amount defines the gradient to use
  4722. * @returns the new interpolated quaternion
  4723. */
  4724. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4725. /**
  4726. * Interpolates between two quaternions and stores it into a target quaternion
  4727. * @param left defines first quaternion
  4728. * @param right defines second quaternion
  4729. * @param amount defines the gradient to use
  4730. * @param result defines the target quaternion
  4731. */
  4732. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4733. /**
  4734. * Interpolate between two quaternions using Hermite interpolation
  4735. * @param value1 defines first quaternion
  4736. * @param tangent1 defines the incoming tangent
  4737. * @param value2 defines second quaternion
  4738. * @param tangent2 defines the outgoing tangent
  4739. * @param amount defines the target quaternion
  4740. * @returns the new interpolated quaternion
  4741. */
  4742. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4743. }
  4744. /**
  4745. * Class used to store matrix data (4x4)
  4746. */
  4747. export class Matrix {
  4748. /**
  4749. * Gets the precision of matrix computations
  4750. */
  4751. static get Use64Bits(): boolean;
  4752. private static _updateFlagSeed;
  4753. private static _identityReadOnly;
  4754. private _isIdentity;
  4755. private _isIdentityDirty;
  4756. private _isIdentity3x2;
  4757. private _isIdentity3x2Dirty;
  4758. /**
  4759. * Gets the update flag of the matrix which is an unique number for the matrix.
  4760. * It will be incremented every time the matrix data change.
  4761. * You can use it to speed the comparison between two versions of the same matrix.
  4762. */
  4763. updateFlag: number;
  4764. private readonly _m;
  4765. /**
  4766. * Gets the internal data of the matrix
  4767. */
  4768. get m(): DeepImmutable<Float32Array | Array<number>>;
  4769. /** @hidden */
  4770. _markAsUpdated(): void;
  4771. /** @hidden */
  4772. private _updateIdentityStatus;
  4773. /**
  4774. * Creates an empty matrix (filled with zeros)
  4775. */
  4776. constructor();
  4777. /**
  4778. * Check if the current matrix is identity
  4779. * @returns true is the matrix is the identity matrix
  4780. */
  4781. isIdentity(): boolean;
  4782. /**
  4783. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentityAs3x2(): boolean;
  4787. /**
  4788. * Gets the determinant of the matrix
  4789. * @returns the matrix determinant
  4790. */
  4791. determinant(): number;
  4792. /**
  4793. * Returns the matrix as a Float32Array or Array<number>
  4794. * @returns the matrix underlying array
  4795. */
  4796. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array.
  4800. */
  4801. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Inverts the current matrix in place
  4804. * @returns the current inverted matrix
  4805. */
  4806. invert(): Matrix;
  4807. /**
  4808. * Sets all the matrix elements to zero
  4809. * @returns the current matrix
  4810. */
  4811. reset(): Matrix;
  4812. /**
  4813. * Adds the current matrix with a second one
  4814. * @param other defines the matrix to add
  4815. * @returns a new matrix as the addition of the current matrix and the given one
  4816. */
  4817. add(other: DeepImmutable<Matrix>): Matrix;
  4818. /**
  4819. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4820. * @param other defines the matrix to add
  4821. * @param result defines the target matrix
  4822. * @returns the current matrix
  4823. */
  4824. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4825. /**
  4826. * Adds in place the given matrix to the current matrix
  4827. * @param other defines the second operand
  4828. * @returns the current updated matrix
  4829. */
  4830. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4831. /**
  4832. * Sets the given matrix to the current inverted Matrix
  4833. * @param other defines the target matrix
  4834. * @returns the unmodified current matrix
  4835. */
  4836. invertToRef(other: Matrix): Matrix;
  4837. /**
  4838. * add a value at the specified position in the current Matrix
  4839. * @param index the index of the value within the matrix. between 0 and 15.
  4840. * @param value the value to be added
  4841. * @returns the current updated matrix
  4842. */
  4843. addAtIndex(index: number, value: number): Matrix;
  4844. /**
  4845. * mutiply the specified position in the current Matrix by a value
  4846. * @param index the index of the value within the matrix. between 0 and 15.
  4847. * @param value the value to be added
  4848. * @returns the current updated matrix
  4849. */
  4850. multiplyAtIndex(index: number, value: number): Matrix;
  4851. /**
  4852. * Inserts the translation vector (using 3 floats) in the current matrix
  4853. * @param x defines the 1st component of the translation
  4854. * @param y defines the 2nd component of the translation
  4855. * @param z defines the 3rd component of the translation
  4856. * @returns the current updated matrix
  4857. */
  4858. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4859. /**
  4860. * Adds the translation vector (using 3 floats) in the current matrix
  4861. * @param x defines the 1st component of the translation
  4862. * @param y defines the 2nd component of the translation
  4863. * @param z defines the 3rd component of the translation
  4864. * @returns the current updated matrix
  4865. */
  4866. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4867. /**
  4868. * Inserts the translation vector in the current matrix
  4869. * @param vector3 defines the translation to insert
  4870. * @returns the current updated matrix
  4871. */
  4872. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4873. /**
  4874. * Gets the translation value of the current matrix
  4875. * @returns a new Vector3 as the extracted translation from the matrix
  4876. */
  4877. getTranslation(): Vector3;
  4878. /**
  4879. * Fill a Vector3 with the extracted translation from the matrix
  4880. * @param result defines the Vector3 where to store the translation
  4881. * @returns the current matrix
  4882. */
  4883. getTranslationToRef(result: Vector3): Matrix;
  4884. /**
  4885. * Remove rotation and scaling part from the matrix
  4886. * @returns the updated matrix
  4887. */
  4888. removeRotationAndScaling(): Matrix;
  4889. /**
  4890. * Multiply two matrices
  4891. * @param other defines the second operand
  4892. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4893. */
  4894. multiply(other: DeepImmutable<Matrix>): Matrix;
  4895. /**
  4896. * Copy the current matrix from the given one
  4897. * @param other defines the source matrix
  4898. * @returns the current updated matrix
  4899. */
  4900. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4901. /**
  4902. * Populates the given array from the starting index with the current matrix values
  4903. * @param array defines the target array
  4904. * @param offset defines the offset in the target array where to start storing values
  4905. * @returns the current matrix
  4906. */
  4907. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4908. /**
  4909. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4910. * @param other defines the second operand
  4911. * @param result defines the matrix where to store the multiplication
  4912. * @returns the current matrix
  4913. */
  4914. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4915. /**
  4916. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4917. * @param other defines the second operand
  4918. * @param result defines the array where to store the multiplication
  4919. * @param offset defines the offset in the target array where to start storing values
  4920. * @returns the current matrix
  4921. */
  4922. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4923. /**
  4924. * Check equality between this matrix and a second one
  4925. * @param value defines the second matrix to compare
  4926. * @returns true is the current matrix and the given one values are strictly equal
  4927. */
  4928. equals(value: DeepImmutable<Matrix>): boolean;
  4929. /**
  4930. * Clone the current matrix
  4931. * @returns a new matrix from the current matrix
  4932. */
  4933. clone(): Matrix;
  4934. /**
  4935. * Returns the name of the current matrix class
  4936. * @returns the string "Matrix"
  4937. */
  4938. getClassName(): string;
  4939. /**
  4940. * Gets the hash code of the current matrix
  4941. * @returns the hash code
  4942. */
  4943. getHashCode(): number;
  4944. /**
  4945. * Decomposes the current Matrix into a translation, rotation and scaling components
  4946. * @param scale defines the scale vector3 given as a reference to update
  4947. * @param rotation defines the rotation quaternion given as a reference to update
  4948. * @param translation defines the translation vector3 given as a reference to update
  4949. * @returns true if operation was successful
  4950. */
  4951. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4952. /**
  4953. * Gets specific row of the matrix
  4954. * @param index defines the number of the row to get
  4955. * @returns the index-th row of the current matrix as a new Vector4
  4956. */
  4957. getRow(index: number): Nullable<Vector4>;
  4958. /**
  4959. * Sets the index-th row of the current matrix to the vector4 values
  4960. * @param index defines the number of the row to set
  4961. * @param row defines the target vector4
  4962. * @returns the updated current matrix
  4963. */
  4964. setRow(index: number, row: Vector4): Matrix;
  4965. /**
  4966. * Compute the transpose of the matrix
  4967. * @returns the new transposed matrix
  4968. */
  4969. transpose(): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix and store it in a given matrix
  4972. * @param result defines the target matrix
  4973. * @returns the current matrix
  4974. */
  4975. transposeToRef(result: Matrix): Matrix;
  4976. /**
  4977. * Sets the index-th row of the current matrix with the given 4 x float values
  4978. * @param index defines the row index
  4979. * @param x defines the x component to set
  4980. * @param y defines the y component to set
  4981. * @param z defines the z component to set
  4982. * @param w defines the w component to set
  4983. * @returns the updated current matrix
  4984. */
  4985. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4986. /**
  4987. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4988. * @param scale defines the scale factor
  4989. * @returns a new matrix
  4990. */
  4991. scale(scale: number): Matrix;
  4992. /**
  4993. * Scale the current matrix values by a factor to a given result matrix
  4994. * @param scale defines the scale factor
  4995. * @param result defines the matrix to store the result
  4996. * @returns the current matrix
  4997. */
  4998. scaleToRef(scale: number, result: Matrix): Matrix;
  4999. /**
  5000. * Scale the current matrix values by a factor and add the result to a given matrix
  5001. * @param scale defines the scale factor
  5002. * @param result defines the Matrix to store the result
  5003. * @returns the current matrix
  5004. */
  5005. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5006. /**
  5007. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5008. * @param ref matrix to store the result
  5009. */
  5010. toNormalMatrix(ref: Matrix): void;
  5011. /**
  5012. * Gets only rotation part of the current matrix
  5013. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5014. */
  5015. getRotationMatrix(): Matrix;
  5016. /**
  5017. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5018. * @param result defines the target matrix to store data to
  5019. * @returns the current matrix
  5020. */
  5021. getRotationMatrixToRef(result: Matrix): Matrix;
  5022. /**
  5023. * Toggles model matrix from being right handed to left handed in place and vice versa
  5024. */
  5025. toggleModelMatrixHandInPlace(): void;
  5026. /**
  5027. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5028. */
  5029. toggleProjectionMatrixHandInPlace(): void;
  5030. /**
  5031. * Creates a matrix from an array
  5032. * @param array defines the source array
  5033. * @param offset defines an offset in the source array
  5034. * @returns a new Matrix set from the starting index of the given array
  5035. */
  5036. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5037. /**
  5038. * Copy the content of an array into a given matrix
  5039. * @param array defines the source array
  5040. * @param offset defines an offset in the source array
  5041. * @param result defines the target matrix
  5042. */
  5043. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5044. /**
  5045. * Stores an array into a matrix after having multiplied each component by a given factor
  5046. * @param array defines the source array
  5047. * @param offset defines the offset in the source array
  5048. * @param scale defines the scaling factor
  5049. * @param result defines the target matrix
  5050. */
  5051. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5052. /**
  5053. * Gets an identity matrix that must not be updated
  5054. */
  5055. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5056. /**
  5057. * Stores a list of values (16) inside a given matrix
  5058. * @param initialM11 defines 1st value of 1st row
  5059. * @param initialM12 defines 2nd value of 1st row
  5060. * @param initialM13 defines 3rd value of 1st row
  5061. * @param initialM14 defines 4th value of 1st row
  5062. * @param initialM21 defines 1st value of 2nd row
  5063. * @param initialM22 defines 2nd value of 2nd row
  5064. * @param initialM23 defines 3rd value of 2nd row
  5065. * @param initialM24 defines 4th value of 2nd row
  5066. * @param initialM31 defines 1st value of 3rd row
  5067. * @param initialM32 defines 2nd value of 3rd row
  5068. * @param initialM33 defines 3rd value of 3rd row
  5069. * @param initialM34 defines 4th value of 3rd row
  5070. * @param initialM41 defines 1st value of 4th row
  5071. * @param initialM42 defines 2nd value of 4th row
  5072. * @param initialM43 defines 3rd value of 4th row
  5073. * @param initialM44 defines 4th value of 4th row
  5074. * @param result defines the target matrix
  5075. */
  5076. 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;
  5077. /**
  5078. * Creates new matrix from a list of values (16)
  5079. * @param initialM11 defines 1st value of 1st row
  5080. * @param initialM12 defines 2nd value of 1st row
  5081. * @param initialM13 defines 3rd value of 1st row
  5082. * @param initialM14 defines 4th value of 1st row
  5083. * @param initialM21 defines 1st value of 2nd row
  5084. * @param initialM22 defines 2nd value of 2nd row
  5085. * @param initialM23 defines 3rd value of 2nd row
  5086. * @param initialM24 defines 4th value of 2nd row
  5087. * @param initialM31 defines 1st value of 3rd row
  5088. * @param initialM32 defines 2nd value of 3rd row
  5089. * @param initialM33 defines 3rd value of 3rd row
  5090. * @param initialM34 defines 4th value of 3rd row
  5091. * @param initialM41 defines 1st value of 4th row
  5092. * @param initialM42 defines 2nd value of 4th row
  5093. * @param initialM43 defines 3rd value of 4th row
  5094. * @param initialM44 defines 4th value of 4th row
  5095. * @returns the new matrix
  5096. */
  5097. 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;
  5098. /**
  5099. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5100. * @param scale defines the scale vector3
  5101. * @param rotation defines the rotation quaternion
  5102. * @param translation defines the translation vector3
  5103. * @returns a new matrix
  5104. */
  5105. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5106. /**
  5107. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5108. * @param scale defines the scale vector3
  5109. * @param rotation defines the rotation quaternion
  5110. * @param translation defines the translation vector3
  5111. * @param result defines the target matrix
  5112. */
  5113. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5114. /**
  5115. * Creates a new identity matrix
  5116. * @returns a new identity matrix
  5117. */
  5118. static Identity(): Matrix;
  5119. /**
  5120. * Creates a new identity matrix and stores the result in a given matrix
  5121. * @param result defines the target matrix
  5122. */
  5123. static IdentityToRef(result: Matrix): void;
  5124. /**
  5125. * Creates a new zero matrix
  5126. * @returns a new zero matrix
  5127. */
  5128. static Zero(): Matrix;
  5129. /**
  5130. * Creates a new rotation matrix for "angle" radians around the X axis
  5131. * @param angle defines the angle (in radians) to use
  5132. * @return the new matrix
  5133. */
  5134. static RotationX(angle: number): Matrix;
  5135. /**
  5136. * Creates a new matrix as the invert of a given matrix
  5137. * @param source defines the source matrix
  5138. * @returns the new matrix
  5139. */
  5140. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5141. /**
  5142. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5143. * @param angle defines the angle (in radians) to use
  5144. * @param result defines the target matrix
  5145. */
  5146. static RotationXToRef(angle: number, result: Matrix): void;
  5147. /**
  5148. * Creates a new rotation matrix for "angle" radians around the Y axis
  5149. * @param angle defines the angle (in radians) to use
  5150. * @return the new matrix
  5151. */
  5152. static RotationY(angle: number): Matrix;
  5153. /**
  5154. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5155. * @param angle defines the angle (in radians) to use
  5156. * @param result defines the target matrix
  5157. */
  5158. static RotationYToRef(angle: number, result: Matrix): void;
  5159. /**
  5160. * Creates a new rotation matrix for "angle" radians around the Z axis
  5161. * @param angle defines the angle (in radians) to use
  5162. * @return the new matrix
  5163. */
  5164. static RotationZ(angle: number): Matrix;
  5165. /**
  5166. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5167. * @param angle defines the angle (in radians) to use
  5168. * @param result defines the target matrix
  5169. */
  5170. static RotationZToRef(angle: number, result: Matrix): void;
  5171. /**
  5172. * Creates a new rotation matrix for "angle" radians around the given axis
  5173. * @param axis defines the axis to use
  5174. * @param angle defines the angle (in radians) to use
  5175. * @return the new matrix
  5176. */
  5177. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5178. /**
  5179. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5180. * @param axis defines the axis to use
  5181. * @param angle defines the angle (in radians) to use
  5182. * @param result defines the target matrix
  5183. */
  5184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5185. /**
  5186. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5187. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5188. * @param from defines the vector to align
  5189. * @param to defines the vector to align to
  5190. * @param result defines the target matrix
  5191. */
  5192. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5193. /**
  5194. * Creates a rotation matrix
  5195. * @param yaw defines the yaw angle in radians (Y axis)
  5196. * @param pitch defines the pitch angle in radians (X axis)
  5197. * @param roll defines the roll angle in radians (Z axis)
  5198. * @returns the new rotation matrix
  5199. */
  5200. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5201. /**
  5202. * Creates a rotation matrix and stores it in a given matrix
  5203. * @param yaw defines the yaw angle in radians (Y axis)
  5204. * @param pitch defines the pitch angle in radians (X axis)
  5205. * @param roll defines the roll angle in radians (Z axis)
  5206. * @param result defines the target matrix
  5207. */
  5208. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5209. /**
  5210. * Creates a scaling matrix
  5211. * @param x defines the scale factor on X axis
  5212. * @param y defines the scale factor on Y axis
  5213. * @param z defines the scale factor on Z axis
  5214. * @returns the new matrix
  5215. */
  5216. static Scaling(x: number, y: number, z: number): Matrix;
  5217. /**
  5218. * Creates a scaling matrix and stores it in a given matrix
  5219. * @param x defines the scale factor on X axis
  5220. * @param y defines the scale factor on Y axis
  5221. * @param z defines the scale factor on Z axis
  5222. * @param result defines the target matrix
  5223. */
  5224. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5225. /**
  5226. * Creates a translation matrix
  5227. * @param x defines the translation on X axis
  5228. * @param y defines the translation on Y axis
  5229. * @param z defines the translationon Z axis
  5230. * @returns the new matrix
  5231. */
  5232. static Translation(x: number, y: number, z: number): Matrix;
  5233. /**
  5234. * Creates a translation matrix and stores it in a given matrix
  5235. * @param x defines the translation on X axis
  5236. * @param y defines the translation on Y axis
  5237. * @param z defines the translationon Z axis
  5238. * @param result defines the target matrix
  5239. */
  5240. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5241. /**
  5242. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5243. * @param startValue defines the start value
  5244. * @param endValue defines the end value
  5245. * @param gradient defines the gradient factor
  5246. * @returns the new matrix
  5247. */
  5248. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5249. /**
  5250. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5251. * @param startValue defines the start value
  5252. * @param endValue defines the end value
  5253. * @param gradient defines the gradient factor
  5254. * @param result defines the Matrix object where to store data
  5255. */
  5256. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5257. /**
  5258. * Builds a new matrix whose values are computed by:
  5259. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5260. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5261. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5262. * @param startValue defines the first matrix
  5263. * @param endValue defines the second matrix
  5264. * @param gradient defines the gradient between the two matrices
  5265. * @returns the new matrix
  5266. */
  5267. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5268. /**
  5269. * Update a matrix to values which are computed by:
  5270. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5271. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5272. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5273. * @param startValue defines the first matrix
  5274. * @param endValue defines the second matrix
  5275. * @param gradient defines the gradient between the two matrices
  5276. * @param result defines the target matrix
  5277. */
  5278. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5279. /**
  5280. * 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"
  5281. * This function works in left handed mode
  5282. * @param eye defines the final position of the entity
  5283. * @param target defines where the entity should look at
  5284. * @param up defines the up vector for the entity
  5285. * @returns the new matrix
  5286. */
  5287. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5288. /**
  5289. * 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".
  5290. * This function works in left handed mode
  5291. * @param eye defines the final position of the entity
  5292. * @param target defines where the entity should look at
  5293. * @param up defines the up vector for the entity
  5294. * @param result defines the target matrix
  5295. */
  5296. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5297. /**
  5298. * 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"
  5299. * This function works in right handed mode
  5300. * @param eye defines the final position of the entity
  5301. * @param target defines where the entity should look at
  5302. * @param up defines the up vector for the entity
  5303. * @returns the new matrix
  5304. */
  5305. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5306. /**
  5307. * 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".
  5308. * This function works in right handed mode
  5309. * @param eye defines the final position of the entity
  5310. * @param target defines where the entity should look at
  5311. * @param up defines the up vector for the entity
  5312. * @param result defines the target matrix
  5313. */
  5314. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5315. /**
  5316. * Create a left-handed orthographic projection matrix
  5317. * @param width defines the viewport width
  5318. * @param height defines the viewport height
  5319. * @param znear defines the near clip plane
  5320. * @param zfar defines the far clip plane
  5321. * @returns a new matrix as a left-handed orthographic projection matrix
  5322. */
  5323. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5324. /**
  5325. * Store a left-handed orthographic projection to a given matrix
  5326. * @param width defines the viewport width
  5327. * @param height defines the viewport height
  5328. * @param znear defines the near clip plane
  5329. * @param zfar defines the far clip plane
  5330. * @param result defines the target matrix
  5331. */
  5332. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5333. /**
  5334. * Create a left-handed orthographic projection matrix
  5335. * @param left defines the viewport left coordinate
  5336. * @param right defines the viewport right coordinate
  5337. * @param bottom defines the viewport bottom coordinate
  5338. * @param top defines the viewport top coordinate
  5339. * @param znear defines the near clip plane
  5340. * @param zfar defines the far clip plane
  5341. * @returns a new matrix as a left-handed orthographic projection matrix
  5342. */
  5343. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5344. /**
  5345. * Stores a left-handed orthographic projection into a given matrix
  5346. * @param left defines the viewport left coordinate
  5347. * @param right defines the viewport right coordinate
  5348. * @param bottom defines the viewport bottom coordinate
  5349. * @param top defines the viewport top coordinate
  5350. * @param znear defines the near clip plane
  5351. * @param zfar defines the far clip plane
  5352. * @param result defines the target matrix
  5353. */
  5354. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5355. /**
  5356. * Creates a right-handed orthographic projection matrix
  5357. * @param left defines the viewport left coordinate
  5358. * @param right defines the viewport right coordinate
  5359. * @param bottom defines the viewport bottom coordinate
  5360. * @param top defines the viewport top coordinate
  5361. * @param znear defines the near clip plane
  5362. * @param zfar defines the far clip plane
  5363. * @returns a new matrix as a right-handed orthographic projection matrix
  5364. */
  5365. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5366. /**
  5367. * Stores a right-handed orthographic projection into a given matrix
  5368. * @param left defines the viewport left coordinate
  5369. * @param right defines the viewport right coordinate
  5370. * @param bottom defines the viewport bottom coordinate
  5371. * @param top defines the viewport top coordinate
  5372. * @param znear defines the near clip plane
  5373. * @param zfar defines the far clip plane
  5374. * @param result defines the target matrix
  5375. */
  5376. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5377. /**
  5378. * Creates a left-handed perspective projection matrix
  5379. * @param width defines the viewport width
  5380. * @param height defines the viewport height
  5381. * @param znear defines the near clip plane
  5382. * @param zfar defines the far clip plane
  5383. * @returns a new matrix as a left-handed perspective projection matrix
  5384. */
  5385. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5386. /**
  5387. * Creates a left-handed perspective projection matrix
  5388. * @param fov defines the horizontal field of view
  5389. * @param aspect defines the aspect ratio
  5390. * @param znear defines the near clip plane
  5391. * @param zfar defines the far clip plane
  5392. * @returns a new matrix as a left-handed perspective projection matrix
  5393. */
  5394. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5395. /**
  5396. * Stores a left-handed perspective projection into a given matrix
  5397. * @param fov defines the horizontal field of view
  5398. * @param aspect defines the aspect ratio
  5399. * @param znear defines the near clip plane
  5400. * @param zfar defines the far clip plane
  5401. * @param result defines the target matrix
  5402. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5403. */
  5404. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5405. /**
  5406. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5407. * @param fov defines the horizontal field of view
  5408. * @param aspect defines the aspect ratio
  5409. * @param znear defines the near clip plane
  5410. * @param zfar not used as infinity is used as far clip
  5411. * @param result defines the target matrix
  5412. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5413. */
  5414. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5415. /**
  5416. * Creates a right-handed perspective projection matrix
  5417. * @param fov defines the horizontal field of view
  5418. * @param aspect defines the aspect ratio
  5419. * @param znear defines the near clip plane
  5420. * @param zfar defines the far clip plane
  5421. * @returns a new matrix as a right-handed perspective projection matrix
  5422. */
  5423. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5424. /**
  5425. * Stores a right-handed perspective projection into a given matrix
  5426. * @param fov defines the horizontal field of view
  5427. * @param aspect defines the aspect ratio
  5428. * @param znear defines the near clip plane
  5429. * @param zfar defines the far clip plane
  5430. * @param result defines the target matrix
  5431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5432. */
  5433. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5434. /**
  5435. * Stores a right-handed perspective projection into a given matrix
  5436. * @param fov defines the horizontal field of view
  5437. * @param aspect defines the aspect ratio
  5438. * @param znear defines the near clip plane
  5439. * @param zfar not used as infinity is used as far clip
  5440. * @param result defines the target matrix
  5441. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5442. */
  5443. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5444. /**
  5445. * Stores a perspective projection for WebVR info a given matrix
  5446. * @param fov defines the field of view
  5447. * @param znear defines the near clip plane
  5448. * @param zfar defines the far clip plane
  5449. * @param result defines the target matrix
  5450. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5451. */
  5452. static PerspectiveFovWebVRToRef(fov: {
  5453. upDegrees: number;
  5454. downDegrees: number;
  5455. leftDegrees: number;
  5456. rightDegrees: number;
  5457. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5458. /**
  5459. * Computes a complete transformation matrix
  5460. * @param viewport defines the viewport to use
  5461. * @param world defines the world matrix
  5462. * @param view defines the view matrix
  5463. * @param projection defines the projection matrix
  5464. * @param zmin defines the near clip plane
  5465. * @param zmax defines the far clip plane
  5466. * @returns the transformation matrix
  5467. */
  5468. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5469. /**
  5470. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5471. * @param matrix defines the matrix to use
  5472. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5473. */
  5474. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5475. /**
  5476. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5477. * @param matrix defines the matrix to use
  5478. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5479. */
  5480. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5481. /**
  5482. * Compute the transpose of a given matrix
  5483. * @param matrix defines the matrix to transpose
  5484. * @returns the new matrix
  5485. */
  5486. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5487. /**
  5488. * Compute the transpose of a matrix and store it in a target matrix
  5489. * @param matrix defines the matrix to transpose
  5490. * @param result defines the target matrix
  5491. */
  5492. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5493. /**
  5494. * Computes a reflection matrix from a plane
  5495. * @param plane defines the reflection plane
  5496. * @returns a new matrix
  5497. */
  5498. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5499. /**
  5500. * Computes a reflection matrix from a plane
  5501. * @param plane defines the reflection plane
  5502. * @param result defines the target matrix
  5503. */
  5504. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5505. /**
  5506. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5507. * @param xaxis defines the value of the 1st axis
  5508. * @param yaxis defines the value of the 2nd axis
  5509. * @param zaxis defines the value of the 3rd axis
  5510. * @param result defines the target matrix
  5511. */
  5512. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5513. /**
  5514. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5515. * @param quat defines the quaternion to use
  5516. * @param result defines the target matrix
  5517. */
  5518. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5519. }
  5520. /**
  5521. * @hidden
  5522. */
  5523. export class TmpVectors {
  5524. static Vector2: Vector2[];
  5525. static Vector3: Vector3[];
  5526. static Vector4: Vector4[];
  5527. static Quaternion: Quaternion[];
  5528. static Matrix: Matrix[];
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * Defines potential orientation for back face culling
  5534. */
  5535. export enum Orientation {
  5536. /**
  5537. * Clockwise
  5538. */
  5539. CW = 0,
  5540. /** Counter clockwise */
  5541. CCW = 1
  5542. }
  5543. /** Class used to represent a Bezier curve */
  5544. export class BezierCurve {
  5545. /**
  5546. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5547. * @param t defines the time
  5548. * @param x1 defines the left coordinate on X axis
  5549. * @param y1 defines the left coordinate on Y axis
  5550. * @param x2 defines the right coordinate on X axis
  5551. * @param y2 defines the right coordinate on Y axis
  5552. * @returns the interpolated value
  5553. */
  5554. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5555. }
  5556. /**
  5557. * Defines angle representation
  5558. */
  5559. export class Angle {
  5560. private _radians;
  5561. /**
  5562. * Creates an Angle object of "radians" radians (float).
  5563. * @param radians the angle in radians
  5564. */
  5565. constructor(radians: number);
  5566. /**
  5567. * Get value in degrees
  5568. * @returns the Angle value in degrees (float)
  5569. */
  5570. degrees(): number;
  5571. /**
  5572. * Get value in radians
  5573. * @returns the Angle value in radians (float)
  5574. */
  5575. radians(): number;
  5576. /**
  5577. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5578. * @param a defines first point as the origin
  5579. * @param b defines point
  5580. * @returns a new Angle
  5581. */
  5582. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5583. /**
  5584. * Gets a new Angle object from the given float in radians
  5585. * @param radians defines the angle value in radians
  5586. * @returns a new Angle
  5587. */
  5588. static FromRadians(radians: number): Angle;
  5589. /**
  5590. * Gets a new Angle object from the given float in degrees
  5591. * @param degrees defines the angle value in degrees
  5592. * @returns a new Angle
  5593. */
  5594. static FromDegrees(degrees: number): Angle;
  5595. }
  5596. /**
  5597. * This represents an arc in a 2d space.
  5598. */
  5599. export class Arc2 {
  5600. /** Defines the start point of the arc */
  5601. startPoint: Vector2;
  5602. /** Defines the mid point of the arc */
  5603. midPoint: Vector2;
  5604. /** Defines the end point of the arc */
  5605. endPoint: Vector2;
  5606. /**
  5607. * Defines the center point of the arc.
  5608. */
  5609. centerPoint: Vector2;
  5610. /**
  5611. * Defines the radius of the arc.
  5612. */
  5613. radius: number;
  5614. /**
  5615. * Defines the angle of the arc (from mid point to end point).
  5616. */
  5617. angle: Angle;
  5618. /**
  5619. * Defines the start angle of the arc (from start point to middle point).
  5620. */
  5621. startAngle: Angle;
  5622. /**
  5623. * Defines the orientation of the arc (clock wise/counter clock wise).
  5624. */
  5625. orientation: Orientation;
  5626. /**
  5627. * Creates an Arc object from the three given points : start, middle and end.
  5628. * @param startPoint Defines the start point of the arc
  5629. * @param midPoint Defines the midlle point of the arc
  5630. * @param endPoint Defines the end point of the arc
  5631. */
  5632. constructor(
  5633. /** Defines the start point of the arc */
  5634. startPoint: Vector2,
  5635. /** Defines the mid point of the arc */
  5636. midPoint: Vector2,
  5637. /** Defines the end point of the arc */
  5638. endPoint: Vector2);
  5639. }
  5640. /**
  5641. * Represents a 2D path made up of multiple 2D points
  5642. */
  5643. export class Path2 {
  5644. private _points;
  5645. private _length;
  5646. /**
  5647. * If the path start and end point are the same
  5648. */
  5649. closed: boolean;
  5650. /**
  5651. * Creates a Path2 object from the starting 2D coordinates x and y.
  5652. * @param x the starting points x value
  5653. * @param y the starting points y value
  5654. */
  5655. constructor(x: number, y: number);
  5656. /**
  5657. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5658. * @param x the added points x value
  5659. * @param y the added points y value
  5660. * @returns the updated Path2.
  5661. */
  5662. addLineTo(x: number, y: number): Path2;
  5663. /**
  5664. * 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.
  5665. * @param midX middle point x value
  5666. * @param midY middle point y value
  5667. * @param endX end point x value
  5668. * @param endY end point y value
  5669. * @param numberOfSegments (default: 36)
  5670. * @returns the updated Path2.
  5671. */
  5672. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5673. /**
  5674. * Closes the Path2.
  5675. * @returns the Path2.
  5676. */
  5677. close(): Path2;
  5678. /**
  5679. * Gets the sum of the distance between each sequential point in the path
  5680. * @returns the Path2 total length (float).
  5681. */
  5682. length(): number;
  5683. /**
  5684. * Gets the points which construct the path
  5685. * @returns the Path2 internal array of points.
  5686. */
  5687. getPoints(): Vector2[];
  5688. /**
  5689. * Retreives the point at the distance aways from the starting point
  5690. * @param normalizedLengthPosition the length along the path to retreive the point from
  5691. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5692. */
  5693. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5694. /**
  5695. * Creates a new path starting from an x and y position
  5696. * @param x starting x value
  5697. * @param y starting y value
  5698. * @returns a new Path2 starting at the coordinates (x, y).
  5699. */
  5700. static StartingAt(x: number, y: number): Path2;
  5701. }
  5702. /**
  5703. * Represents a 3D path made up of multiple 3D points
  5704. */
  5705. export class Path3D {
  5706. /**
  5707. * an array of Vector3, the curve axis of the Path3D
  5708. */
  5709. path: Vector3[];
  5710. private _curve;
  5711. private _distances;
  5712. private _tangents;
  5713. private _normals;
  5714. private _binormals;
  5715. private _raw;
  5716. private _alignTangentsWithPath;
  5717. private readonly _pointAtData;
  5718. /**
  5719. * new Path3D(path, normal, raw)
  5720. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5721. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5722. * @param path an array of Vector3, the curve axis of the Path3D
  5723. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5724. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5725. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5726. */
  5727. constructor(
  5728. /**
  5729. * an array of Vector3, the curve axis of the Path3D
  5730. */
  5731. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5732. /**
  5733. * Returns the Path3D array of successive Vector3 designing its curve.
  5734. * @returns the Path3D array of successive Vector3 designing its curve.
  5735. */
  5736. getCurve(): Vector3[];
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getPoints(): Vector3[];
  5742. /**
  5743. * @returns the computed length (float) of the path.
  5744. */
  5745. length(): number;
  5746. /**
  5747. * Returns an array populated with tangent vectors on each Path3D curve point.
  5748. * @returns an array populated with tangent vectors on each Path3D curve point.
  5749. */
  5750. getTangents(): Vector3[];
  5751. /**
  5752. * Returns an array populated with normal vectors on each Path3D curve point.
  5753. * @returns an array populated with normal vectors on each Path3D curve point.
  5754. */
  5755. getNormals(): Vector3[];
  5756. /**
  5757. * Returns an array populated with binormal vectors on each Path3D curve point.
  5758. * @returns an array populated with binormal vectors on each Path3D curve point.
  5759. */
  5760. getBinormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5763. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5764. */
  5765. getDistances(): number[];
  5766. /**
  5767. * Returns an interpolated point along this path
  5768. * @param position the position of the point along this path, from 0.0 to 1.0
  5769. * @returns a new Vector3 as the point
  5770. */
  5771. getPointAt(position: number): Vector3;
  5772. /**
  5773. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5774. * @param position the position of the point along this path, from 0.0 to 1.0
  5775. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5776. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5777. */
  5778. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5779. /**
  5780. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5781. * @param position the position of the point along this path, from 0.0 to 1.0
  5782. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5783. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5784. */
  5785. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5786. /**
  5787. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5788. * @param position the position of the point along this path, from 0.0 to 1.0
  5789. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5790. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5791. */
  5792. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5793. /**
  5794. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5795. * @param position the position of the point along this path, from 0.0 to 1.0
  5796. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5797. */
  5798. getDistanceAt(position: number): number;
  5799. /**
  5800. * Returns the array index of the previous point of an interpolated point along this path
  5801. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5802. * @returns the array index
  5803. */
  5804. getPreviousPointIndexAt(position: number): number;
  5805. /**
  5806. * 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)
  5807. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5808. * @returns the sub position
  5809. */
  5810. getSubPositionAt(position: number): number;
  5811. /**
  5812. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5813. * @param target the vector of which to get the closest position to
  5814. * @returns the position of the closest virtual point on this path to the target vector
  5815. */
  5816. getClosestPositionTo(target: Vector3): number;
  5817. /**
  5818. * Returns a sub path (slice) of this path
  5819. * @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
  5820. * @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
  5821. * @returns a sub path (slice) of this path
  5822. */
  5823. slice(start?: number, end?: number): Path3D;
  5824. /**
  5825. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5826. * @param path path which all values are copied into the curves points
  5827. * @param firstNormal which should be projected onto the curve
  5828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5829. * @returns the same object updated.
  5830. */
  5831. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5832. private _compute;
  5833. private _getFirstNonNullVector;
  5834. private _getLastNonNullVector;
  5835. private _normalVector;
  5836. /**
  5837. * Updates the point at data for an interpolated point along this curve
  5838. * @param position the position of the point along this curve, from 0.0 to 1.0
  5839. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5840. * @returns the (updated) point at data
  5841. */
  5842. private _updatePointAtData;
  5843. /**
  5844. * Updates the point at data from the specified parameters
  5845. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5846. * @param point the interpolated point
  5847. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5848. */
  5849. private _setPointAtData;
  5850. /**
  5851. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5852. */
  5853. private _updateInterpolationMatrix;
  5854. }
  5855. /**
  5856. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5857. * A Curve3 is designed from a series of successive Vector3.
  5858. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5859. */
  5860. export class Curve3 {
  5861. private _points;
  5862. private _length;
  5863. /**
  5864. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5865. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5866. * @param v1 (Vector3) the control point
  5867. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5868. * @param nbPoints (integer) the wanted number of points in the curve
  5869. * @returns the created Curve3
  5870. */
  5871. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5872. /**
  5873. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5874. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5875. * @param v1 (Vector3) the first control point
  5876. * @param v2 (Vector3) the second control point
  5877. * @param v3 (Vector3) the end point of the Cubic Bezier
  5878. * @param nbPoints (integer) the wanted number of points in the curve
  5879. * @returns the created Curve3
  5880. */
  5881. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5882. /**
  5883. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5884. * @param p1 (Vector3) the origin point of the Hermite Spline
  5885. * @param t1 (Vector3) the tangent vector at the origin point
  5886. * @param p2 (Vector3) the end point of the Hermite Spline
  5887. * @param t2 (Vector3) the tangent vector at the end point
  5888. * @param nbPoints (integer) the wanted number of points in the curve
  5889. * @returns the created Curve3
  5890. */
  5891. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5892. /**
  5893. * Returns a Curve3 object along a CatmullRom Spline curve :
  5894. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5895. * @param nbPoints (integer) the wanted number of points between each curve control points
  5896. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5897. * @returns the created Curve3
  5898. */
  5899. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5900. /**
  5901. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5902. * A Curve3 is designed from a series of successive Vector3.
  5903. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5904. * @param points points which make up the curve
  5905. */
  5906. constructor(points: Vector3[]);
  5907. /**
  5908. * @returns the Curve3 stored array of successive Vector3
  5909. */
  5910. getPoints(): Vector3[];
  5911. /**
  5912. * @returns the computed length (float) of the curve.
  5913. */
  5914. length(): number;
  5915. /**
  5916. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5917. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5918. * curveA and curveB keep unchanged.
  5919. * @param curve the curve to continue from this curve
  5920. * @returns the newly constructed curve
  5921. */
  5922. continue(curve: DeepImmutable<Curve3>): Curve3;
  5923. private _computeLength;
  5924. }
  5925. }
  5926. declare module BABYLON {
  5927. /**
  5928. * This represents the main contract an easing function should follow.
  5929. * Easing functions are used throughout the animation system.
  5930. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5931. */
  5932. export interface IEasingFunction {
  5933. /**
  5934. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5935. * of the easing function.
  5936. * The link below provides some of the most common examples of easing functions.
  5937. * @see https://easings.net/
  5938. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5939. * @returns the corresponding value on the curve defined by the easing function
  5940. */
  5941. ease(gradient: number): number;
  5942. }
  5943. /**
  5944. * Base class used for every default easing function.
  5945. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5946. */
  5947. export class EasingFunction implements IEasingFunction {
  5948. /**
  5949. * Interpolation follows the mathematical formula associated with the easing function.
  5950. */
  5951. static readonly EASINGMODE_EASEIN: number;
  5952. /**
  5953. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5954. */
  5955. static readonly EASINGMODE_EASEOUT: number;
  5956. /**
  5957. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5958. */
  5959. static readonly EASINGMODE_EASEINOUT: number;
  5960. private _easingMode;
  5961. /**
  5962. * Sets the easing mode of the current function.
  5963. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5964. */
  5965. setEasingMode(easingMode: number): void;
  5966. /**
  5967. * Gets the current easing mode.
  5968. * @returns the easing mode
  5969. */
  5970. getEasingMode(): number;
  5971. /**
  5972. * @hidden
  5973. */
  5974. easeInCore(gradient: number): number;
  5975. /**
  5976. * Given an input gradient between 0 and 1, this returns the corresponding value
  5977. * of the easing function.
  5978. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5979. * @returns the corresponding value on the curve defined by the easing function
  5980. */
  5981. ease(gradient: number): number;
  5982. }
  5983. /**
  5984. * Easing function with a circle shape (see link below).
  5985. * @see https://easings.net/#easeInCirc
  5986. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5987. */
  5988. export class CircleEase extends EasingFunction implements IEasingFunction {
  5989. /** @hidden */
  5990. easeInCore(gradient: number): number;
  5991. }
  5992. /**
  5993. * Easing function with a ease back shape (see link below).
  5994. * @see https://easings.net/#easeInBack
  5995. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5996. */
  5997. export class BackEase extends EasingFunction implements IEasingFunction {
  5998. /** Defines the amplitude of the function */
  5999. amplitude: number;
  6000. /**
  6001. * Instantiates a back ease easing
  6002. * @see https://easings.net/#easeInBack
  6003. * @param amplitude Defines the amplitude of the function
  6004. */
  6005. constructor(
  6006. /** Defines the amplitude of the function */
  6007. amplitude?: number);
  6008. /** @hidden */
  6009. easeInCore(gradient: number): number;
  6010. }
  6011. /**
  6012. * Easing function with a bouncing shape (see link below).
  6013. * @see https://easings.net/#easeInBounce
  6014. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6015. */
  6016. export class BounceEase extends EasingFunction implements IEasingFunction {
  6017. /** Defines the number of bounces */
  6018. bounces: number;
  6019. /** Defines the amplitude of the bounce */
  6020. bounciness: number;
  6021. /**
  6022. * Instantiates a bounce easing
  6023. * @see https://easings.net/#easeInBounce
  6024. * @param bounces Defines the number of bounces
  6025. * @param bounciness Defines the amplitude of the bounce
  6026. */
  6027. constructor(
  6028. /** Defines the number of bounces */
  6029. bounces?: number,
  6030. /** Defines the amplitude of the bounce */
  6031. bounciness?: number);
  6032. /** @hidden */
  6033. easeInCore(gradient: number): number;
  6034. }
  6035. /**
  6036. * Easing function with a power of 3 shape (see link below).
  6037. * @see https://easings.net/#easeInCubic
  6038. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6039. */
  6040. export class CubicEase extends EasingFunction implements IEasingFunction {
  6041. /** @hidden */
  6042. easeInCore(gradient: number): number;
  6043. }
  6044. /**
  6045. * Easing function with an elastic shape (see link below).
  6046. * @see https://easings.net/#easeInElastic
  6047. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6048. */
  6049. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6050. /** Defines the number of oscillations*/
  6051. oscillations: number;
  6052. /** Defines the amplitude of the oscillations*/
  6053. springiness: number;
  6054. /**
  6055. * Instantiates an elastic easing function
  6056. * @see https://easings.net/#easeInElastic
  6057. * @param oscillations Defines the number of oscillations
  6058. * @param springiness Defines the amplitude of the oscillations
  6059. */
  6060. constructor(
  6061. /** Defines the number of oscillations*/
  6062. oscillations?: number,
  6063. /** Defines the amplitude of the oscillations*/
  6064. springiness?: number);
  6065. /** @hidden */
  6066. easeInCore(gradient: number): number;
  6067. }
  6068. /**
  6069. * Easing function with an exponential shape (see link below).
  6070. * @see https://easings.net/#easeInExpo
  6071. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6072. */
  6073. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6074. /** Defines the exponent of the function */
  6075. exponent: number;
  6076. /**
  6077. * Instantiates an exponential easing function
  6078. * @see https://easings.net/#easeInExpo
  6079. * @param exponent Defines the exponent of the function
  6080. */
  6081. constructor(
  6082. /** Defines the exponent of the function */
  6083. exponent?: number);
  6084. /** @hidden */
  6085. easeInCore(gradient: number): number;
  6086. }
  6087. /**
  6088. * Easing function with a power shape (see link below).
  6089. * @see https://easings.net/#easeInQuad
  6090. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6091. */
  6092. export class PowerEase extends EasingFunction implements IEasingFunction {
  6093. /** Defines the power of the function */
  6094. power: number;
  6095. /**
  6096. * Instantiates an power base easing function
  6097. * @see https://easings.net/#easeInQuad
  6098. * @param power Defines the power of the function
  6099. */
  6100. constructor(
  6101. /** Defines the power of the function */
  6102. power?: number);
  6103. /** @hidden */
  6104. easeInCore(gradient: number): number;
  6105. }
  6106. /**
  6107. * Easing function with a power of 2 shape (see link below).
  6108. * @see https://easings.net/#easeInQuad
  6109. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6112. /** @hidden */
  6113. easeInCore(gradient: number): number;
  6114. }
  6115. /**
  6116. * Easing function with a power of 4 shape (see link below).
  6117. * @see https://easings.net/#easeInQuart
  6118. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6119. */
  6120. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6121. /** @hidden */
  6122. easeInCore(gradient: number): number;
  6123. }
  6124. /**
  6125. * Easing function with a power of 5 shape (see link below).
  6126. * @see https://easings.net/#easeInQuint
  6127. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6128. */
  6129. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6130. /** @hidden */
  6131. easeInCore(gradient: number): number;
  6132. }
  6133. /**
  6134. * Easing function with a sin shape (see link below).
  6135. * @see https://easings.net/#easeInSine
  6136. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6137. */
  6138. export class SineEase extends EasingFunction implements IEasingFunction {
  6139. /** @hidden */
  6140. easeInCore(gradient: number): number;
  6141. }
  6142. /**
  6143. * Easing function with a bezier shape (see link below).
  6144. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6145. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6146. */
  6147. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6148. /** Defines the x component of the start tangent in the bezier curve */
  6149. x1: number;
  6150. /** Defines the y component of the start tangent in the bezier curve */
  6151. y1: number;
  6152. /** Defines the x component of the end tangent in the bezier curve */
  6153. x2: number;
  6154. /** Defines the y component of the end tangent in the bezier curve */
  6155. y2: number;
  6156. /**
  6157. * Instantiates a bezier function
  6158. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6159. * @param x1 Defines the x component of the start tangent in the bezier curve
  6160. * @param y1 Defines the y component of the start tangent in the bezier curve
  6161. * @param x2 Defines the x component of the end tangent in the bezier curve
  6162. * @param y2 Defines the y component of the end tangent in the bezier curve
  6163. */
  6164. constructor(
  6165. /** Defines the x component of the start tangent in the bezier curve */
  6166. x1?: number,
  6167. /** Defines the y component of the start tangent in the bezier curve */
  6168. y1?: number,
  6169. /** Defines the x component of the end tangent in the bezier curve */
  6170. x2?: number,
  6171. /** Defines the y component of the end tangent in the bezier curve */
  6172. y2?: number);
  6173. /** @hidden */
  6174. easeInCore(gradient: number): number;
  6175. }
  6176. }
  6177. declare module BABYLON {
  6178. /**
  6179. * Class used to hold a RGB color
  6180. */
  6181. export class Color3 {
  6182. /**
  6183. * Defines the red component (between 0 and 1, default is 0)
  6184. */
  6185. r: number;
  6186. /**
  6187. * Defines the green component (between 0 and 1, default is 0)
  6188. */
  6189. g: number;
  6190. /**
  6191. * Defines the blue component (between 0 and 1, default is 0)
  6192. */
  6193. b: number;
  6194. /**
  6195. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6196. * @param r defines the red component (between 0 and 1, default is 0)
  6197. * @param g defines the green component (between 0 and 1, default is 0)
  6198. * @param b defines the blue component (between 0 and 1, default is 0)
  6199. */
  6200. constructor(
  6201. /**
  6202. * Defines the red component (between 0 and 1, default is 0)
  6203. */
  6204. r?: number,
  6205. /**
  6206. * Defines the green component (between 0 and 1, default is 0)
  6207. */
  6208. g?: number,
  6209. /**
  6210. * Defines the blue component (between 0 and 1, default is 0)
  6211. */
  6212. b?: number);
  6213. /**
  6214. * Creates a string with the Color3 current values
  6215. * @returns the string representation of the Color3 object
  6216. */
  6217. toString(): string;
  6218. /**
  6219. * Returns the string "Color3"
  6220. * @returns "Color3"
  6221. */
  6222. getClassName(): string;
  6223. /**
  6224. * Compute the Color3 hash code
  6225. * @returns an unique number that can be used to hash Color3 objects
  6226. */
  6227. getHashCode(): number;
  6228. /**
  6229. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6230. * @param array defines the array where to store the r,g,b components
  6231. * @param index defines an optional index in the target array to define where to start storing values
  6232. * @returns the current Color3 object
  6233. */
  6234. toArray(array: FloatArray, index?: number): Color3;
  6235. /**
  6236. * Update the current color with values stored in an array from the starting index of the given array
  6237. * @param array defines the source array
  6238. * @param offset defines an offset in the source array
  6239. * @returns the current Color3 object
  6240. */
  6241. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6242. /**
  6243. * Returns a new Color4 object from the current Color3 and the given alpha
  6244. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6245. * @returns a new Color4 object
  6246. */
  6247. toColor4(alpha?: number): Color4;
  6248. /**
  6249. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6250. * @returns the new array
  6251. */
  6252. asArray(): number[];
  6253. /**
  6254. * Returns the luminance value
  6255. * @returns a float value
  6256. */
  6257. toLuminance(): number;
  6258. /**
  6259. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6260. * @param otherColor defines the second operand
  6261. * @returns the new Color3 object
  6262. */
  6263. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6264. /**
  6265. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6266. * @param otherColor defines the second operand
  6267. * @param result defines the Color3 object where to store the result
  6268. * @returns the current Color3
  6269. */
  6270. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6271. /**
  6272. * Determines equality between Color3 objects
  6273. * @param otherColor defines the second operand
  6274. * @returns true if the rgb values are equal to the given ones
  6275. */
  6276. equals(otherColor: DeepImmutable<Color3>): boolean;
  6277. /**
  6278. * Determines equality between the current Color3 object and a set of r,b,g values
  6279. * @param r defines the red component to check
  6280. * @param g defines the green component to check
  6281. * @param b defines the blue component to check
  6282. * @returns true if the rgb values are equal to the given ones
  6283. */
  6284. equalsFloats(r: number, g: number, b: number): boolean;
  6285. /**
  6286. * Multiplies in place each rgb value by scale
  6287. * @param scale defines the scaling factor
  6288. * @returns the updated Color3
  6289. */
  6290. scale(scale: number): Color3;
  6291. /**
  6292. * Multiplies the rgb values by scale and stores the result into "result"
  6293. * @param scale defines the scaling factor
  6294. * @param result defines the Color3 object where to store the result
  6295. * @returns the unmodified current Color3
  6296. */
  6297. scaleToRef(scale: number, result: Color3): Color3;
  6298. /**
  6299. * Scale the current Color3 values by a factor and add the result to a given Color3
  6300. * @param scale defines the scale factor
  6301. * @param result defines color to store the result into
  6302. * @returns the unmodified current Color3
  6303. */
  6304. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6305. /**
  6306. * Clamps the rgb values by the min and max values and stores the result into "result"
  6307. * @param min defines minimum clamping value (default is 0)
  6308. * @param max defines maximum clamping value (default is 1)
  6309. * @param result defines color to store the result into
  6310. * @returns the original Color3
  6311. */
  6312. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6313. /**
  6314. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6315. * @param otherColor defines the second operand
  6316. * @returns the new Color3
  6317. */
  6318. add(otherColor: DeepImmutable<Color3>): Color3;
  6319. /**
  6320. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6321. * @param otherColor defines the second operand
  6322. * @param result defines Color3 object to store the result into
  6323. * @returns the unmodified current Color3
  6324. */
  6325. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6326. /**
  6327. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6328. * @param otherColor defines the second operand
  6329. * @returns the new Color3
  6330. */
  6331. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6332. /**
  6333. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6334. * @param otherColor defines the second operand
  6335. * @param result defines Color3 object to store the result into
  6336. * @returns the unmodified current Color3
  6337. */
  6338. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6339. /**
  6340. * Copy the current object
  6341. * @returns a new Color3 copied the current one
  6342. */
  6343. clone(): Color3;
  6344. /**
  6345. * Copies the rgb values from the source in the current Color3
  6346. * @param source defines the source Color3 object
  6347. * @returns the updated Color3 object
  6348. */
  6349. copyFrom(source: DeepImmutable<Color3>): Color3;
  6350. /**
  6351. * Updates the Color3 rgb values from the given floats
  6352. * @param r defines the red component to read from
  6353. * @param g defines the green component to read from
  6354. * @param b defines the blue component to read from
  6355. * @returns the current Color3 object
  6356. */
  6357. copyFromFloats(r: number, g: number, b: number): Color3;
  6358. /**
  6359. * Updates the Color3 rgb values from the given floats
  6360. * @param r defines the red component to read from
  6361. * @param g defines the green component to read from
  6362. * @param b defines the blue component to read from
  6363. * @returns the current Color3 object
  6364. */
  6365. set(r: number, g: number, b: number): Color3;
  6366. /**
  6367. * Compute the Color3 hexadecimal code as a string
  6368. * @returns a string containing the hexadecimal representation of the Color3 object
  6369. */
  6370. toHexString(): string;
  6371. /**
  6372. * Computes a new Color3 converted from the current one to linear space
  6373. * @returns a new Color3 object
  6374. */
  6375. toLinearSpace(): Color3;
  6376. /**
  6377. * Converts current color in rgb space to HSV values
  6378. * @returns a new color3 representing the HSV values
  6379. */
  6380. toHSV(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @param result defines the Color3 where to store the HSV values
  6384. */
  6385. toHSVToRef(result: Color3): void;
  6386. /**
  6387. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6388. * @param convertedColor defines the Color3 object where to store the linear space version
  6389. * @returns the unmodified Color3
  6390. */
  6391. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6392. /**
  6393. * Computes a new Color3 converted from the current one to gamma space
  6394. * @returns a new Color3 object
  6395. */
  6396. toGammaSpace(): Color3;
  6397. /**
  6398. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6399. * @param convertedColor defines the Color3 object where to store the gamma space version
  6400. * @returns the unmodified Color3
  6401. */
  6402. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6403. private static _BlackReadOnly;
  6404. /**
  6405. * Convert Hue, saturation and value to a Color3 (RGB)
  6406. * @param hue defines the hue
  6407. * @param saturation defines the saturation
  6408. * @param value defines the value
  6409. * @param result defines the Color3 where to store the RGB values
  6410. */
  6411. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6412. /**
  6413. * Creates a new Color3 from the string containing valid hexadecimal values
  6414. * @param hex defines a string containing valid hexadecimal values
  6415. * @returns a new Color3 object
  6416. */
  6417. static FromHexString(hex: string): Color3;
  6418. /**
  6419. * Creates a new Color3 from the starting index of the given array
  6420. * @param array defines the source array
  6421. * @param offset defines an offset in the source array
  6422. * @returns a new Color3 object
  6423. */
  6424. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6425. /**
  6426. * Creates a new Color3 from the starting index element of the given array
  6427. * @param array defines the source array to read from
  6428. * @param offset defines the offset in the source array
  6429. * @param result defines the target Color3 object
  6430. */
  6431. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6432. /**
  6433. * Creates a new Color3 from integer values (< 256)
  6434. * @param r defines the red component to read from (value between 0 and 255)
  6435. * @param g defines the green component to read from (value between 0 and 255)
  6436. * @param b defines the blue component to read from (value between 0 and 255)
  6437. * @returns a new Color3 object
  6438. */
  6439. static FromInts(r: number, g: number, b: number): Color3;
  6440. /**
  6441. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6442. * @param start defines the start Color3 value
  6443. * @param end defines the end Color3 value
  6444. * @param amount defines the gradient value between start and end
  6445. * @returns a new Color3 object
  6446. */
  6447. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6448. /**
  6449. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6450. * @param left defines the start value
  6451. * @param right defines the end value
  6452. * @param amount defines the gradient factor
  6453. * @param result defines the Color3 object where to store the result
  6454. */
  6455. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6456. /**
  6457. * Returns a Color3 value containing a red color
  6458. * @returns a new Color3 object
  6459. */
  6460. static Red(): Color3;
  6461. /**
  6462. * Returns a Color3 value containing a green color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Green(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a blue color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Blue(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a black color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Black(): Color3;
  6476. /**
  6477. * Gets a Color3 value containing a black color that must not be updated
  6478. */
  6479. static get BlackReadOnly(): DeepImmutable<Color3>;
  6480. /**
  6481. * Returns a Color3 value containing a white color
  6482. * @returns a new Color3 object
  6483. */
  6484. static White(): Color3;
  6485. /**
  6486. * Returns a Color3 value containing a purple color
  6487. * @returns a new Color3 object
  6488. */
  6489. static Purple(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a magenta color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Magenta(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a yellow color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Yellow(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a gray color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Gray(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a teal color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Teal(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a random color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Random(): Color3;
  6515. }
  6516. /**
  6517. * Class used to hold a RBGA color
  6518. */
  6519. export class Color4 {
  6520. /**
  6521. * Defines the red component (between 0 and 1, default is 0)
  6522. */
  6523. r: number;
  6524. /**
  6525. * Defines the green component (between 0 and 1, default is 0)
  6526. */
  6527. g: number;
  6528. /**
  6529. * Defines the blue component (between 0 and 1, default is 0)
  6530. */
  6531. b: number;
  6532. /**
  6533. * Defines the alpha component (between 0 and 1, default is 1)
  6534. */
  6535. a: number;
  6536. /**
  6537. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6538. * @param r defines the red component (between 0 and 1, default is 0)
  6539. * @param g defines the green component (between 0 and 1, default is 0)
  6540. * @param b defines the blue component (between 0 and 1, default is 0)
  6541. * @param a defines the alpha component (between 0 and 1, default is 1)
  6542. */
  6543. constructor(
  6544. /**
  6545. * Defines the red component (between 0 and 1, default is 0)
  6546. */
  6547. r?: number,
  6548. /**
  6549. * Defines the green component (between 0 and 1, default is 0)
  6550. */
  6551. g?: number,
  6552. /**
  6553. * Defines the blue component (between 0 and 1, default is 0)
  6554. */
  6555. b?: number,
  6556. /**
  6557. * Defines the alpha component (between 0 and 1, default is 1)
  6558. */
  6559. a?: number);
  6560. /**
  6561. * Adds in place the given Color4 values to the current Color4 object
  6562. * @param right defines the second operand
  6563. * @returns the current updated Color4 object
  6564. */
  6565. addInPlace(right: DeepImmutable<Color4>): Color4;
  6566. /**
  6567. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6568. * @returns the new array
  6569. */
  6570. asArray(): number[];
  6571. /**
  6572. * Stores from the starting index in the given array the Color4 successive values
  6573. * @param array defines the array where to store the r,g,b components
  6574. * @param index defines an optional index in the target array to define where to start storing values
  6575. * @returns the current Color4 object
  6576. */
  6577. toArray(array: number[], index?: number): Color4;
  6578. /**
  6579. * Update the current color with values stored in an array from the starting index of the given array
  6580. * @param array defines the source array
  6581. * @param offset defines an offset in the source array
  6582. * @returns the current Color4 object
  6583. */
  6584. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6585. /**
  6586. * Determines equality between Color4 objects
  6587. * @param otherColor defines the second operand
  6588. * @returns true if the rgba values are equal to the given ones
  6589. */
  6590. equals(otherColor: DeepImmutable<Color4>): boolean;
  6591. /**
  6592. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6593. * @param right defines the second operand
  6594. * @returns a new Color4 object
  6595. */
  6596. add(right: DeepImmutable<Color4>): Color4;
  6597. /**
  6598. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6599. * @param right defines the second operand
  6600. * @returns a new Color4 object
  6601. */
  6602. subtract(right: DeepImmutable<Color4>): Color4;
  6603. /**
  6604. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6605. * @param right defines the second operand
  6606. * @param result defines the Color4 object where to store the result
  6607. * @returns the current Color4 object
  6608. */
  6609. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6610. /**
  6611. * Creates a new Color4 with the current Color4 values multiplied by scale
  6612. * @param scale defines the scaling factor to apply
  6613. * @returns a new Color4 object
  6614. */
  6615. scale(scale: number): Color4;
  6616. /**
  6617. * Multiplies the current Color4 values by scale and stores the result in "result"
  6618. * @param scale defines the scaling factor to apply
  6619. * @param result defines the Color4 object where to store the result
  6620. * @returns the current unmodified Color4
  6621. */
  6622. scaleToRef(scale: number, result: Color4): Color4;
  6623. /**
  6624. * Scale the current Color4 values by a factor and add the result to a given Color4
  6625. * @param scale defines the scale factor
  6626. * @param result defines the Color4 object where to store the result
  6627. * @returns the unmodified current Color4
  6628. */
  6629. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6630. /**
  6631. * Clamps the rgb values by the min and max values and stores the result into "result"
  6632. * @param min defines minimum clamping value (default is 0)
  6633. * @param max defines maximum clamping value (default is 1)
  6634. * @param result defines color to store the result into.
  6635. * @returns the cuurent Color4
  6636. */
  6637. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6638. /**
  6639. * Multipy an Color4 value by another and return a new Color4 object
  6640. * @param color defines the Color4 value to multiply by
  6641. * @returns a new Color4 object
  6642. */
  6643. multiply(color: Color4): Color4;
  6644. /**
  6645. * Multipy a Color4 value by another and push the result in a reference value
  6646. * @param color defines the Color4 value to multiply by
  6647. * @param result defines the Color4 to fill the result in
  6648. * @returns the result Color4
  6649. */
  6650. multiplyToRef(color: Color4, result: Color4): Color4;
  6651. /**
  6652. * Creates a string with the Color4 current values
  6653. * @returns the string representation of the Color4 object
  6654. */
  6655. toString(): string;
  6656. /**
  6657. * Returns the string "Color4"
  6658. * @returns "Color4"
  6659. */
  6660. getClassName(): string;
  6661. /**
  6662. * Compute the Color4 hash code
  6663. * @returns an unique number that can be used to hash Color4 objects
  6664. */
  6665. getHashCode(): number;
  6666. /**
  6667. * Creates a new Color4 copied from the current one
  6668. * @returns a new Color4 object
  6669. */
  6670. clone(): Color4;
  6671. /**
  6672. * Copies the given Color4 values into the current one
  6673. * @param source defines the source Color4 object
  6674. * @returns the current updated Color4 object
  6675. */
  6676. copyFrom(source: Color4): Color4;
  6677. /**
  6678. * Copies the given float values into the current one
  6679. * @param r defines the red component to read from
  6680. * @param g defines the green component to read from
  6681. * @param b defines the blue component to read from
  6682. * @param a defines the alpha component to read from
  6683. * @returns the current updated Color4 object
  6684. */
  6685. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6686. /**
  6687. * Copies the given float values into the current one
  6688. * @param r defines the red component to read from
  6689. * @param g defines the green component to read from
  6690. * @param b defines the blue component to read from
  6691. * @param a defines the alpha component to read from
  6692. * @returns the current updated Color4 object
  6693. */
  6694. set(r: number, g: number, b: number, a: number): Color4;
  6695. /**
  6696. * Compute the Color4 hexadecimal code as a string
  6697. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6698. * @returns a string containing the hexadecimal representation of the Color4 object
  6699. */
  6700. toHexString(returnAsColor3?: boolean): string;
  6701. /**
  6702. * Computes a new Color4 converted from the current one to linear space
  6703. * @returns a new Color4 object
  6704. */
  6705. toLinearSpace(): Color4;
  6706. /**
  6707. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6708. * @param convertedColor defines the Color4 object where to store the linear space version
  6709. * @returns the unmodified Color4
  6710. */
  6711. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6712. /**
  6713. * Computes a new Color4 converted from the current one to gamma space
  6714. * @returns a new Color4 object
  6715. */
  6716. toGammaSpace(): Color4;
  6717. /**
  6718. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6719. * @param convertedColor defines the Color4 object where to store the gamma space version
  6720. * @returns the unmodified Color4
  6721. */
  6722. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6723. /**
  6724. * Creates a new Color4 from the string containing valid hexadecimal values
  6725. * @param hex defines a string containing valid hexadecimal values
  6726. * @returns a new Color4 object
  6727. */
  6728. static FromHexString(hex: string): Color4;
  6729. /**
  6730. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6731. * @param left defines the start value
  6732. * @param right defines the end value
  6733. * @param amount defines the gradient factor
  6734. * @returns a new Color4 object
  6735. */
  6736. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6737. /**
  6738. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6739. * @param left defines the start value
  6740. * @param right defines the end value
  6741. * @param amount defines the gradient factor
  6742. * @param result defines the Color4 object where to store data
  6743. */
  6744. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6745. /**
  6746. * Creates a new Color4 from a Color3 and an alpha value
  6747. * @param color3 defines the source Color3 to read from
  6748. * @param alpha defines the alpha component (1.0 by default)
  6749. * @returns a new Color4 object
  6750. */
  6751. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6752. /**
  6753. * Creates a new Color4 from the starting index element of the given array
  6754. * @param array defines the source array to read from
  6755. * @param offset defines the offset in the source array
  6756. * @returns a new Color4 object
  6757. */
  6758. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6759. /**
  6760. * Creates a new Color4 from the starting index element of the given array
  6761. * @param array defines the source array to read from
  6762. * @param offset defines the offset in the source array
  6763. * @param result defines the target Color4 object
  6764. */
  6765. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6766. /**
  6767. * Creates a new Color3 from integer values (< 256)
  6768. * @param r defines the red component to read from (value between 0 and 255)
  6769. * @param g defines the green component to read from (value between 0 and 255)
  6770. * @param b defines the blue component to read from (value between 0 and 255)
  6771. * @param a defines the alpha component to read from (value between 0 and 255)
  6772. * @returns a new Color3 object
  6773. */
  6774. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6775. /**
  6776. * Check the content of a given array and convert it to an array containing RGBA data
  6777. * If the original array was already containing count * 4 values then it is returned directly
  6778. * @param colors defines the array to check
  6779. * @param count defines the number of RGBA data to expect
  6780. * @returns an array containing count * 4 values (RGBA)
  6781. */
  6782. static CheckColors4(colors: number[], count: number): number[];
  6783. }
  6784. /**
  6785. * @hidden
  6786. */
  6787. export class TmpColors {
  6788. static Color3: Color3[];
  6789. static Color4: Color4[];
  6790. }
  6791. }
  6792. declare module BABYLON {
  6793. /**
  6794. * Defines an interface which represents an animation key frame
  6795. */
  6796. export interface IAnimationKey {
  6797. /**
  6798. * Frame of the key frame
  6799. */
  6800. frame: number;
  6801. /**
  6802. * Value at the specifies key frame
  6803. */
  6804. value: any;
  6805. /**
  6806. * The input tangent for the cubic hermite spline
  6807. */
  6808. inTangent?: any;
  6809. /**
  6810. * The output tangent for the cubic hermite spline
  6811. */
  6812. outTangent?: any;
  6813. /**
  6814. * The animation interpolation type
  6815. */
  6816. interpolation?: AnimationKeyInterpolation;
  6817. }
  6818. /**
  6819. * Enum for the animation key frame interpolation type
  6820. */
  6821. export enum AnimationKeyInterpolation {
  6822. /**
  6823. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6824. */
  6825. STEP = 1
  6826. }
  6827. }
  6828. declare module BABYLON {
  6829. /**
  6830. * Represents the range of an animation
  6831. */
  6832. export class AnimationRange {
  6833. /**The name of the animation range**/
  6834. name: string;
  6835. /**The starting frame of the animation */
  6836. from: number;
  6837. /**The ending frame of the animation*/
  6838. to: number;
  6839. /**
  6840. * Initializes the range of an animation
  6841. * @param name The name of the animation range
  6842. * @param from The starting frame of the animation
  6843. * @param to The ending frame of the animation
  6844. */
  6845. constructor(
  6846. /**The name of the animation range**/
  6847. name: string,
  6848. /**The starting frame of the animation */
  6849. from: number,
  6850. /**The ending frame of the animation*/
  6851. to: number);
  6852. /**
  6853. * Makes a copy of the animation range
  6854. * @returns A copy of the animation range
  6855. */
  6856. clone(): AnimationRange;
  6857. }
  6858. }
  6859. declare module BABYLON {
  6860. /**
  6861. * Composed of a frame, and an action function
  6862. */
  6863. export class AnimationEvent {
  6864. /** The frame for which the event is triggered **/
  6865. frame: number;
  6866. /** The event to perform when triggered **/
  6867. action: (currentFrame: number) => void;
  6868. /** Specifies if the event should be triggered only once**/
  6869. onlyOnce?: boolean | undefined;
  6870. /**
  6871. * Specifies if the animation event is done
  6872. */
  6873. isDone: boolean;
  6874. /**
  6875. * Initializes the animation event
  6876. * @param frame The frame for which the event is triggered
  6877. * @param action The event to perform when triggered
  6878. * @param onlyOnce Specifies if the event should be triggered only once
  6879. */
  6880. constructor(
  6881. /** The frame for which the event is triggered **/
  6882. frame: number,
  6883. /** The event to perform when triggered **/
  6884. action: (currentFrame: number) => void,
  6885. /** Specifies if the event should be triggered only once**/
  6886. onlyOnce?: boolean | undefined);
  6887. /** @hidden */
  6888. _clone(): AnimationEvent;
  6889. }
  6890. }
  6891. declare module BABYLON {
  6892. /**
  6893. * Interface used to define a behavior
  6894. */
  6895. export interface Behavior<T> {
  6896. /** gets or sets behavior's name */
  6897. name: string;
  6898. /**
  6899. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6900. */
  6901. init(): void;
  6902. /**
  6903. * Called when the behavior is attached to a target
  6904. * @param target defines the target where the behavior is attached to
  6905. */
  6906. attach(target: T): void;
  6907. /**
  6908. * Called when the behavior is detached from its target
  6909. */
  6910. detach(): void;
  6911. }
  6912. /**
  6913. * Interface implemented by classes supporting behaviors
  6914. */
  6915. export interface IBehaviorAware<T> {
  6916. /**
  6917. * Attach a behavior
  6918. * @param behavior defines the behavior to attach
  6919. * @returns the current host
  6920. */
  6921. addBehavior(behavior: Behavior<T>): T;
  6922. /**
  6923. * Remove a behavior from the current object
  6924. * @param behavior defines the behavior to detach
  6925. * @returns the current host
  6926. */
  6927. removeBehavior(behavior: Behavior<T>): T;
  6928. /**
  6929. * Gets a behavior using its name to search
  6930. * @param name defines the name to search
  6931. * @returns the behavior or null if not found
  6932. */
  6933. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6934. }
  6935. }
  6936. declare module BABYLON {
  6937. /**
  6938. * Class used to store data that will be store in GPU memory
  6939. */
  6940. export class Buffer {
  6941. private _engine;
  6942. private _buffer;
  6943. /** @hidden */
  6944. _data: Nullable<DataArray>;
  6945. private _updatable;
  6946. private _instanced;
  6947. private _divisor;
  6948. private _isAlreadyOwned;
  6949. /**
  6950. * Gets the byte stride.
  6951. */
  6952. readonly byteStride: number;
  6953. /**
  6954. * Constructor
  6955. * @param engine the engine
  6956. * @param data the data to use for this buffer
  6957. * @param updatable whether the data is updatable
  6958. * @param stride the stride (optional)
  6959. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6960. * @param instanced whether the buffer is instanced (optional)
  6961. * @param useBytes set to true if the stride in in bytes (optional)
  6962. * @param divisor sets an optional divisor for instances (1 by default)
  6963. */
  6964. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6965. /**
  6966. * Create a new VertexBuffer based on the current buffer
  6967. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6968. * @param offset defines offset in the buffer (0 by default)
  6969. * @param size defines the size in floats of attributes (position is 3 for instance)
  6970. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6971. * @param instanced defines if the vertex buffer contains indexed data
  6972. * @param useBytes defines if the offset and stride are in bytes *
  6973. * @param divisor sets an optional divisor for instances (1 by default)
  6974. * @returns the new vertex buffer
  6975. */
  6976. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6977. /**
  6978. * Gets a boolean indicating if the Buffer is updatable?
  6979. * @returns true if the buffer is updatable
  6980. */
  6981. isUpdatable(): boolean;
  6982. /**
  6983. * Gets current buffer's data
  6984. * @returns a DataArray or null
  6985. */
  6986. getData(): Nullable<DataArray>;
  6987. /**
  6988. * Gets underlying native buffer
  6989. * @returns underlying native buffer
  6990. */
  6991. getBuffer(): Nullable<DataBuffer>;
  6992. /**
  6993. * Gets the stride in float32 units (i.e. byte stride / 4).
  6994. * May not be an integer if the byte stride is not divisible by 4.
  6995. * @returns the stride in float32 units
  6996. * @deprecated Please use byteStride instead.
  6997. */
  6998. getStrideSize(): number;
  6999. /**
  7000. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7001. * @param data defines the data to store
  7002. */
  7003. create(data?: Nullable<DataArray>): void;
  7004. /** @hidden */
  7005. _rebuild(): void;
  7006. /**
  7007. * Update current buffer data
  7008. * @param data defines the data to store
  7009. */
  7010. update(data: DataArray): void;
  7011. /**
  7012. * Updates the data directly.
  7013. * @param data the new data
  7014. * @param offset the new offset
  7015. * @param vertexCount the vertex count (optional)
  7016. * @param useBytes set to true if the offset is in bytes
  7017. */
  7018. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7019. /** @hidden */
  7020. _increaseReferences(): void;
  7021. /**
  7022. * Release all resources
  7023. */
  7024. dispose(): void;
  7025. }
  7026. /**
  7027. * Specialized buffer used to store vertex data
  7028. */
  7029. export class VertexBuffer {
  7030. private static _Counter;
  7031. /** @hidden */
  7032. _buffer: Buffer;
  7033. private _kind;
  7034. private _size;
  7035. private _ownsBuffer;
  7036. private _instanced;
  7037. private _instanceDivisor;
  7038. /**
  7039. * The byte type.
  7040. */
  7041. static readonly BYTE: number;
  7042. /**
  7043. * The unsigned byte type.
  7044. */
  7045. static readonly UNSIGNED_BYTE: number;
  7046. /**
  7047. * The short type.
  7048. */
  7049. static readonly SHORT: number;
  7050. /**
  7051. * The unsigned short type.
  7052. */
  7053. static readonly UNSIGNED_SHORT: number;
  7054. /**
  7055. * The integer type.
  7056. */
  7057. static readonly INT: number;
  7058. /**
  7059. * The unsigned integer type.
  7060. */
  7061. static readonly UNSIGNED_INT: number;
  7062. /**
  7063. * The float type.
  7064. */
  7065. static readonly FLOAT: number;
  7066. /**
  7067. * Gets or sets the instance divisor when in instanced mode
  7068. */
  7069. get instanceDivisor(): number;
  7070. set instanceDivisor(value: number);
  7071. /**
  7072. * Gets the byte stride.
  7073. */
  7074. readonly byteStride: number;
  7075. /**
  7076. * Gets the byte offset.
  7077. */
  7078. readonly byteOffset: number;
  7079. /**
  7080. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7081. */
  7082. readonly normalized: boolean;
  7083. /**
  7084. * Gets the data type of each component in the array.
  7085. */
  7086. readonly type: number;
  7087. /**
  7088. * Gets the unique id of this vertex buffer
  7089. */
  7090. readonly uniqueId: number;
  7091. /**
  7092. * Constructor
  7093. * @param engine the engine
  7094. * @param data the data to use for this vertex buffer
  7095. * @param kind the vertex buffer kind
  7096. * @param updatable whether the data is updatable
  7097. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7098. * @param stride the stride (optional)
  7099. * @param instanced whether the buffer is instanced (optional)
  7100. * @param offset the offset of the data (optional)
  7101. * @param size the number of components (optional)
  7102. * @param type the type of the component (optional)
  7103. * @param normalized whether the data contains normalized data (optional)
  7104. * @param useBytes set to true if stride and offset are in bytes (optional)
  7105. * @param divisor defines the instance divisor to use (1 by default)
  7106. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7107. */
  7108. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  7109. /** @hidden */
  7110. _rebuild(): void;
  7111. /**
  7112. * Returns the kind of the VertexBuffer (string)
  7113. * @returns a string
  7114. */
  7115. getKind(): string;
  7116. /**
  7117. * Gets a boolean indicating if the VertexBuffer is updatable?
  7118. * @returns true if the buffer is updatable
  7119. */
  7120. isUpdatable(): boolean;
  7121. /**
  7122. * Gets current buffer's data
  7123. * @returns a DataArray or null
  7124. */
  7125. getData(): Nullable<DataArray>;
  7126. /**
  7127. * Gets underlying native buffer
  7128. * @returns underlying native buffer
  7129. */
  7130. getBuffer(): Nullable<DataBuffer>;
  7131. /**
  7132. * Gets the stride in float32 units (i.e. byte stride / 4).
  7133. * May not be an integer if the byte stride is not divisible by 4.
  7134. * @returns the stride in float32 units
  7135. * @deprecated Please use byteStride instead.
  7136. */
  7137. getStrideSize(): number;
  7138. /**
  7139. * Returns the offset as a multiple of the type byte length.
  7140. * @returns the offset in bytes
  7141. * @deprecated Please use byteOffset instead.
  7142. */
  7143. getOffset(): number;
  7144. /**
  7145. * Returns the number of components per vertex attribute (integer)
  7146. * @returns the size in float
  7147. */
  7148. getSize(): number;
  7149. /**
  7150. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7151. * @returns true if this buffer is instanced
  7152. */
  7153. getIsInstanced(): boolean;
  7154. /**
  7155. * Returns the instancing divisor, zero for non-instanced (integer).
  7156. * @returns a number
  7157. */
  7158. getInstanceDivisor(): number;
  7159. /**
  7160. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7161. * @param data defines the data to store
  7162. */
  7163. create(data?: DataArray): void;
  7164. /**
  7165. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7166. * This function will create a new buffer if the current one is not updatable
  7167. * @param data defines the data to store
  7168. */
  7169. update(data: DataArray): void;
  7170. /**
  7171. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7172. * Returns the directly updated WebGLBuffer.
  7173. * @param data the new data
  7174. * @param offset the new offset
  7175. * @param useBytes set to true if the offset is in bytes
  7176. */
  7177. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7178. /**
  7179. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7180. */
  7181. dispose(): void;
  7182. /**
  7183. * Enumerates each value of this vertex buffer as numbers.
  7184. * @param count the number of values to enumerate
  7185. * @param callback the callback function called for each value
  7186. */
  7187. forEach(count: number, callback: (value: number, index: number) => void): void;
  7188. /**
  7189. * Positions
  7190. */
  7191. static readonly PositionKind: string;
  7192. /**
  7193. * Normals
  7194. */
  7195. static readonly NormalKind: string;
  7196. /**
  7197. * Tangents
  7198. */
  7199. static readonly TangentKind: string;
  7200. /**
  7201. * Texture coordinates
  7202. */
  7203. static readonly UVKind: string;
  7204. /**
  7205. * Texture coordinates 2
  7206. */
  7207. static readonly UV2Kind: string;
  7208. /**
  7209. * Texture coordinates 3
  7210. */
  7211. static readonly UV3Kind: string;
  7212. /**
  7213. * Texture coordinates 4
  7214. */
  7215. static readonly UV4Kind: string;
  7216. /**
  7217. * Texture coordinates 5
  7218. */
  7219. static readonly UV5Kind: string;
  7220. /**
  7221. * Texture coordinates 6
  7222. */
  7223. static readonly UV6Kind: string;
  7224. /**
  7225. * Colors
  7226. */
  7227. static readonly ColorKind: string;
  7228. /**
  7229. * Matrix indices (for bones)
  7230. */
  7231. static readonly MatricesIndicesKind: string;
  7232. /**
  7233. * Matrix weights (for bones)
  7234. */
  7235. static readonly MatricesWeightsKind: string;
  7236. /**
  7237. * Additional matrix indices (for bones)
  7238. */
  7239. static readonly MatricesIndicesExtraKind: string;
  7240. /**
  7241. * Additional matrix weights (for bones)
  7242. */
  7243. static readonly MatricesWeightsExtraKind: string;
  7244. /**
  7245. * Deduces the stride given a kind.
  7246. * @param kind The kind string to deduce
  7247. * @returns The deduced stride
  7248. */
  7249. static DeduceStride(kind: string): number;
  7250. /**
  7251. * Gets the byte length of the given type.
  7252. * @param type the type
  7253. * @returns the number of bytes
  7254. */
  7255. static GetTypeByteLength(type: number): number;
  7256. /**
  7257. * Enumerates each value of the given parameters as numbers.
  7258. * @param data the data to enumerate
  7259. * @param byteOffset the byte offset of the data
  7260. * @param byteStride the byte stride of the data
  7261. * @param componentCount the number of components per element
  7262. * @param componentType the type of the component
  7263. * @param count the number of values to enumerate
  7264. * @param normalized whether the data is normalized
  7265. * @param callback the callback function called for each value
  7266. */
  7267. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7268. private static _GetFloatValue;
  7269. }
  7270. }
  7271. declare module BABYLON {
  7272. /**
  7273. * @hidden
  7274. */
  7275. export class IntersectionInfo {
  7276. bu: Nullable<number>;
  7277. bv: Nullable<number>;
  7278. distance: number;
  7279. faceId: number;
  7280. subMeshId: number;
  7281. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7282. }
  7283. }
  7284. declare module BABYLON {
  7285. /**
  7286. * Class used to store bounding sphere information
  7287. */
  7288. export class BoundingSphere {
  7289. /**
  7290. * Gets the center of the bounding sphere in local space
  7291. */
  7292. readonly center: Vector3;
  7293. /**
  7294. * Radius of the bounding sphere in local space
  7295. */
  7296. radius: number;
  7297. /**
  7298. * Gets the center of the bounding sphere in world space
  7299. */
  7300. readonly centerWorld: Vector3;
  7301. /**
  7302. * Radius of the bounding sphere in world space
  7303. */
  7304. radiusWorld: number;
  7305. /**
  7306. * Gets the minimum vector in local space
  7307. */
  7308. readonly minimum: Vector3;
  7309. /**
  7310. * Gets the maximum vector in local space
  7311. */
  7312. readonly maximum: Vector3;
  7313. private _worldMatrix;
  7314. private static readonly TmpVector3;
  7315. /**
  7316. * Creates a new bounding sphere
  7317. * @param min defines the minimum vector (in local space)
  7318. * @param max defines the maximum vector (in local space)
  7319. * @param worldMatrix defines the new world matrix
  7320. */
  7321. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7322. /**
  7323. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7324. * @param min defines the new minimum vector (in local space)
  7325. * @param max defines the new maximum vector (in local space)
  7326. * @param worldMatrix defines the new world matrix
  7327. */
  7328. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7329. /**
  7330. * Scale the current bounding sphere by applying a scale factor
  7331. * @param factor defines the scale factor to apply
  7332. * @returns the current bounding box
  7333. */
  7334. scale(factor: number): BoundingSphere;
  7335. /**
  7336. * Gets the world matrix of the bounding box
  7337. * @returns a matrix
  7338. */
  7339. getWorldMatrix(): DeepImmutable<Matrix>;
  7340. /** @hidden */
  7341. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7342. /**
  7343. * Tests if the bounding sphere is intersecting the frustum planes
  7344. * @param frustumPlanes defines the frustum planes to test
  7345. * @returns true if there is an intersection
  7346. */
  7347. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7348. /**
  7349. * Tests if the bounding sphere center is in between the frustum planes.
  7350. * Used for optimistic fast inclusion.
  7351. * @param frustumPlanes defines the frustum planes to test
  7352. * @returns true if the sphere center is in between the frustum planes
  7353. */
  7354. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7355. /**
  7356. * Tests if a point is inside the bounding sphere
  7357. * @param point defines the point to test
  7358. * @returns true if the point is inside the bounding sphere
  7359. */
  7360. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7361. /**
  7362. * Checks if two sphere intersct
  7363. * @param sphere0 sphere 0
  7364. * @param sphere1 sphere 1
  7365. * @returns true if the speres intersect
  7366. */
  7367. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7368. }
  7369. }
  7370. declare module BABYLON {
  7371. /**
  7372. * Class used to store bounding box information
  7373. */
  7374. export class BoundingBox implements ICullable {
  7375. /**
  7376. * Gets the 8 vectors representing the bounding box in local space
  7377. */
  7378. readonly vectors: Vector3[];
  7379. /**
  7380. * Gets the center of the bounding box in local space
  7381. */
  7382. readonly center: Vector3;
  7383. /**
  7384. * Gets the center of the bounding box in world space
  7385. */
  7386. readonly centerWorld: Vector3;
  7387. /**
  7388. * Gets the extend size in local space
  7389. */
  7390. readonly extendSize: Vector3;
  7391. /**
  7392. * Gets the extend size in world space
  7393. */
  7394. readonly extendSizeWorld: Vector3;
  7395. /**
  7396. * Gets the OBB (object bounding box) directions
  7397. */
  7398. readonly directions: Vector3[];
  7399. /**
  7400. * Gets the 8 vectors representing the bounding box in world space
  7401. */
  7402. readonly vectorsWorld: Vector3[];
  7403. /**
  7404. * Gets the minimum vector in world space
  7405. */
  7406. readonly minimumWorld: Vector3;
  7407. /**
  7408. * Gets the maximum vector in world space
  7409. */
  7410. readonly maximumWorld: Vector3;
  7411. /**
  7412. * Gets the minimum vector in local space
  7413. */
  7414. readonly minimum: Vector3;
  7415. /**
  7416. * Gets the maximum vector in local space
  7417. */
  7418. readonly maximum: Vector3;
  7419. private _worldMatrix;
  7420. private static readonly TmpVector3;
  7421. /**
  7422. * @hidden
  7423. */
  7424. _tag: number;
  7425. /**
  7426. * Creates a new bounding box
  7427. * @param min defines the minimum vector (in local space)
  7428. * @param max defines the maximum vector (in local space)
  7429. * @param worldMatrix defines the new world matrix
  7430. */
  7431. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7432. /**
  7433. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7434. * @param min defines the new minimum vector (in local space)
  7435. * @param max defines the new maximum vector (in local space)
  7436. * @param worldMatrix defines the new world matrix
  7437. */
  7438. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7439. /**
  7440. * Scale the current bounding box by applying a scale factor
  7441. * @param factor defines the scale factor to apply
  7442. * @returns the current bounding box
  7443. */
  7444. scale(factor: number): BoundingBox;
  7445. /**
  7446. * Gets the world matrix of the bounding box
  7447. * @returns a matrix
  7448. */
  7449. getWorldMatrix(): DeepImmutable<Matrix>;
  7450. /** @hidden */
  7451. _update(world: DeepImmutable<Matrix>): void;
  7452. /**
  7453. * Tests if the bounding box is intersecting the frustum planes
  7454. * @param frustumPlanes defines the frustum planes to test
  7455. * @returns true if there is an intersection
  7456. */
  7457. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7458. /**
  7459. * Tests if the bounding box is entirely inside the frustum planes
  7460. * @param frustumPlanes defines the frustum planes to test
  7461. * @returns true if there is an inclusion
  7462. */
  7463. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7464. /**
  7465. * Tests if a point is inside the bounding box
  7466. * @param point defines the point to test
  7467. * @returns true if the point is inside the bounding box
  7468. */
  7469. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7470. /**
  7471. * Tests if the bounding box intersects with a bounding sphere
  7472. * @param sphere defines the sphere to test
  7473. * @returns true if there is an intersection
  7474. */
  7475. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7476. /**
  7477. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7478. * @param min defines the min vector to use
  7479. * @param max defines the max vector to use
  7480. * @returns true if there is an intersection
  7481. */
  7482. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7483. /**
  7484. * Tests if two bounding boxes are intersections
  7485. * @param box0 defines the first box to test
  7486. * @param box1 defines the second box to test
  7487. * @returns true if there is an intersection
  7488. */
  7489. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7490. /**
  7491. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7492. * @param minPoint defines the minimum vector of the bounding box
  7493. * @param maxPoint defines the maximum vector of the bounding box
  7494. * @param sphereCenter defines the sphere center
  7495. * @param sphereRadius defines the sphere radius
  7496. * @returns true if there is an intersection
  7497. */
  7498. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7499. /**
  7500. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7501. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7502. * @param frustumPlanes defines the frustum planes to test
  7503. * @return true if there is an inclusion
  7504. */
  7505. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7506. /**
  7507. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7508. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7509. * @param frustumPlanes defines the frustum planes to test
  7510. * @return true if there is an intersection
  7511. */
  7512. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7513. }
  7514. }
  7515. declare module BABYLON {
  7516. /** @hidden */
  7517. export class Collider {
  7518. /** Define if a collision was found */
  7519. collisionFound: boolean;
  7520. /**
  7521. * Define last intersection point in local space
  7522. */
  7523. intersectionPoint: Vector3;
  7524. /**
  7525. * Define last collided mesh
  7526. */
  7527. collidedMesh: Nullable<AbstractMesh>;
  7528. private _collisionPoint;
  7529. private _planeIntersectionPoint;
  7530. private _tempVector;
  7531. private _tempVector2;
  7532. private _tempVector3;
  7533. private _tempVector4;
  7534. private _edge;
  7535. private _baseToVertex;
  7536. private _destinationPoint;
  7537. private _slidePlaneNormal;
  7538. private _displacementVector;
  7539. /** @hidden */
  7540. _radius: Vector3;
  7541. /** @hidden */
  7542. _retry: number;
  7543. private _velocity;
  7544. private _basePoint;
  7545. private _epsilon;
  7546. /** @hidden */
  7547. _velocityWorldLength: number;
  7548. /** @hidden */
  7549. _basePointWorld: Vector3;
  7550. private _velocityWorld;
  7551. private _normalizedVelocity;
  7552. /** @hidden */
  7553. _initialVelocity: Vector3;
  7554. /** @hidden */
  7555. _initialPosition: Vector3;
  7556. private _nearestDistance;
  7557. private _collisionMask;
  7558. get collisionMask(): number;
  7559. set collisionMask(mask: number);
  7560. /**
  7561. * Gets the plane normal used to compute the sliding response (in local space)
  7562. */
  7563. get slidePlaneNormal(): Vector3;
  7564. /** @hidden */
  7565. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7566. /** @hidden */
  7567. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7568. /** @hidden */
  7569. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7570. /** @hidden */
  7571. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7572. /** @hidden */
  7573. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7574. /** @hidden */
  7575. _getResponse(pos: Vector3, vel: Vector3): void;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. /**
  7580. * Interface for cullable objects
  7581. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7582. */
  7583. export interface ICullable {
  7584. /**
  7585. * Checks if the object or part of the object is in the frustum
  7586. * @param frustumPlanes Camera near/planes
  7587. * @returns true if the object is in frustum otherwise false
  7588. */
  7589. isInFrustum(frustumPlanes: Plane[]): boolean;
  7590. /**
  7591. * Checks if a cullable object (mesh...) is in the camera frustum
  7592. * Unlike isInFrustum this cheks the full bounding box
  7593. * @param frustumPlanes Camera near/planes
  7594. * @returns true if the object is in frustum otherwise false
  7595. */
  7596. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7597. }
  7598. /**
  7599. * Info for a bounding data of a mesh
  7600. */
  7601. export class BoundingInfo implements ICullable {
  7602. /**
  7603. * Bounding box for the mesh
  7604. */
  7605. readonly boundingBox: BoundingBox;
  7606. /**
  7607. * Bounding sphere for the mesh
  7608. */
  7609. readonly boundingSphere: BoundingSphere;
  7610. private _isLocked;
  7611. private static readonly TmpVector3;
  7612. /**
  7613. * Constructs bounding info
  7614. * @param minimum min vector of the bounding box/sphere
  7615. * @param maximum max vector of the bounding box/sphere
  7616. * @param worldMatrix defines the new world matrix
  7617. */
  7618. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7619. /**
  7620. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7621. * @param min defines the new minimum vector (in local space)
  7622. * @param max defines the new maximum vector (in local space)
  7623. * @param worldMatrix defines the new world matrix
  7624. */
  7625. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7626. /**
  7627. * min vector of the bounding box/sphere
  7628. */
  7629. get minimum(): Vector3;
  7630. /**
  7631. * max vector of the bounding box/sphere
  7632. */
  7633. get maximum(): Vector3;
  7634. /**
  7635. * If the info is locked and won't be updated to avoid perf overhead
  7636. */
  7637. get isLocked(): boolean;
  7638. set isLocked(value: boolean);
  7639. /**
  7640. * Updates the bounding sphere and box
  7641. * @param world world matrix to be used to update
  7642. */
  7643. update(world: DeepImmutable<Matrix>): void;
  7644. /**
  7645. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7646. * @param center New center of the bounding info
  7647. * @param extend New extend of the bounding info
  7648. * @returns the current bounding info
  7649. */
  7650. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7651. /**
  7652. * Scale the current bounding info by applying a scale factor
  7653. * @param factor defines the scale factor to apply
  7654. * @returns the current bounding info
  7655. */
  7656. scale(factor: number): BoundingInfo;
  7657. /**
  7658. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7659. * @param frustumPlanes defines the frustum to test
  7660. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7661. * @returns true if the bounding info is in the frustum planes
  7662. */
  7663. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7664. /**
  7665. * Gets the world distance between the min and max points of the bounding box
  7666. */
  7667. get diagonalLength(): number;
  7668. /**
  7669. * Checks if a cullable object (mesh...) is in the camera frustum
  7670. * Unlike isInFrustum this cheks the full bounding box
  7671. * @param frustumPlanes Camera near/planes
  7672. * @returns true if the object is in frustum otherwise false
  7673. */
  7674. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7675. /** @hidden */
  7676. _checkCollision(collider: Collider): boolean;
  7677. /**
  7678. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7679. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7680. * @param point the point to check intersection with
  7681. * @returns if the point intersects
  7682. */
  7683. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7684. /**
  7685. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7686. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7687. * @param boundingInfo the bounding info to check intersection with
  7688. * @param precise if the intersection should be done using OBB
  7689. * @returns if the bounding info intersects
  7690. */
  7691. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7692. }
  7693. }
  7694. declare module BABYLON {
  7695. /**
  7696. * Extracts minimum and maximum values from a list of indexed positions
  7697. * @param positions defines the positions to use
  7698. * @param indices defines the indices to the positions
  7699. * @param indexStart defines the start index
  7700. * @param indexCount defines the end index
  7701. * @param bias defines bias value to add to the result
  7702. * @return minimum and maximum values
  7703. */
  7704. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7705. minimum: Vector3;
  7706. maximum: Vector3;
  7707. };
  7708. /**
  7709. * Extracts minimum and maximum values from a list of positions
  7710. * @param positions defines the positions to use
  7711. * @param start defines the start index in the positions array
  7712. * @param count defines the number of positions to handle
  7713. * @param bias defines bias value to add to the result
  7714. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7715. * @return minimum and maximum values
  7716. */
  7717. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7718. minimum: Vector3;
  7719. maximum: Vector3;
  7720. };
  7721. }
  7722. declare module BABYLON {
  7723. /**
  7724. * Class used to manipulate GUIDs
  7725. */
  7726. export class GUID {
  7727. /**
  7728. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7729. * Be aware Math.random() could cause collisions, but:
  7730. * "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"
  7731. * @returns a pseudo random id
  7732. */
  7733. static RandomId(): string;
  7734. }
  7735. }
  7736. declare module BABYLON {
  7737. /**
  7738. * Base class of all the textures in babylon.
  7739. * It groups all the common properties the materials, post process, lights... might need
  7740. * in order to make a correct use of the texture.
  7741. */
  7742. export class BaseTexture extends ThinTexture implements IAnimatable {
  7743. /**
  7744. * Default anisotropic filtering level for the application.
  7745. * It is set to 4 as a good tradeoff between perf and quality.
  7746. */
  7747. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7748. /**
  7749. * Gets or sets the unique id of the texture
  7750. */
  7751. uniqueId: number;
  7752. /**
  7753. * Define the name of the texture.
  7754. */
  7755. name: string;
  7756. /**
  7757. * Gets or sets an object used to store user defined information.
  7758. */
  7759. metadata: any;
  7760. /**
  7761. * For internal use only. Please do not use.
  7762. */
  7763. reservedDataStore: any;
  7764. private _hasAlpha;
  7765. /**
  7766. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7767. */
  7768. set hasAlpha(value: boolean);
  7769. get hasAlpha(): boolean;
  7770. /**
  7771. * Defines if the alpha value should be determined via the rgb values.
  7772. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7773. */
  7774. getAlphaFromRGB: boolean;
  7775. /**
  7776. * Intensity or strength of the texture.
  7777. * It is commonly used by materials to fine tune the intensity of the texture
  7778. */
  7779. level: number;
  7780. /**
  7781. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7782. * This is part of the texture as textures usually maps to one uv set.
  7783. */
  7784. coordinatesIndex: number;
  7785. protected _coordinatesMode: number;
  7786. /**
  7787. * How a texture is mapped.
  7788. *
  7789. * | Value | Type | Description |
  7790. * | ----- | ----------------------------------- | ----------- |
  7791. * | 0 | EXPLICIT_MODE | |
  7792. * | 1 | SPHERICAL_MODE | |
  7793. * | 2 | PLANAR_MODE | |
  7794. * | 3 | CUBIC_MODE | |
  7795. * | 4 | PROJECTION_MODE | |
  7796. * | 5 | SKYBOX_MODE | |
  7797. * | 6 | INVCUBIC_MODE | |
  7798. * | 7 | EQUIRECTANGULAR_MODE | |
  7799. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7800. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7801. */
  7802. set coordinatesMode(value: number);
  7803. get coordinatesMode(): number;
  7804. /**
  7805. * | Value | Type | Description |
  7806. * | ----- | ------------------ | ----------- |
  7807. * | 0 | CLAMP_ADDRESSMODE | |
  7808. * | 1 | WRAP_ADDRESSMODE | |
  7809. * | 2 | MIRROR_ADDRESSMODE | |
  7810. */
  7811. get wrapU(): number;
  7812. set wrapU(value: number);
  7813. /**
  7814. * | Value | Type | Description |
  7815. * | ----- | ------------------ | ----------- |
  7816. * | 0 | CLAMP_ADDRESSMODE | |
  7817. * | 1 | WRAP_ADDRESSMODE | |
  7818. * | 2 | MIRROR_ADDRESSMODE | |
  7819. */
  7820. get wrapV(): number;
  7821. set wrapV(value: number);
  7822. /**
  7823. * | Value | Type | Description |
  7824. * | ----- | ------------------ | ----------- |
  7825. * | 0 | CLAMP_ADDRESSMODE | |
  7826. * | 1 | WRAP_ADDRESSMODE | |
  7827. * | 2 | MIRROR_ADDRESSMODE | |
  7828. */
  7829. wrapR: number;
  7830. /**
  7831. * With compliant hardware and browser (supporting anisotropic filtering)
  7832. * this defines the level of anisotropic filtering in the texture.
  7833. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7834. */
  7835. anisotropicFilteringLevel: number;
  7836. private _isCube;
  7837. /**
  7838. * Define if the texture is a cube texture or if false a 2d texture.
  7839. */
  7840. get isCube(): boolean;
  7841. set isCube(value: boolean);
  7842. /**
  7843. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7844. */
  7845. get is3D(): boolean;
  7846. set is3D(value: boolean);
  7847. /**
  7848. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7849. */
  7850. get is2DArray(): boolean;
  7851. set is2DArray(value: boolean);
  7852. private _gammaSpace;
  7853. /**
  7854. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7855. * HDR texture are usually stored in linear space.
  7856. * This only impacts the PBR and Background materials
  7857. */
  7858. get gammaSpace(): boolean;
  7859. set gammaSpace(gamma: boolean);
  7860. /**
  7861. * Gets or sets whether or not the texture contains RGBD data.
  7862. */
  7863. get isRGBD(): boolean;
  7864. set isRGBD(value: boolean);
  7865. /**
  7866. * Is Z inverted in the texture (useful in a cube texture).
  7867. */
  7868. invertZ: boolean;
  7869. /**
  7870. * Are mip maps generated for this texture or not.
  7871. */
  7872. get noMipmap(): boolean;
  7873. /**
  7874. * @hidden
  7875. */
  7876. lodLevelInAlpha: boolean;
  7877. /**
  7878. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7879. */
  7880. get lodGenerationOffset(): number;
  7881. set lodGenerationOffset(value: number);
  7882. /**
  7883. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7884. */
  7885. get lodGenerationScale(): number;
  7886. set lodGenerationScale(value: number);
  7887. /**
  7888. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7889. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7890. * average roughness values.
  7891. */
  7892. get linearSpecularLOD(): boolean;
  7893. set linearSpecularLOD(value: boolean);
  7894. /**
  7895. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7896. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7897. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7898. */
  7899. get irradianceTexture(): Nullable<BaseTexture>;
  7900. set irradianceTexture(value: Nullable<BaseTexture>);
  7901. /**
  7902. * Define if the texture is a render target.
  7903. */
  7904. isRenderTarget: boolean;
  7905. /**
  7906. * Define the unique id of the texture in the scene.
  7907. */
  7908. get uid(): string;
  7909. /** @hidden */
  7910. _prefiltered: boolean;
  7911. /**
  7912. * Return a string representation of the texture.
  7913. * @returns the texture as a string
  7914. */
  7915. toString(): string;
  7916. /**
  7917. * Get the class name of the texture.
  7918. * @returns "BaseTexture"
  7919. */
  7920. getClassName(): string;
  7921. /**
  7922. * Define the list of animation attached to the texture.
  7923. */
  7924. animations: Animation[];
  7925. /**
  7926. * An event triggered when the texture is disposed.
  7927. */
  7928. onDisposeObservable: Observable<BaseTexture>;
  7929. private _onDisposeObserver;
  7930. /**
  7931. * Callback triggered when the texture has been disposed.
  7932. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7933. */
  7934. set onDispose(callback: () => void);
  7935. protected _scene: Nullable<Scene>;
  7936. /** @hidden */
  7937. _texture: Nullable<InternalTexture>;
  7938. private _uid;
  7939. /**
  7940. * Define if the texture is preventinga material to render or not.
  7941. * If not and the texture is not ready, the engine will use a default black texture instead.
  7942. */
  7943. get isBlocking(): boolean;
  7944. /**
  7945. * Instantiates a new BaseTexture.
  7946. * Base class of all the textures in babylon.
  7947. * It groups all the common properties the materials, post process, lights... might need
  7948. * in order to make a correct use of the texture.
  7949. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7950. */
  7951. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7952. /**
  7953. * Get the scene the texture belongs to.
  7954. * @returns the scene or null if undefined
  7955. */
  7956. getScene(): Nullable<Scene>;
  7957. /** @hidden */
  7958. protected _getEngine(): Nullable<ThinEngine>;
  7959. /**
  7960. * Checks if the texture has the same transform matrix than another texture
  7961. * @param texture texture to check against
  7962. * @returns true if the transforms are the same, else false
  7963. */
  7964. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7965. /**
  7966. * Get the texture transform matrix used to offset tile the texture for istance.
  7967. * @returns the transformation matrix
  7968. */
  7969. getTextureMatrix(): Matrix;
  7970. /**
  7971. * Get the texture reflection matrix used to rotate/transform the reflection.
  7972. * @returns the reflection matrix
  7973. */
  7974. getReflectionTextureMatrix(): Matrix;
  7975. /**
  7976. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7977. * @returns true if ready or not blocking
  7978. */
  7979. isReadyOrNotBlocking(): boolean;
  7980. /**
  7981. * Scales the texture if is `canRescale()`
  7982. * @param ratio the resize factor we want to use to rescale
  7983. */
  7984. scale(ratio: number): void;
  7985. /**
  7986. * Get if the texture can rescale.
  7987. */
  7988. get canRescale(): boolean;
  7989. /** @hidden */
  7990. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7991. /** @hidden */
  7992. _rebuild(): void;
  7993. /**
  7994. * Clones the texture.
  7995. * @returns the cloned texture
  7996. */
  7997. clone(): Nullable<BaseTexture>;
  7998. /**
  7999. * Get the texture underlying type (INT, FLOAT...)
  8000. */
  8001. get textureType(): number;
  8002. /**
  8003. * Get the texture underlying format (RGB, RGBA...)
  8004. */
  8005. get textureFormat(): number;
  8006. /**
  8007. * Indicates that textures need to be re-calculated for all materials
  8008. */
  8009. protected _markAllSubMeshesAsTexturesDirty(): void;
  8010. /**
  8011. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8012. * This will returns an RGBA array buffer containing either in values (0-255) or
  8013. * float values (0-1) depending of the underlying buffer type.
  8014. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8015. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8016. * @param buffer defines a user defined buffer to fill with data (can be null)
  8017. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8018. * @returns The Array buffer promise containing the pixels data.
  8019. */
  8020. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8021. /** @hidden */
  8022. get _lodTextureHigh(): Nullable<BaseTexture>;
  8023. /** @hidden */
  8024. get _lodTextureMid(): Nullable<BaseTexture>;
  8025. /** @hidden */
  8026. get _lodTextureLow(): Nullable<BaseTexture>;
  8027. /**
  8028. * Dispose the texture and release its associated resources.
  8029. */
  8030. dispose(): void;
  8031. /**
  8032. * Serialize the texture into a JSON representation that can be parsed later on.
  8033. * @returns the JSON representation of the texture
  8034. */
  8035. serialize(): any;
  8036. /**
  8037. * Helper function to be called back once a list of texture contains only ready textures.
  8038. * @param textures Define the list of textures to wait for
  8039. * @param callback Define the callback triggered once the entire list will be ready
  8040. */
  8041. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8042. private static _isScene;
  8043. }
  8044. }
  8045. declare module BABYLON {
  8046. /** @hidden */
  8047. export class WebGLDataBuffer extends DataBuffer {
  8048. private _buffer;
  8049. constructor(resource: WebGLBuffer);
  8050. get underlyingResource(): any;
  8051. }
  8052. }
  8053. declare module BABYLON {
  8054. /** @hidden */
  8055. export class WebGLPipelineContext implements IPipelineContext {
  8056. private _valueCache;
  8057. private _uniforms;
  8058. engine: ThinEngine;
  8059. program: Nullable<WebGLProgram>;
  8060. context?: WebGLRenderingContext;
  8061. vertexShader?: WebGLShader;
  8062. fragmentShader?: WebGLShader;
  8063. isParallelCompiled: boolean;
  8064. onCompiled?: () => void;
  8065. transformFeedback?: WebGLTransformFeedback | null;
  8066. vertexCompilationError: Nullable<string>;
  8067. fragmentCompilationError: Nullable<string>;
  8068. programLinkError: Nullable<string>;
  8069. programValidationError: Nullable<string>;
  8070. get isAsync(): boolean;
  8071. get isReady(): boolean;
  8072. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8073. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8074. [key: string]: number;
  8075. }, uniformsNames: string[], uniforms: {
  8076. [key: string]: Nullable<WebGLUniformLocation>;
  8077. }, samplerList: string[], samplers: {
  8078. [key: string]: number;
  8079. }, attributesNames: string[], attributes: number[]): void;
  8080. /**
  8081. * Release all associated resources.
  8082. **/
  8083. dispose(): void;
  8084. /** @hidden */
  8085. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8086. /** @hidden */
  8087. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8088. /** @hidden */
  8089. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8090. /** @hidden */
  8091. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8092. /**
  8093. * Sets an interger value on a uniform variable.
  8094. * @param uniformName Name of the variable.
  8095. * @param value Value to be set.
  8096. */
  8097. setInt(uniformName: string, value: number): void;
  8098. /**
  8099. * Sets a int2 on a uniform variable.
  8100. * @param uniformName Name of the variable.
  8101. * @param x First int in int2.
  8102. * @param y Second int in int2.
  8103. */
  8104. setInt2(uniformName: string, x: number, y: number): void;
  8105. /**
  8106. * Sets a int3 on a uniform variable.
  8107. * @param uniformName Name of the variable.
  8108. * @param x First int in int3.
  8109. * @param y Second int in int3.
  8110. * @param y Third int in int3.
  8111. */
  8112. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8113. /**
  8114. * Sets a int4 on a uniform variable.
  8115. * @param uniformName Name of the variable.
  8116. * @param x First int in int4.
  8117. * @param y Second int in int4.
  8118. * @param y Third int in int4.
  8119. * @param w Fourth int in int4.
  8120. */
  8121. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8122. /**
  8123. * Sets an int array on a uniform variable.
  8124. * @param uniformName Name of the variable.
  8125. * @param array array to be set.
  8126. */
  8127. setIntArray(uniformName: string, array: Int32Array): void;
  8128. /**
  8129. * 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)
  8130. * @param uniformName Name of the variable.
  8131. * @param array array to be set.
  8132. */
  8133. setIntArray2(uniformName: string, array: Int32Array): void;
  8134. /**
  8135. * 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)
  8136. * @param uniformName Name of the variable.
  8137. * @param array array to be set.
  8138. */
  8139. setIntArray3(uniformName: string, array: Int32Array): void;
  8140. /**
  8141. * 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)
  8142. * @param uniformName Name of the variable.
  8143. * @param array array to be set.
  8144. */
  8145. setIntArray4(uniformName: string, array: Int32Array): void;
  8146. /**
  8147. * Sets an array on a uniform variable.
  8148. * @param uniformName Name of the variable.
  8149. * @param array array to be set.
  8150. */
  8151. setArray(uniformName: string, array: number[]): void;
  8152. /**
  8153. * 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)
  8154. * @param uniformName Name of the variable.
  8155. * @param array array to be set.
  8156. */
  8157. setArray2(uniformName: string, array: number[]): void;
  8158. /**
  8159. * 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)
  8160. * @param uniformName Name of the variable.
  8161. * @param array array to be set.
  8162. * @returns this effect.
  8163. */
  8164. setArray3(uniformName: string, array: number[]): void;
  8165. /**
  8166. * 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)
  8167. * @param uniformName Name of the variable.
  8168. * @param array array to be set.
  8169. */
  8170. setArray4(uniformName: string, array: number[]): void;
  8171. /**
  8172. * Sets matrices on a uniform variable.
  8173. * @param uniformName Name of the variable.
  8174. * @param matrices matrices to be set.
  8175. */
  8176. setMatrices(uniformName: string, matrices: Float32Array): void;
  8177. /**
  8178. * Sets matrix on a uniform variable.
  8179. * @param uniformName Name of the variable.
  8180. * @param matrix matrix to be set.
  8181. */
  8182. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8183. /**
  8184. * 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)
  8185. * @param uniformName Name of the variable.
  8186. * @param matrix matrix to be set.
  8187. */
  8188. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8189. /**
  8190. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8191. * @param uniformName Name of the variable.
  8192. * @param matrix matrix to be set.
  8193. */
  8194. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8195. /**
  8196. * Sets a float on a uniform variable.
  8197. * @param uniformName Name of the variable.
  8198. * @param value value to be set.
  8199. * @returns this effect.
  8200. */
  8201. setFloat(uniformName: string, value: number): void;
  8202. /**
  8203. * Sets a Vector2 on a uniform variable.
  8204. * @param uniformName Name of the variable.
  8205. * @param vector2 vector2 to be set.
  8206. */
  8207. setVector2(uniformName: string, vector2: IVector2Like): void;
  8208. /**
  8209. * Sets a float2 on a uniform variable.
  8210. * @param uniformName Name of the variable.
  8211. * @param x First float in float2.
  8212. * @param y Second float in float2.
  8213. */
  8214. setFloat2(uniformName: string, x: number, y: number): void;
  8215. /**
  8216. * Sets a Vector3 on a uniform variable.
  8217. * @param uniformName Name of the variable.
  8218. * @param vector3 Value to be set.
  8219. */
  8220. setVector3(uniformName: string, vector3: IVector3Like): void;
  8221. /**
  8222. * Sets a float3 on a uniform variable.
  8223. * @param uniformName Name of the variable.
  8224. * @param x First float in float3.
  8225. * @param y Second float in float3.
  8226. * @param z Third float in float3.
  8227. */
  8228. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8229. /**
  8230. * Sets a Vector4 on a uniform variable.
  8231. * @param uniformName Name of the variable.
  8232. * @param vector4 Value to be set.
  8233. */
  8234. setVector4(uniformName: string, vector4: IVector4Like): void;
  8235. /**
  8236. * Sets a float4 on a uniform variable.
  8237. * @param uniformName Name of the variable.
  8238. * @param x First float in float4.
  8239. * @param y Second float in float4.
  8240. * @param z Third float in float4.
  8241. * @param w Fourth float in float4.
  8242. * @returns this effect.
  8243. */
  8244. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8245. /**
  8246. * Sets a Color3 on a uniform variable.
  8247. * @param uniformName Name of the variable.
  8248. * @param color3 Value to be set.
  8249. */
  8250. setColor3(uniformName: string, color3: IColor3Like): void;
  8251. /**
  8252. * Sets a Color4 on a uniform variable.
  8253. * @param uniformName Name of the variable.
  8254. * @param color3 Value to be set.
  8255. * @param alpha Alpha value to be set.
  8256. */
  8257. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8258. /**
  8259. * Sets a Color4 on a uniform variable
  8260. * @param uniformName defines the name of the variable
  8261. * @param color4 defines the value to be set
  8262. */
  8263. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8264. _getVertexShaderCode(): string | null;
  8265. _getFragmentShaderCode(): string | null;
  8266. }
  8267. }
  8268. declare module BABYLON {
  8269. interface ThinEngine {
  8270. /**
  8271. * Create an uniform buffer
  8272. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8273. * @param elements defines the content of the uniform buffer
  8274. * @returns the webGL uniform buffer
  8275. */
  8276. createUniformBuffer(elements: FloatArray): DataBuffer;
  8277. /**
  8278. * Create a dynamic uniform buffer
  8279. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8280. * @param elements defines the content of the uniform buffer
  8281. * @returns the webGL uniform buffer
  8282. */
  8283. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8284. /**
  8285. * Update an existing uniform buffer
  8286. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8287. * @param uniformBuffer defines the target uniform buffer
  8288. * @param elements defines the content to update
  8289. * @param offset defines the offset in the uniform buffer where update should start
  8290. * @param count defines the size of the data to update
  8291. */
  8292. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8293. /**
  8294. * Bind an uniform buffer to the current webGL context
  8295. * @param buffer defines the buffer to bind
  8296. */
  8297. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8298. /**
  8299. * Bind a buffer to the current webGL context at a given location
  8300. * @param buffer defines the buffer to bind
  8301. * @param location defines the index where to bind the buffer
  8302. * @param name Name of the uniform variable to bind
  8303. */
  8304. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8305. /**
  8306. * Bind a specific block at a given index in a specific shader program
  8307. * @param pipelineContext defines the pipeline context to use
  8308. * @param blockName defines the block name
  8309. * @param index defines the index where to bind the block
  8310. */
  8311. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8312. }
  8313. }
  8314. declare module BABYLON {
  8315. /**
  8316. * Uniform buffer objects.
  8317. *
  8318. * Handles blocks of uniform on the GPU.
  8319. *
  8320. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8321. *
  8322. * For more information, please refer to :
  8323. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8324. */
  8325. export class UniformBuffer {
  8326. /** @hidden */
  8327. static _updatedUbosInFrame: {
  8328. [name: string]: number;
  8329. };
  8330. private _engine;
  8331. private _buffer;
  8332. private _buffers;
  8333. private _bufferIndex;
  8334. private _createBufferOnWrite;
  8335. private _data;
  8336. private _bufferData;
  8337. private _dynamic?;
  8338. private _uniformLocations;
  8339. private _uniformSizes;
  8340. private _uniformArraySizes;
  8341. private _uniformLocationPointer;
  8342. private _needSync;
  8343. private _noUBO;
  8344. private _currentEffect;
  8345. private _currentEffectName;
  8346. private _name;
  8347. private _currentFrameId;
  8348. /** @hidden */
  8349. _alreadyBound: boolean;
  8350. private static _MAX_UNIFORM_SIZE;
  8351. private static _tempBuffer;
  8352. private static _tempBufferInt32View;
  8353. /**
  8354. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8355. * This is dynamic to allow compat with webgl 1 and 2.
  8356. * You will need to pass the name of the uniform as well as the value.
  8357. */
  8358. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8359. /**
  8360. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8361. * This is dynamic to allow compat with webgl 1 and 2.
  8362. * You will need to pass the name of the uniform as well as the value.
  8363. */
  8364. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8365. /**
  8366. * Lambda to Update a single float in a uniform buffer.
  8367. * This is dynamic to allow compat with webgl 1 and 2.
  8368. * You will need to pass the name of the uniform as well as the value.
  8369. */
  8370. updateFloat: (name: string, x: number) => void;
  8371. /**
  8372. * Lambda to Update a vec2 of float in a uniform buffer.
  8373. * This is dynamic to allow compat with webgl 1 and 2.
  8374. * You will need to pass the name of the uniform as well as the value.
  8375. */
  8376. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8377. /**
  8378. * Lambda to Update a vec3 of float in a uniform buffer.
  8379. * This is dynamic to allow compat with webgl 1 and 2.
  8380. * You will need to pass the name of the uniform as well as the value.
  8381. */
  8382. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8383. /**
  8384. * Lambda to Update a vec4 of float in a uniform buffer.
  8385. * This is dynamic to allow compat with webgl 1 and 2.
  8386. * You will need to pass the name of the uniform as well as the value.
  8387. */
  8388. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8389. /**
  8390. * Lambda to Update an array of float in a uniform buffer.
  8391. * This is dynamic to allow compat with webgl 1 and 2.
  8392. * You will need to pass the name of the uniform as well as the value.
  8393. */
  8394. updateFloatArray: (name: string, array: Float32Array) => void;
  8395. /**
  8396. * Lambda to Update an array of number in a uniform buffer.
  8397. * This is dynamic to allow compat with webgl 1 and 2.
  8398. * You will need to pass the name of the uniform as well as the value.
  8399. */
  8400. updateArray: (name: string, array: number[]) => void;
  8401. /**
  8402. * Lambda to Update an array of number in a uniform buffer.
  8403. * This is dynamic to allow compat with webgl 1 and 2.
  8404. * You will need to pass the name of the uniform as well as the value.
  8405. */
  8406. updateIntArray: (name: string, array: Int32Array) => void;
  8407. /**
  8408. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8409. * This is dynamic to allow compat with webgl 1 and 2.
  8410. * You will need to pass the name of the uniform as well as the value.
  8411. */
  8412. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8413. /**
  8414. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8415. * This is dynamic to allow compat with webgl 1 and 2.
  8416. * You will need to pass the name of the uniform as well as the value.
  8417. */
  8418. updateMatrices: (name: string, mat: Float32Array) => void;
  8419. /**
  8420. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8421. * This is dynamic to allow compat with webgl 1 and 2.
  8422. * You will need to pass the name of the uniform as well as the value.
  8423. */
  8424. updateVector3: (name: string, vector: Vector3) => void;
  8425. /**
  8426. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8427. * This is dynamic to allow compat with webgl 1 and 2.
  8428. * You will need to pass the name of the uniform as well as the value.
  8429. */
  8430. updateVector4: (name: string, vector: Vector4) => void;
  8431. /**
  8432. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8433. * This is dynamic to allow compat with webgl 1 and 2.
  8434. * You will need to pass the name of the uniform as well as the value.
  8435. */
  8436. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8437. /**
  8438. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8439. * This is dynamic to allow compat with webgl 1 and 2.
  8440. * You will need to pass the name of the uniform as well as the value.
  8441. */
  8442. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8443. /**
  8444. * Lambda to Update a int a uniform buffer.
  8445. * This is dynamic to allow compat with webgl 1 and 2.
  8446. * You will need to pass the name of the uniform as well as the value.
  8447. */
  8448. updateInt: (name: string, x: number, suffix?: string) => void;
  8449. /**
  8450. * Lambda to Update a vec2 of int in a uniform buffer.
  8451. * This is dynamic to allow compat with webgl 1 and 2.
  8452. * You will need to pass the name of the uniform as well as the value.
  8453. */
  8454. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8455. /**
  8456. * Lambda to Update a vec3 of int in a uniform buffer.
  8457. * This is dynamic to allow compat with webgl 1 and 2.
  8458. * You will need to pass the name of the uniform as well as the value.
  8459. */
  8460. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8461. /**
  8462. * Lambda to Update a vec4 of int in a uniform buffer.
  8463. * This is dynamic to allow compat with webgl 1 and 2.
  8464. * You will need to pass the name of the uniform as well as the value.
  8465. */
  8466. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8467. /**
  8468. * Instantiates a new Uniform buffer objects.
  8469. *
  8470. * Handles blocks of uniform on the GPU.
  8471. *
  8472. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8473. *
  8474. * For more information, please refer to :
  8475. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8476. * @param engine Define the engine the buffer is associated with
  8477. * @param data Define the data contained in the buffer
  8478. * @param dynamic Define if the buffer is updatable
  8479. * @param name to assign to the buffer (debugging purpose)
  8480. */
  8481. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8482. /**
  8483. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8484. * or just falling back on setUniformXXX calls.
  8485. */
  8486. get useUbo(): boolean;
  8487. /**
  8488. * Indicates if the WebGL underlying uniform buffer is in sync
  8489. * with the javascript cache data.
  8490. */
  8491. get isSync(): boolean;
  8492. /**
  8493. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8494. * Also, a dynamic UniformBuffer will disable cache verification and always
  8495. * update the underlying WebGL uniform buffer to the GPU.
  8496. * @returns if Dynamic, otherwise false
  8497. */
  8498. isDynamic(): boolean;
  8499. /**
  8500. * The data cache on JS side.
  8501. * @returns the underlying data as a float array
  8502. */
  8503. getData(): Float32Array;
  8504. /**
  8505. * The underlying WebGL Uniform buffer.
  8506. * @returns the webgl buffer
  8507. */
  8508. getBuffer(): Nullable<DataBuffer>;
  8509. /**
  8510. * std140 layout specifies how to align data within an UBO structure.
  8511. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8512. * for specs.
  8513. */
  8514. private _fillAlignment;
  8515. /**
  8516. * Adds an uniform in the buffer.
  8517. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8518. * for the layout to be correct !
  8519. * @param name Name of the uniform, as used in the uniform block in the shader.
  8520. * @param size Data size, or data directly.
  8521. * @param arraySize The number of elements in the array, 0 if not an array.
  8522. */
  8523. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8524. /**
  8525. * Adds a Matrix 4x4 to the uniform buffer.
  8526. * @param name Name of the uniform, as used in the uniform block in the shader.
  8527. * @param mat A 4x4 matrix.
  8528. */
  8529. addMatrix(name: string, mat: Matrix): void;
  8530. /**
  8531. * Adds a vec2 to the uniform buffer.
  8532. * @param name Name of the uniform, as used in the uniform block in the shader.
  8533. * @param x Define the x component value of the vec2
  8534. * @param y Define the y component value of the vec2
  8535. */
  8536. addFloat2(name: string, x: number, y: number): void;
  8537. /**
  8538. * Adds a vec3 to the uniform buffer.
  8539. * @param name Name of the uniform, as used in the uniform block in the shader.
  8540. * @param x Define the x component value of the vec3
  8541. * @param y Define the y component value of the vec3
  8542. * @param z Define the z component value of the vec3
  8543. */
  8544. addFloat3(name: string, x: number, y: number, z: number): void;
  8545. /**
  8546. * Adds a vec3 to the uniform buffer.
  8547. * @param name Name of the uniform, as used in the uniform block in the shader.
  8548. * @param color Define the vec3 from a Color
  8549. */
  8550. addColor3(name: string, color: Color3): void;
  8551. /**
  8552. * Adds a vec4 to the uniform buffer.
  8553. * @param name Name of the uniform, as used in the uniform block in the shader.
  8554. * @param color Define the rgb components from a Color
  8555. * @param alpha Define the a component of the vec4
  8556. */
  8557. addColor4(name: string, color: Color3, alpha: number): void;
  8558. /**
  8559. * Adds a vec3 to the uniform buffer.
  8560. * @param name Name of the uniform, as used in the uniform block in the shader.
  8561. * @param vector Define the vec3 components from a Vector
  8562. */
  8563. addVector3(name: string, vector: Vector3): void;
  8564. /**
  8565. * Adds a Matrix 3x3 to the uniform buffer.
  8566. * @param name Name of the uniform, as used in the uniform block in the shader.
  8567. */
  8568. addMatrix3x3(name: string): void;
  8569. /**
  8570. * Adds a Matrix 2x2 to the uniform buffer.
  8571. * @param name Name of the uniform, as used in the uniform block in the shader.
  8572. */
  8573. addMatrix2x2(name: string): void;
  8574. /**
  8575. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8576. */
  8577. create(): void;
  8578. /** @hidden */
  8579. _rebuild(): void;
  8580. /** @hidden */
  8581. get _numBuffers(): number;
  8582. /** @hidden */
  8583. get _indexBuffer(): number;
  8584. /** Gets the name of this buffer */
  8585. get name(): string;
  8586. /**
  8587. * Updates the WebGL Uniform Buffer on the GPU.
  8588. * If the `dynamic` flag is set to true, no cache comparison is done.
  8589. * Otherwise, the buffer will be updated only if the cache differs.
  8590. */
  8591. update(): void;
  8592. private _createNewBuffer;
  8593. private _checkNewFrame;
  8594. /**
  8595. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8596. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8597. * @param data Define the flattened data
  8598. * @param size Define the size of the data.
  8599. */
  8600. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8601. /**
  8602. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8603. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8604. * @param data Define the flattened data
  8605. * @param size Define the size of the data.
  8606. */
  8607. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8608. private _valueCache;
  8609. private _cacheMatrix;
  8610. private _updateMatrix3x3ForUniform;
  8611. private _updateMatrix3x3ForEffect;
  8612. private _updateMatrix2x2ForEffect;
  8613. private _updateMatrix2x2ForUniform;
  8614. private _updateFloatForEffect;
  8615. private _updateFloatForUniform;
  8616. private _updateFloat2ForEffect;
  8617. private _updateFloat2ForUniform;
  8618. private _updateFloat3ForEffect;
  8619. private _updateFloat3ForUniform;
  8620. private _updateFloat4ForEffect;
  8621. private _updateFloat4ForUniform;
  8622. private _updateFloatArrayForEffect;
  8623. private _updateFloatArrayForUniform;
  8624. private _updateArrayForEffect;
  8625. private _updateArrayForUniform;
  8626. private _updateIntArrayForEffect;
  8627. private _updateIntArrayForUniform;
  8628. private _updateMatrixForEffect;
  8629. private _updateMatrixForUniform;
  8630. private _updateMatricesForEffect;
  8631. private _updateMatricesForUniform;
  8632. private _updateVector3ForEffect;
  8633. private _updateVector3ForUniform;
  8634. private _updateVector4ForEffect;
  8635. private _updateVector4ForUniform;
  8636. private _updateColor3ForEffect;
  8637. private _updateColor3ForUniform;
  8638. private _updateColor4ForEffect;
  8639. private _updateColor4ForUniform;
  8640. private _updateIntForEffect;
  8641. private _updateIntForUniform;
  8642. private _updateInt2ForEffect;
  8643. private _updateInt2ForUniform;
  8644. private _updateInt3ForEffect;
  8645. private _updateInt3ForUniform;
  8646. private _updateInt4ForEffect;
  8647. private _updateInt4ForUniform;
  8648. /**
  8649. * Sets a sampler uniform on the effect.
  8650. * @param name Define the name of the sampler.
  8651. * @param texture Define the texture to set in the sampler
  8652. */
  8653. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8654. /**
  8655. * Directly updates the value of the uniform in the cache AND on the GPU.
  8656. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8657. * @param data Define the flattened data
  8658. */
  8659. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8660. /**
  8661. * Binds this uniform buffer to an effect.
  8662. * @param effect Define the effect to bind the buffer to
  8663. * @param name Name of the uniform block in the shader.
  8664. */
  8665. bindToEffect(effect: Effect, name: string): void;
  8666. /**
  8667. * Disposes the uniform buffer.
  8668. */
  8669. dispose(): void;
  8670. }
  8671. }
  8672. declare module BABYLON {
  8673. /**
  8674. * Manages the defines for the Material
  8675. */
  8676. export class MaterialDefines {
  8677. /** @hidden */
  8678. protected _keys: string[];
  8679. private _isDirty;
  8680. /** @hidden */
  8681. _renderId: number;
  8682. /** @hidden */
  8683. _areLightsDirty: boolean;
  8684. /** @hidden */
  8685. _areLightsDisposed: boolean;
  8686. /** @hidden */
  8687. _areAttributesDirty: boolean;
  8688. /** @hidden */
  8689. _areTexturesDirty: boolean;
  8690. /** @hidden */
  8691. _areFresnelDirty: boolean;
  8692. /** @hidden */
  8693. _areMiscDirty: boolean;
  8694. /** @hidden */
  8695. _arePrePassDirty: boolean;
  8696. /** @hidden */
  8697. _areImageProcessingDirty: boolean;
  8698. /** @hidden */
  8699. _normals: boolean;
  8700. /** @hidden */
  8701. _uvs: boolean;
  8702. /** @hidden */
  8703. _needNormals: boolean;
  8704. /** @hidden */
  8705. _needUVs: boolean;
  8706. [id: string]: any;
  8707. /**
  8708. * Specifies if the material needs to be re-calculated
  8709. */
  8710. get isDirty(): boolean;
  8711. /**
  8712. * Marks the material to indicate that it has been re-calculated
  8713. */
  8714. markAsProcessed(): void;
  8715. /**
  8716. * Marks the material to indicate that it needs to be re-calculated
  8717. */
  8718. markAsUnprocessed(): void;
  8719. /**
  8720. * Marks the material to indicate all of its defines need to be re-calculated
  8721. */
  8722. markAllAsDirty(): void;
  8723. /**
  8724. * Marks the material to indicate that image processing needs to be re-calculated
  8725. */
  8726. markAsImageProcessingDirty(): void;
  8727. /**
  8728. * Marks the material to indicate the lights need to be re-calculated
  8729. * @param disposed Defines whether the light is dirty due to dispose or not
  8730. */
  8731. markAsLightDirty(disposed?: boolean): void;
  8732. /**
  8733. * Marks the attribute state as changed
  8734. */
  8735. markAsAttributesDirty(): void;
  8736. /**
  8737. * Marks the texture state as changed
  8738. */
  8739. markAsTexturesDirty(): void;
  8740. /**
  8741. * Marks the fresnel state as changed
  8742. */
  8743. markAsFresnelDirty(): void;
  8744. /**
  8745. * Marks the misc state as changed
  8746. */
  8747. markAsMiscDirty(): void;
  8748. /**
  8749. * Marks the prepass state as changed
  8750. */
  8751. markAsPrePassDirty(): void;
  8752. /**
  8753. * Rebuilds the material defines
  8754. */
  8755. rebuild(): void;
  8756. /**
  8757. * Specifies if two material defines are equal
  8758. * @param other - A material define instance to compare to
  8759. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8760. */
  8761. isEqual(other: MaterialDefines): boolean;
  8762. /**
  8763. * Clones this instance's defines to another instance
  8764. * @param other - material defines to clone values to
  8765. */
  8766. cloneTo(other: MaterialDefines): void;
  8767. /**
  8768. * Resets the material define values
  8769. */
  8770. reset(): void;
  8771. /**
  8772. * Converts the material define values to a string
  8773. * @returns - String of material define information
  8774. */
  8775. toString(): string;
  8776. }
  8777. }
  8778. declare module BABYLON {
  8779. /**
  8780. * Enum that determines the text-wrapping mode to use.
  8781. */
  8782. export enum InspectableType {
  8783. /**
  8784. * Checkbox for booleans
  8785. */
  8786. Checkbox = 0,
  8787. /**
  8788. * Sliders for numbers
  8789. */
  8790. Slider = 1,
  8791. /**
  8792. * Vector3
  8793. */
  8794. Vector3 = 2,
  8795. /**
  8796. * Quaternions
  8797. */
  8798. Quaternion = 3,
  8799. /**
  8800. * Color3
  8801. */
  8802. Color3 = 4,
  8803. /**
  8804. * String
  8805. */
  8806. String = 5
  8807. }
  8808. /**
  8809. * Interface used to define custom inspectable properties.
  8810. * This interface is used by the inspector to display custom property grids
  8811. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8812. */
  8813. export interface IInspectable {
  8814. /**
  8815. * Gets the label to display
  8816. */
  8817. label: string;
  8818. /**
  8819. * Gets the name of the property to edit
  8820. */
  8821. propertyName: string;
  8822. /**
  8823. * Gets the type of the editor to use
  8824. */
  8825. type: InspectableType;
  8826. /**
  8827. * Gets the minimum value of the property when using in "slider" mode
  8828. */
  8829. min?: number;
  8830. /**
  8831. * Gets the maximum value of the property when using in "slider" mode
  8832. */
  8833. max?: number;
  8834. /**
  8835. * Gets the setp to use when using in "slider" mode
  8836. */
  8837. step?: number;
  8838. }
  8839. }
  8840. declare module BABYLON {
  8841. /**
  8842. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8843. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8844. * 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.
  8845. */
  8846. export abstract class Light extends Node {
  8847. /**
  8848. * Falloff Default: light is falling off following the material specification:
  8849. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8850. */
  8851. static readonly FALLOFF_DEFAULT: number;
  8852. /**
  8853. * Falloff Physical: light is falling off following the inverse squared distance law.
  8854. */
  8855. static readonly FALLOFF_PHYSICAL: number;
  8856. /**
  8857. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8858. * to enhance interoperability with other engines.
  8859. */
  8860. static readonly FALLOFF_GLTF: number;
  8861. /**
  8862. * Falloff Standard: light is falling off like in the standard material
  8863. * to enhance interoperability with other materials.
  8864. */
  8865. static readonly FALLOFF_STANDARD: number;
  8866. /**
  8867. * If every light affecting the material is in this lightmapMode,
  8868. * material.lightmapTexture adds or multiplies
  8869. * (depends on material.useLightmapAsShadowmap)
  8870. * after every other light calculations.
  8871. */
  8872. static readonly LIGHTMAP_DEFAULT: number;
  8873. /**
  8874. * material.lightmapTexture as only diffuse lighting from this light
  8875. * adds only specular lighting from this light
  8876. * adds dynamic shadows
  8877. */
  8878. static readonly LIGHTMAP_SPECULAR: number;
  8879. /**
  8880. * material.lightmapTexture as only lighting
  8881. * no light calculation from this light
  8882. * only adds dynamic shadows from this light
  8883. */
  8884. static readonly LIGHTMAP_SHADOWSONLY: number;
  8885. /**
  8886. * Each light type uses the default quantity according to its type:
  8887. * point/spot lights use luminous intensity
  8888. * directional lights use illuminance
  8889. */
  8890. static readonly INTENSITYMODE_AUTOMATIC: number;
  8891. /**
  8892. * lumen (lm)
  8893. */
  8894. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8895. /**
  8896. * candela (lm/sr)
  8897. */
  8898. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8899. /**
  8900. * lux (lm/m^2)
  8901. */
  8902. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8903. /**
  8904. * nit (cd/m^2)
  8905. */
  8906. static readonly INTENSITYMODE_LUMINANCE: number;
  8907. /**
  8908. * Light type const id of the point light.
  8909. */
  8910. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8911. /**
  8912. * Light type const id of the directional light.
  8913. */
  8914. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8915. /**
  8916. * Light type const id of the spot light.
  8917. */
  8918. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8919. /**
  8920. * Light type const id of the hemispheric light.
  8921. */
  8922. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8923. /**
  8924. * Diffuse gives the basic color to an object.
  8925. */
  8926. diffuse: Color3;
  8927. /**
  8928. * Specular produces a highlight color on an object.
  8929. * Note: This is note affecting PBR materials.
  8930. */
  8931. specular: Color3;
  8932. /**
  8933. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8934. * falling off base on range or angle.
  8935. * This can be set to any values in Light.FALLOFF_x.
  8936. *
  8937. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8938. * other types of materials.
  8939. */
  8940. falloffType: number;
  8941. /**
  8942. * Strength of the light.
  8943. * Note: By default it is define in the framework own unit.
  8944. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8945. */
  8946. intensity: number;
  8947. private _range;
  8948. protected _inverseSquaredRange: number;
  8949. /**
  8950. * Defines how far from the source the light is impacting in scene units.
  8951. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8952. */
  8953. get range(): number;
  8954. /**
  8955. * Defines how far from the source the light is impacting in scene units.
  8956. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8957. */
  8958. set range(value: number);
  8959. /**
  8960. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8961. * of light.
  8962. */
  8963. private _photometricScale;
  8964. private _intensityMode;
  8965. /**
  8966. * Gets the photometric scale used to interpret the intensity.
  8967. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8968. */
  8969. get intensityMode(): number;
  8970. /**
  8971. * Sets the photometric scale used to interpret the intensity.
  8972. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8973. */
  8974. set intensityMode(value: number);
  8975. private _radius;
  8976. /**
  8977. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8978. */
  8979. get radius(): number;
  8980. /**
  8981. * sets the light radius used by PBR Materials to simulate soft area lights.
  8982. */
  8983. set radius(value: number);
  8984. private _renderPriority;
  8985. /**
  8986. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8987. * exceeding the number allowed of the materials.
  8988. */
  8989. renderPriority: number;
  8990. private _shadowEnabled;
  8991. /**
  8992. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8993. * the current shadow generator.
  8994. */
  8995. get shadowEnabled(): boolean;
  8996. /**
  8997. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8998. * the current shadow generator.
  8999. */
  9000. set shadowEnabled(value: boolean);
  9001. private _includedOnlyMeshes;
  9002. /**
  9003. * Gets the only meshes impacted by this light.
  9004. */
  9005. get includedOnlyMeshes(): AbstractMesh[];
  9006. /**
  9007. * Sets the only meshes impacted by this light.
  9008. */
  9009. set includedOnlyMeshes(value: AbstractMesh[]);
  9010. private _excludedMeshes;
  9011. /**
  9012. * Gets the meshes not impacted by this light.
  9013. */
  9014. get excludedMeshes(): AbstractMesh[];
  9015. /**
  9016. * Sets the meshes not impacted by this light.
  9017. */
  9018. set excludedMeshes(value: AbstractMesh[]);
  9019. private _excludeWithLayerMask;
  9020. /**
  9021. * Gets the layer id use to find what meshes are not impacted by the light.
  9022. * Inactive if 0
  9023. */
  9024. get excludeWithLayerMask(): number;
  9025. /**
  9026. * Sets the layer id use to find what meshes are not impacted by the light.
  9027. * Inactive if 0
  9028. */
  9029. set excludeWithLayerMask(value: number);
  9030. private _includeOnlyWithLayerMask;
  9031. /**
  9032. * Gets the layer id use to find what meshes are impacted by the light.
  9033. * Inactive if 0
  9034. */
  9035. get includeOnlyWithLayerMask(): number;
  9036. /**
  9037. * Sets the layer id use to find what meshes are impacted by the light.
  9038. * Inactive if 0
  9039. */
  9040. set includeOnlyWithLayerMask(value: number);
  9041. private _lightmapMode;
  9042. /**
  9043. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9044. */
  9045. get lightmapMode(): number;
  9046. /**
  9047. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9048. */
  9049. set lightmapMode(value: number);
  9050. /**
  9051. * Shadow generator associted to the light.
  9052. * @hidden Internal use only.
  9053. */
  9054. _shadowGenerator: Nullable<IShadowGenerator>;
  9055. /**
  9056. * @hidden Internal use only.
  9057. */
  9058. _excludedMeshesIds: string[];
  9059. /**
  9060. * @hidden Internal use only.
  9061. */
  9062. _includedOnlyMeshesIds: string[];
  9063. /**
  9064. * The current light unifom buffer.
  9065. * @hidden Internal use only.
  9066. */
  9067. _uniformBuffer: UniformBuffer;
  9068. /** @hidden */
  9069. _renderId: number;
  9070. /**
  9071. * Creates a Light object in the scene.
  9072. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9073. * @param name The firendly name of the light
  9074. * @param scene The scene the light belongs too
  9075. */
  9076. constructor(name: string, scene: Scene);
  9077. protected abstract _buildUniformLayout(): void;
  9078. /**
  9079. * Sets the passed Effect "effect" with the Light information.
  9080. * @param effect The effect to update
  9081. * @param lightIndex The index of the light in the effect to update
  9082. * @returns The light
  9083. */
  9084. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9085. /**
  9086. * Sets the passed Effect "effect" with the Light textures.
  9087. * @param effect The effect to update
  9088. * @param lightIndex The index of the light in the effect to update
  9089. * @returns The light
  9090. */
  9091. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9092. /**
  9093. * Binds the lights information from the scene to the effect for the given mesh.
  9094. * @param lightIndex Light index
  9095. * @param scene The scene where the light belongs to
  9096. * @param effect The effect we are binding the data to
  9097. * @param useSpecular Defines if specular is supported
  9098. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9099. */
  9100. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9101. /**
  9102. * Sets the passed Effect "effect" with the Light information.
  9103. * @param effect The effect to update
  9104. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9105. * @returns The light
  9106. */
  9107. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9108. /**
  9109. * Returns the string "Light".
  9110. * @returns the class name
  9111. */
  9112. getClassName(): string;
  9113. /** @hidden */
  9114. readonly _isLight: boolean;
  9115. /**
  9116. * Converts the light information to a readable string for debug purpose.
  9117. * @param fullDetails Supports for multiple levels of logging within scene loading
  9118. * @returns the human readable light info
  9119. */
  9120. toString(fullDetails?: boolean): string;
  9121. /** @hidden */
  9122. protected _syncParentEnabledState(): void;
  9123. /**
  9124. * Set the enabled state of this node.
  9125. * @param value - the new enabled state
  9126. */
  9127. setEnabled(value: boolean): void;
  9128. /**
  9129. * Returns the Light associated shadow generator if any.
  9130. * @return the associated shadow generator.
  9131. */
  9132. getShadowGenerator(): Nullable<IShadowGenerator>;
  9133. /**
  9134. * Returns a Vector3, the absolute light position in the World.
  9135. * @returns the world space position of the light
  9136. */
  9137. getAbsolutePosition(): Vector3;
  9138. /**
  9139. * Specifies if the light will affect the passed mesh.
  9140. * @param mesh The mesh to test against the light
  9141. * @return true the mesh is affected otherwise, false.
  9142. */
  9143. canAffectMesh(mesh: AbstractMesh): boolean;
  9144. /**
  9145. * Sort function to order lights for rendering.
  9146. * @param a First Light object to compare to second.
  9147. * @param b Second Light object to compare first.
  9148. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9149. */
  9150. static CompareLightsPriority(a: Light, b: Light): number;
  9151. /**
  9152. * Releases resources associated with this node.
  9153. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9154. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9155. */
  9156. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9157. /**
  9158. * Returns the light type ID (integer).
  9159. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9160. */
  9161. getTypeID(): number;
  9162. /**
  9163. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9164. * @returns the scaled intensity in intensity mode unit
  9165. */
  9166. getScaledIntensity(): number;
  9167. /**
  9168. * Returns a new Light object, named "name", from the current one.
  9169. * @param name The name of the cloned light
  9170. * @param newParent The parent of this light, if it has one
  9171. * @returns the new created light
  9172. */
  9173. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9174. /**
  9175. * Serializes the current light into a Serialization object.
  9176. * @returns the serialized object.
  9177. */
  9178. serialize(): any;
  9179. /**
  9180. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9181. * This new light is named "name" and added to the passed scene.
  9182. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9183. * @param name The friendly name of the light
  9184. * @param scene The scene the new light will belong to
  9185. * @returns the constructor function
  9186. */
  9187. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9188. /**
  9189. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9190. * @param parsedLight The JSON representation of the light
  9191. * @param scene The scene to create the parsed light in
  9192. * @returns the created light after parsing
  9193. */
  9194. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9195. private _hookArrayForExcluded;
  9196. private _hookArrayForIncludedOnly;
  9197. private _resyncMeshes;
  9198. /**
  9199. * Forces the meshes to update their light related information in their rendering used effects
  9200. * @hidden Internal Use Only
  9201. */
  9202. _markMeshesAsLightDirty(): void;
  9203. /**
  9204. * Recomputes the cached photometric scale if needed.
  9205. */
  9206. private _computePhotometricScale;
  9207. /**
  9208. * Returns the Photometric Scale according to the light type and intensity mode.
  9209. */
  9210. private _getPhotometricScale;
  9211. /**
  9212. * Reorder the light in the scene according to their defined priority.
  9213. * @hidden Internal Use Only
  9214. */
  9215. _reorderLightsInScene(): void;
  9216. /**
  9217. * Prepares the list of defines specific to the light type.
  9218. * @param defines the list of defines
  9219. * @param lightIndex defines the index of the light for the effect
  9220. */
  9221. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9222. }
  9223. }
  9224. declare module BABYLON {
  9225. /** Defines supported spaces */
  9226. export enum Space {
  9227. /** Local (object) space */
  9228. LOCAL = 0,
  9229. /** World space */
  9230. WORLD = 1,
  9231. /** Bone space */
  9232. BONE = 2
  9233. }
  9234. /** Defines the 3 main axes */
  9235. export class Axis {
  9236. /** X axis */
  9237. static X: Vector3;
  9238. /** Y axis */
  9239. static Y: Vector3;
  9240. /** Z axis */
  9241. static Z: Vector3;
  9242. }
  9243. /**
  9244. * Defines cartesian components.
  9245. */
  9246. export enum Coordinate {
  9247. /** X axis */
  9248. X = 0,
  9249. /** Y axis */
  9250. Y = 1,
  9251. /** Z axis */
  9252. Z = 2
  9253. }
  9254. }
  9255. declare module BABYLON {
  9256. /**
  9257. * Interface describing all the common properties and methods a shadow light needs to implement.
  9258. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9259. * as well as binding the different shadow properties to the effects.
  9260. */
  9261. export interface IShadowLight extends Light {
  9262. /**
  9263. * The light id in the scene (used in scene.findLighById for instance)
  9264. */
  9265. id: string;
  9266. /**
  9267. * The position the shdow will be casted from.
  9268. */
  9269. position: Vector3;
  9270. /**
  9271. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9272. */
  9273. direction: Vector3;
  9274. /**
  9275. * The transformed position. Position of the light in world space taking parenting in account.
  9276. */
  9277. transformedPosition: Vector3;
  9278. /**
  9279. * The transformed direction. Direction of the light in world space taking parenting in account.
  9280. */
  9281. transformedDirection: Vector3;
  9282. /**
  9283. * The friendly name of the light in the scene.
  9284. */
  9285. name: string;
  9286. /**
  9287. * Defines the shadow projection clipping minimum z value.
  9288. */
  9289. shadowMinZ: number;
  9290. /**
  9291. * Defines the shadow projection clipping maximum z value.
  9292. */
  9293. shadowMaxZ: number;
  9294. /**
  9295. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9296. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9297. */
  9298. computeTransformedInformation(): boolean;
  9299. /**
  9300. * Gets the scene the light belongs to.
  9301. * @returns The scene
  9302. */
  9303. getScene(): Scene;
  9304. /**
  9305. * Callback defining a custom Projection Matrix Builder.
  9306. * This can be used to override the default projection matrix computation.
  9307. */
  9308. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9309. /**
  9310. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9311. * @param matrix The materix to updated with the projection information
  9312. * @param viewMatrix The transform matrix of the light
  9313. * @param renderList The list of mesh to render in the map
  9314. * @returns The current light
  9315. */
  9316. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9317. /**
  9318. * Gets the current depth scale used in ESM.
  9319. * @returns The scale
  9320. */
  9321. getDepthScale(): number;
  9322. /**
  9323. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9324. * @returns true if a cube texture needs to be use
  9325. */
  9326. needCube(): boolean;
  9327. /**
  9328. * Detects if the projection matrix requires to be recomputed this frame.
  9329. * @returns true if it requires to be recomputed otherwise, false.
  9330. */
  9331. needProjectionMatrixCompute(): boolean;
  9332. /**
  9333. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9334. */
  9335. forceProjectionMatrixCompute(): void;
  9336. /**
  9337. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9338. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9339. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9340. */
  9341. getShadowDirection(faceIndex?: number): Vector3;
  9342. /**
  9343. * Gets the minZ used for shadow according to both the scene and the light.
  9344. * @param activeCamera The camera we are returning the min for
  9345. * @returns the depth min z
  9346. */
  9347. getDepthMinZ(activeCamera: Camera): number;
  9348. /**
  9349. * Gets the maxZ used for shadow according to both the scene and the light.
  9350. * @param activeCamera The camera we are returning the max for
  9351. * @returns the depth max z
  9352. */
  9353. getDepthMaxZ(activeCamera: Camera): number;
  9354. }
  9355. /**
  9356. * Base implementation IShadowLight
  9357. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9358. */
  9359. export abstract class ShadowLight extends Light implements IShadowLight {
  9360. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9361. protected _position: Vector3;
  9362. protected _setPosition(value: Vector3): void;
  9363. /**
  9364. * Sets the position the shadow will be casted from. Also use as the light position for both
  9365. * point and spot lights.
  9366. */
  9367. get position(): Vector3;
  9368. /**
  9369. * Sets the position the shadow will be casted from. Also use as the light position for both
  9370. * point and spot lights.
  9371. */
  9372. set position(value: Vector3);
  9373. protected _direction: Vector3;
  9374. protected _setDirection(value: Vector3): void;
  9375. /**
  9376. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9377. * Also use as the light direction on spot and directional lights.
  9378. */
  9379. get direction(): Vector3;
  9380. /**
  9381. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9382. * Also use as the light direction on spot and directional lights.
  9383. */
  9384. set direction(value: Vector3);
  9385. protected _shadowMinZ: number;
  9386. /**
  9387. * Gets the shadow projection clipping minimum z value.
  9388. */
  9389. get shadowMinZ(): number;
  9390. /**
  9391. * Sets the shadow projection clipping minimum z value.
  9392. */
  9393. set shadowMinZ(value: number);
  9394. protected _shadowMaxZ: number;
  9395. /**
  9396. * Sets the shadow projection clipping maximum z value.
  9397. */
  9398. get shadowMaxZ(): number;
  9399. /**
  9400. * Gets the shadow projection clipping maximum z value.
  9401. */
  9402. set shadowMaxZ(value: number);
  9403. /**
  9404. * Callback defining a custom Projection Matrix Builder.
  9405. * This can be used to override the default projection matrix computation.
  9406. */
  9407. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9408. /**
  9409. * The transformed position. Position of the light in world space taking parenting in account.
  9410. */
  9411. transformedPosition: Vector3;
  9412. /**
  9413. * The transformed direction. Direction of the light in world space taking parenting in account.
  9414. */
  9415. transformedDirection: Vector3;
  9416. private _needProjectionMatrixCompute;
  9417. /**
  9418. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9419. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9420. */
  9421. computeTransformedInformation(): boolean;
  9422. /**
  9423. * Return the depth scale used for the shadow map.
  9424. * @returns the depth scale.
  9425. */
  9426. getDepthScale(): number;
  9427. /**
  9428. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9429. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9430. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9431. */
  9432. getShadowDirection(faceIndex?: number): Vector3;
  9433. /**
  9434. * Returns the ShadowLight absolute position in the World.
  9435. * @returns the position vector in world space
  9436. */
  9437. getAbsolutePosition(): Vector3;
  9438. /**
  9439. * Sets the ShadowLight direction toward the passed target.
  9440. * @param target The point to target in local space
  9441. * @returns the updated ShadowLight direction
  9442. */
  9443. setDirectionToTarget(target: Vector3): Vector3;
  9444. /**
  9445. * Returns the light rotation in euler definition.
  9446. * @returns the x y z rotation in local space.
  9447. */
  9448. getRotation(): Vector3;
  9449. /**
  9450. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9451. * @returns true if a cube texture needs to be use
  9452. */
  9453. needCube(): boolean;
  9454. /**
  9455. * Detects if the projection matrix requires to be recomputed this frame.
  9456. * @returns true if it requires to be recomputed otherwise, false.
  9457. */
  9458. needProjectionMatrixCompute(): boolean;
  9459. /**
  9460. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9461. */
  9462. forceProjectionMatrixCompute(): void;
  9463. /** @hidden */
  9464. _initCache(): void;
  9465. /** @hidden */
  9466. _isSynchronized(): boolean;
  9467. /**
  9468. * Computes the world matrix of the node
  9469. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9470. * @returns the world matrix
  9471. */
  9472. computeWorldMatrix(force?: boolean): Matrix;
  9473. /**
  9474. * Gets the minZ used for shadow according to both the scene and the light.
  9475. * @param activeCamera The camera we are returning the min for
  9476. * @returns the depth min z
  9477. */
  9478. getDepthMinZ(activeCamera: Camera): number;
  9479. /**
  9480. * Gets the maxZ used for shadow according to both the scene and the light.
  9481. * @param activeCamera The camera we are returning the max for
  9482. * @returns the depth max z
  9483. */
  9484. getDepthMaxZ(activeCamera: Camera): number;
  9485. /**
  9486. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9487. * @param matrix The materix to updated with the projection information
  9488. * @param viewMatrix The transform matrix of the light
  9489. * @param renderList The list of mesh to render in the map
  9490. * @returns The current light
  9491. */
  9492. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9493. }
  9494. }
  9495. declare module BABYLON {
  9496. /**
  9497. * Configuration needed for prepass-capable materials
  9498. */
  9499. export class PrePassConfiguration {
  9500. /**
  9501. * Previous world matrices of meshes carrying this material
  9502. * Used for computing velocity
  9503. */
  9504. previousWorldMatrices: {
  9505. [index: number]: Matrix;
  9506. };
  9507. /**
  9508. * Previous view project matrix
  9509. * Used for computing velocity
  9510. */
  9511. previousViewProjection: Matrix;
  9512. /**
  9513. * Previous bones of meshes carrying this material
  9514. * Used for computing velocity
  9515. */
  9516. previousBones: {
  9517. [index: number]: Float32Array;
  9518. };
  9519. /**
  9520. * Add the required uniforms to the current list.
  9521. * @param uniforms defines the current uniform list.
  9522. */
  9523. static AddUniforms(uniforms: string[]): void;
  9524. /**
  9525. * Add the required samplers to the current list.
  9526. * @param samplers defines the current sampler list.
  9527. */
  9528. static AddSamplers(samplers: string[]): void;
  9529. /**
  9530. * Binds the material data.
  9531. * @param effect defines the effect to update
  9532. * @param scene defines the scene the material belongs to.
  9533. * @param mesh The mesh
  9534. * @param world World matrix of this mesh
  9535. * @param isFrozen Is the material frozen
  9536. */
  9537. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9538. }
  9539. }
  9540. declare module BABYLON {
  9541. /**
  9542. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9543. * This is the base of the follow, arc rotate cameras and Free camera
  9544. * @see https://doc.babylonjs.com/features/cameras
  9545. */
  9546. export class TargetCamera extends Camera {
  9547. private static _RigCamTransformMatrix;
  9548. private static _TargetTransformMatrix;
  9549. private static _TargetFocalPoint;
  9550. private _tmpUpVector;
  9551. private _tmpTargetVector;
  9552. /**
  9553. * Define the current direction the camera is moving to
  9554. */
  9555. cameraDirection: Vector3;
  9556. /**
  9557. * Define the current rotation the camera is rotating to
  9558. */
  9559. cameraRotation: Vector2;
  9560. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9561. ignoreParentScaling: boolean;
  9562. /**
  9563. * When set, the up vector of the camera will be updated by the rotation of the camera
  9564. */
  9565. updateUpVectorFromRotation: boolean;
  9566. private _tmpQuaternion;
  9567. /**
  9568. * Define the current rotation of the camera
  9569. */
  9570. rotation: Vector3;
  9571. /**
  9572. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9573. */
  9574. rotationQuaternion: Quaternion;
  9575. /**
  9576. * Define the current speed of the camera
  9577. */
  9578. speed: number;
  9579. /**
  9580. * Add constraint to the camera to prevent it to move freely in all directions and
  9581. * around all axis.
  9582. */
  9583. noRotationConstraint: boolean;
  9584. /**
  9585. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9586. * panning
  9587. */
  9588. invertRotation: boolean;
  9589. /**
  9590. * Speed multiplier for inverse camera panning
  9591. */
  9592. inverseRotationSpeed: number;
  9593. /**
  9594. * Define the current target of the camera as an object or a position.
  9595. */
  9596. lockedTarget: any;
  9597. /** @hidden */
  9598. _currentTarget: Vector3;
  9599. /** @hidden */
  9600. _initialFocalDistance: number;
  9601. /** @hidden */
  9602. _viewMatrix: Matrix;
  9603. /** @hidden */
  9604. _camMatrix: Matrix;
  9605. /** @hidden */
  9606. _cameraTransformMatrix: Matrix;
  9607. /** @hidden */
  9608. _cameraRotationMatrix: Matrix;
  9609. /** @hidden */
  9610. _referencePoint: Vector3;
  9611. /** @hidden */
  9612. _transformedReferencePoint: Vector3;
  9613. /** @hidden */
  9614. _reset: () => void;
  9615. private _defaultUp;
  9616. /**
  9617. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9618. * This is the base of the follow, arc rotate cameras and Free camera
  9619. * @see https://doc.babylonjs.com/features/cameras
  9620. * @param name Defines the name of the camera in the scene
  9621. * @param position Defines the start position of the camera in the scene
  9622. * @param scene Defines the scene the camera belongs to
  9623. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9624. */
  9625. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9626. /**
  9627. * Gets the position in front of the camera at a given distance.
  9628. * @param distance The distance from the camera we want the position to be
  9629. * @returns the position
  9630. */
  9631. getFrontPosition(distance: number): Vector3;
  9632. /** @hidden */
  9633. _getLockedTargetPosition(): Nullable<Vector3>;
  9634. private _storedPosition;
  9635. private _storedRotation;
  9636. private _storedRotationQuaternion;
  9637. /**
  9638. * Store current camera state of the camera (fov, position, rotation, etc..)
  9639. * @returns the camera
  9640. */
  9641. storeState(): Camera;
  9642. /**
  9643. * Restored camera state. You must call storeState() first
  9644. * @returns whether it was successful or not
  9645. * @hidden
  9646. */
  9647. _restoreStateValues(): boolean;
  9648. /** @hidden */
  9649. _initCache(): void;
  9650. /** @hidden */
  9651. _updateCache(ignoreParentClass?: boolean): void;
  9652. /** @hidden */
  9653. _isSynchronizedViewMatrix(): boolean;
  9654. /** @hidden */
  9655. _computeLocalCameraSpeed(): number;
  9656. /**
  9657. * Defines the target the camera should look at.
  9658. * @param target Defines the new target as a Vector or a mesh
  9659. */
  9660. setTarget(target: Vector3): void;
  9661. /**
  9662. * Defines the target point of the camera.
  9663. * The camera looks towards it form the radius distance.
  9664. */
  9665. get target(): Vector3;
  9666. set target(value: Vector3);
  9667. /**
  9668. * Return the current target position of the camera. This value is expressed in local space.
  9669. * @returns the target position
  9670. */
  9671. getTarget(): Vector3;
  9672. /** @hidden */
  9673. _decideIfNeedsToMove(): boolean;
  9674. /** @hidden */
  9675. _updatePosition(): void;
  9676. /** @hidden */
  9677. _checkInputs(): void;
  9678. protected _updateCameraRotationMatrix(): void;
  9679. /**
  9680. * 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)
  9681. * @returns the current camera
  9682. */
  9683. private _rotateUpVectorWithCameraRotationMatrix;
  9684. private _cachedRotationZ;
  9685. private _cachedQuaternionRotationZ;
  9686. /** @hidden */
  9687. _getViewMatrix(): Matrix;
  9688. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9689. /**
  9690. * @hidden
  9691. */
  9692. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9693. /**
  9694. * @hidden
  9695. */
  9696. _updateRigCameras(): void;
  9697. private _getRigCamPositionAndTarget;
  9698. /**
  9699. * Gets the current object class name.
  9700. * @return the class name
  9701. */
  9702. getClassName(): string;
  9703. }
  9704. }
  9705. declare module BABYLON {
  9706. /**
  9707. * @ignore
  9708. * This is a list of all the different input types that are available in the application.
  9709. * Fo instance: ArcRotateCameraGamepadInput...
  9710. */
  9711. export var CameraInputTypes: {};
  9712. /**
  9713. * This is the contract to implement in order to create a new input class.
  9714. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9715. */
  9716. export interface ICameraInput<TCamera extends Camera> {
  9717. /**
  9718. * Defines the camera the input is attached to.
  9719. */
  9720. camera: Nullable<TCamera>;
  9721. /**
  9722. * Gets the class name of the current intput.
  9723. * @returns the class name
  9724. */
  9725. getClassName(): string;
  9726. /**
  9727. * Get the friendly name associated with the input class.
  9728. * @returns the input friendly name
  9729. */
  9730. getSimpleName(): string;
  9731. /**
  9732. * Attach the input controls to a specific dom element to get the input from.
  9733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9734. */
  9735. attachControl(noPreventDefault?: boolean): void;
  9736. /**
  9737. * Detach the current controls from the specified dom element.
  9738. */
  9739. detachControl(): void;
  9740. /**
  9741. * Update the current camera state depending on the inputs that have been used this frame.
  9742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9743. */
  9744. checkInputs?: () => void;
  9745. }
  9746. /**
  9747. * Represents a map of input types to input instance or input index to input instance.
  9748. */
  9749. export interface CameraInputsMap<TCamera extends Camera> {
  9750. /**
  9751. * Accessor to the input by input type.
  9752. */
  9753. [name: string]: ICameraInput<TCamera>;
  9754. /**
  9755. * Accessor to the input by input index.
  9756. */
  9757. [idx: number]: ICameraInput<TCamera>;
  9758. }
  9759. /**
  9760. * This represents the input manager used within a camera.
  9761. * It helps dealing with all the different kind of input attached to a camera.
  9762. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9763. */
  9764. export class CameraInputsManager<TCamera extends Camera> {
  9765. /**
  9766. * Defines the list of inputs attahed to the camera.
  9767. */
  9768. attached: CameraInputsMap<TCamera>;
  9769. /**
  9770. * Defines the dom element the camera is collecting inputs from.
  9771. * This is null if the controls have not been attached.
  9772. */
  9773. attachedToElement: boolean;
  9774. /**
  9775. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9776. */
  9777. noPreventDefault: boolean;
  9778. /**
  9779. * Defined the camera the input manager belongs to.
  9780. */
  9781. camera: TCamera;
  9782. /**
  9783. * Update the current camera state depending on the inputs that have been used this frame.
  9784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9785. */
  9786. checkInputs: () => void;
  9787. /**
  9788. * Instantiate a new Camera Input Manager.
  9789. * @param camera Defines the camera the input manager blongs to
  9790. */
  9791. constructor(camera: TCamera);
  9792. /**
  9793. * Add an input method to a camera
  9794. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9795. * @param input camera input method
  9796. */
  9797. add(input: ICameraInput<TCamera>): void;
  9798. /**
  9799. * Remove a specific input method from a camera
  9800. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9801. * @param inputToRemove camera input method
  9802. */
  9803. remove(inputToRemove: ICameraInput<TCamera>): void;
  9804. /**
  9805. * Remove a specific input type from a camera
  9806. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9807. * @param inputType the type of the input to remove
  9808. */
  9809. removeByType(inputType: string): void;
  9810. private _addCheckInputs;
  9811. /**
  9812. * Attach the input controls to the currently attached dom element to listen the events from.
  9813. * @param input Defines the input to attach
  9814. */
  9815. attachInput(input: ICameraInput<TCamera>): void;
  9816. /**
  9817. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9818. * @param element Defines the dom element to collect the events from
  9819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9820. */
  9821. attachElement(noPreventDefault?: boolean): void;
  9822. /**
  9823. * Detach the current manager inputs controls from a specific dom element.
  9824. * @param element Defines the dom element to collect the events from
  9825. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9826. */
  9827. detachElement(disconnect?: boolean): void;
  9828. /**
  9829. * Rebuild the dynamic inputCheck function from the current list of
  9830. * defined inputs in the manager.
  9831. */
  9832. rebuildInputCheck(): void;
  9833. /**
  9834. * Remove all attached input methods from a camera
  9835. */
  9836. clear(): void;
  9837. /**
  9838. * Serialize the current input manager attached to a camera.
  9839. * This ensures than once parsed,
  9840. * the input associated to the camera will be identical to the current ones
  9841. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9842. */
  9843. serialize(serializedCamera: any): void;
  9844. /**
  9845. * Parses an input manager serialized JSON to restore the previous list of inputs
  9846. * and states associated to a camera.
  9847. * @param parsedCamera Defines the JSON to parse
  9848. */
  9849. parse(parsedCamera: any): void;
  9850. }
  9851. }
  9852. declare module BABYLON {
  9853. /**
  9854. * Gather the list of keyboard event types as constants.
  9855. */
  9856. export class KeyboardEventTypes {
  9857. /**
  9858. * The keydown event is fired when a key becomes active (pressed).
  9859. */
  9860. static readonly KEYDOWN: number;
  9861. /**
  9862. * The keyup event is fired when a key has been released.
  9863. */
  9864. static readonly KEYUP: number;
  9865. }
  9866. /**
  9867. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9868. */
  9869. export class KeyboardInfo {
  9870. /**
  9871. * Defines the type of event (KeyboardEventTypes)
  9872. */
  9873. type: number;
  9874. /**
  9875. * Defines the related dom event
  9876. */
  9877. event: KeyboardEvent;
  9878. /**
  9879. * Instantiates a new keyboard info.
  9880. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9881. * @param type Defines the type of event (KeyboardEventTypes)
  9882. * @param event Defines the related dom event
  9883. */
  9884. constructor(
  9885. /**
  9886. * Defines the type of event (KeyboardEventTypes)
  9887. */
  9888. type: number,
  9889. /**
  9890. * Defines the related dom event
  9891. */
  9892. event: KeyboardEvent);
  9893. }
  9894. /**
  9895. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9896. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9897. */
  9898. export class KeyboardInfoPre extends KeyboardInfo {
  9899. /**
  9900. * Defines the type of event (KeyboardEventTypes)
  9901. */
  9902. type: number;
  9903. /**
  9904. * Defines the related dom event
  9905. */
  9906. event: KeyboardEvent;
  9907. /**
  9908. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9909. */
  9910. skipOnPointerObservable: boolean;
  9911. /**
  9912. * Instantiates a new keyboard pre info.
  9913. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9914. * @param type Defines the type of event (KeyboardEventTypes)
  9915. * @param event Defines the related dom event
  9916. */
  9917. constructor(
  9918. /**
  9919. * Defines the type of event (KeyboardEventTypes)
  9920. */
  9921. type: number,
  9922. /**
  9923. * Defines the related dom event
  9924. */
  9925. event: KeyboardEvent);
  9926. }
  9927. }
  9928. declare module BABYLON {
  9929. /**
  9930. * Manage the keyboard inputs to control the movement of a free camera.
  9931. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9932. */
  9933. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9934. /**
  9935. * Defines the camera the input is attached to.
  9936. */
  9937. camera: FreeCamera;
  9938. /**
  9939. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9940. */
  9941. keysUp: number[];
  9942. /**
  9943. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9944. */
  9945. keysUpward: number[];
  9946. /**
  9947. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9948. */
  9949. keysDown: number[];
  9950. /**
  9951. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9952. */
  9953. keysDownward: number[];
  9954. /**
  9955. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9956. */
  9957. keysLeft: number[];
  9958. /**
  9959. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9960. */
  9961. keysRight: number[];
  9962. private _keys;
  9963. private _onCanvasBlurObserver;
  9964. private _onKeyboardObserver;
  9965. private _engine;
  9966. private _scene;
  9967. /**
  9968. * Attach the input controls to a specific dom element to get the input from.
  9969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9970. */
  9971. attachControl(noPreventDefault?: boolean): void;
  9972. /**
  9973. * Detach the current controls from the specified dom element.
  9974. */
  9975. detachControl(): void;
  9976. /**
  9977. * Update the current camera state depending on the inputs that have been used this frame.
  9978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9979. */
  9980. checkInputs(): void;
  9981. /**
  9982. * Gets the class name of the current intput.
  9983. * @returns the class name
  9984. */
  9985. getClassName(): string;
  9986. /** @hidden */
  9987. _onLostFocus(): void;
  9988. /**
  9989. * Get the friendly name associated with the input class.
  9990. * @returns the input friendly name
  9991. */
  9992. getSimpleName(): string;
  9993. }
  9994. }
  9995. declare module BABYLON {
  9996. /**
  9997. * Interface used to define Action
  9998. */
  9999. export interface IAction {
  10000. /**
  10001. * Trigger for the action
  10002. */
  10003. trigger: number;
  10004. /** Options of the trigger */
  10005. triggerOptions: any;
  10006. /**
  10007. * Gets the trigger parameters
  10008. * @returns the trigger parameters
  10009. */
  10010. getTriggerParameter(): any;
  10011. /**
  10012. * Internal only - executes current action event
  10013. * @hidden
  10014. */
  10015. _executeCurrent(evt?: ActionEvent): void;
  10016. /**
  10017. * Serialize placeholder for child classes
  10018. * @param parent of child
  10019. * @returns the serialized object
  10020. */
  10021. serialize(parent: any): any;
  10022. /**
  10023. * Internal only
  10024. * @hidden
  10025. */
  10026. _prepare(): void;
  10027. /**
  10028. * Internal only - manager for action
  10029. * @hidden
  10030. */
  10031. _actionManager: Nullable<AbstractActionManager>;
  10032. /**
  10033. * Adds action to chain of actions, may be a DoNothingAction
  10034. * @param action defines the next action to execute
  10035. * @returns The action passed in
  10036. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10037. */
  10038. then(action: IAction): IAction;
  10039. }
  10040. /**
  10041. * The action to be carried out following a trigger
  10042. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10043. */
  10044. export class Action implements IAction {
  10045. /** the trigger, with or without parameters, for the action */
  10046. triggerOptions: any;
  10047. /**
  10048. * Trigger for the action
  10049. */
  10050. trigger: number;
  10051. /**
  10052. * Internal only - manager for action
  10053. * @hidden
  10054. */
  10055. _actionManager: ActionManager;
  10056. private _nextActiveAction;
  10057. private _child;
  10058. private _condition?;
  10059. private _triggerParameter;
  10060. /**
  10061. * An event triggered prior to action being executed.
  10062. */
  10063. onBeforeExecuteObservable: Observable<Action>;
  10064. /**
  10065. * Creates a new Action
  10066. * @param triggerOptions the trigger, with or without parameters, for the action
  10067. * @param condition an optional determinant of action
  10068. */
  10069. constructor(
  10070. /** the trigger, with or without parameters, for the action */
  10071. triggerOptions: any, condition?: Condition);
  10072. /**
  10073. * Internal only
  10074. * @hidden
  10075. */
  10076. _prepare(): void;
  10077. /**
  10078. * Gets the trigger parameter
  10079. * @returns the trigger parameter
  10080. */
  10081. getTriggerParameter(): any;
  10082. /**
  10083. * Sets the trigger parameter
  10084. * @param value defines the new trigger parameter
  10085. */
  10086. setTriggerParameter(value: any): void;
  10087. /**
  10088. * Internal only - executes current action event
  10089. * @hidden
  10090. */
  10091. _executeCurrent(evt?: ActionEvent): void;
  10092. /**
  10093. * Execute placeholder for child classes
  10094. * @param evt optional action event
  10095. */
  10096. execute(evt?: ActionEvent): void;
  10097. /**
  10098. * Skips to next active action
  10099. */
  10100. skipToNextActiveAction(): void;
  10101. /**
  10102. * Adds action to chain of actions, may be a DoNothingAction
  10103. * @param action defines the next action to execute
  10104. * @returns The action passed in
  10105. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10106. */
  10107. then(action: Action): Action;
  10108. /**
  10109. * Internal only
  10110. * @hidden
  10111. */
  10112. _getProperty(propertyPath: string): string;
  10113. /**
  10114. * Internal only
  10115. * @hidden
  10116. */
  10117. _getEffectiveTarget(target: any, propertyPath: string): any;
  10118. /**
  10119. * Serialize placeholder for child classes
  10120. * @param parent of child
  10121. * @returns the serialized object
  10122. */
  10123. serialize(parent: any): any;
  10124. /**
  10125. * Internal only called by serialize
  10126. * @hidden
  10127. */
  10128. protected _serialize(serializedAction: any, parent?: any): any;
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */
  10133. static _SerializeValueAsString: (value: any) => string;
  10134. /**
  10135. * Internal only
  10136. * @hidden
  10137. */
  10138. static _GetTargetProperty: (target: Scene | Node) => {
  10139. name: string;
  10140. targetType: string;
  10141. value: string;
  10142. };
  10143. }
  10144. }
  10145. declare module BABYLON {
  10146. /**
  10147. * A Condition applied to an Action
  10148. */
  10149. export class Condition {
  10150. /**
  10151. * Internal only - manager for action
  10152. * @hidden
  10153. */
  10154. _actionManager: ActionManager;
  10155. /**
  10156. * Internal only
  10157. * @hidden
  10158. */
  10159. _evaluationId: number;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. _currentResult: boolean;
  10165. /**
  10166. * Creates a new Condition
  10167. * @param actionManager the manager of the action the condition is applied to
  10168. */
  10169. constructor(actionManager: ActionManager);
  10170. /**
  10171. * Check if the current condition is valid
  10172. * @returns a boolean
  10173. */
  10174. isValid(): boolean;
  10175. /**
  10176. * Internal only
  10177. * @hidden
  10178. */
  10179. _getProperty(propertyPath: string): string;
  10180. /**
  10181. * Internal only
  10182. * @hidden
  10183. */
  10184. _getEffectiveTarget(target: any, propertyPath: string): any;
  10185. /**
  10186. * Serialize placeholder for child classes
  10187. * @returns the serialized object
  10188. */
  10189. serialize(): any;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. protected _serialize(serializedCondition: any): any;
  10195. }
  10196. /**
  10197. * Defines specific conditional operators as extensions of Condition
  10198. */
  10199. export class ValueCondition extends Condition {
  10200. /** path to specify the property of the target the conditional operator uses */
  10201. propertyPath: string;
  10202. /** the value compared by the conditional operator against the current value of the property */
  10203. value: any;
  10204. /** the conditional operator, default ValueCondition.IsEqual */
  10205. operator: number;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. private static _IsEqual;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. private static _IsDifferent;
  10216. /**
  10217. * Internal only
  10218. * @hidden
  10219. */
  10220. private static _IsGreater;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. private static _IsLesser;
  10226. /**
  10227. * returns the number for IsEqual
  10228. */
  10229. static get IsEqual(): number;
  10230. /**
  10231. * Returns the number for IsDifferent
  10232. */
  10233. static get IsDifferent(): number;
  10234. /**
  10235. * Returns the number for IsGreater
  10236. */
  10237. static get IsGreater(): number;
  10238. /**
  10239. * Returns the number for IsLesser
  10240. */
  10241. static get IsLesser(): number;
  10242. /**
  10243. * Internal only The action manager for the condition
  10244. * @hidden
  10245. */
  10246. _actionManager: ActionManager;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. private _target;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. private _effectiveTarget;
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. private _property;
  10262. /**
  10263. * Creates a new ValueCondition
  10264. * @param actionManager manager for the action the condition applies to
  10265. * @param target for the action
  10266. * @param propertyPath path to specify the property of the target the conditional operator uses
  10267. * @param value the value compared by the conditional operator against the current value of the property
  10268. * @param operator the conditional operator, default ValueCondition.IsEqual
  10269. */
  10270. constructor(actionManager: ActionManager, target: any,
  10271. /** path to specify the property of the target the conditional operator uses */
  10272. propertyPath: string,
  10273. /** the value compared by the conditional operator against the current value of the property */
  10274. value: any,
  10275. /** the conditional operator, default ValueCondition.IsEqual */
  10276. operator?: number);
  10277. /**
  10278. * Compares the given value with the property value for the specified conditional operator
  10279. * @returns the result of the comparison
  10280. */
  10281. isValid(): boolean;
  10282. /**
  10283. * Serialize the ValueCondition into a JSON compatible object
  10284. * @returns serialization object
  10285. */
  10286. serialize(): any;
  10287. /**
  10288. * Gets the name of the conditional operator for the ValueCondition
  10289. * @param operator the conditional operator
  10290. * @returns the name
  10291. */
  10292. static GetOperatorName(operator: number): string;
  10293. }
  10294. /**
  10295. * Defines a predicate condition as an extension of Condition
  10296. */
  10297. export class PredicateCondition extends Condition {
  10298. /** defines the predicate function used to validate the condition */
  10299. predicate: () => boolean;
  10300. /**
  10301. * Internal only - manager for action
  10302. * @hidden
  10303. */
  10304. _actionManager: ActionManager;
  10305. /**
  10306. * Creates a new PredicateCondition
  10307. * @param actionManager manager for the action the condition applies to
  10308. * @param predicate defines the predicate function used to validate the condition
  10309. */
  10310. constructor(actionManager: ActionManager,
  10311. /** defines the predicate function used to validate the condition */
  10312. predicate: () => boolean);
  10313. /**
  10314. * @returns the validity of the predicate condition
  10315. */
  10316. isValid(): boolean;
  10317. }
  10318. /**
  10319. * Defines a state condition as an extension of Condition
  10320. */
  10321. export class StateCondition extends Condition {
  10322. /** Value to compare with target state */
  10323. value: string;
  10324. /**
  10325. * Internal only - manager for action
  10326. * @hidden
  10327. */
  10328. _actionManager: ActionManager;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. private _target;
  10334. /**
  10335. * Creates a new StateCondition
  10336. * @param actionManager manager for the action the condition applies to
  10337. * @param target of the condition
  10338. * @param value to compare with target state
  10339. */
  10340. constructor(actionManager: ActionManager, target: any,
  10341. /** Value to compare with target state */
  10342. value: string);
  10343. /**
  10344. * Gets a boolean indicating if the current condition is met
  10345. * @returns the validity of the state
  10346. */
  10347. isValid(): boolean;
  10348. /**
  10349. * Serialize the StateCondition into a JSON compatible object
  10350. * @returns serialization object
  10351. */
  10352. serialize(): any;
  10353. }
  10354. }
  10355. declare module BABYLON {
  10356. /**
  10357. * This defines an action responsible to toggle a boolean once triggered.
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10359. */
  10360. export class SwitchBooleanAction extends Action {
  10361. /**
  10362. * The path to the boolean property in the target object
  10363. */
  10364. propertyPath: string;
  10365. private _target;
  10366. private _effectiveTarget;
  10367. private _property;
  10368. /**
  10369. * Instantiate the action
  10370. * @param triggerOptions defines the trigger options
  10371. * @param target defines the object containing the boolean
  10372. * @param propertyPath defines the path to the boolean property in the target object
  10373. * @param condition defines the trigger related conditions
  10374. */
  10375. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10376. /** @hidden */
  10377. _prepare(): void;
  10378. /**
  10379. * Execute the action toggle the boolean value.
  10380. */
  10381. execute(): void;
  10382. /**
  10383. * Serializes the actions and its related information.
  10384. * @param parent defines the object to serialize in
  10385. * @returns the serialized object
  10386. */
  10387. serialize(parent: any): any;
  10388. }
  10389. /**
  10390. * This defines an action responsible to set a the state field of the target
  10391. * to a desired value once triggered.
  10392. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10393. */
  10394. export class SetStateAction extends Action {
  10395. /**
  10396. * The value to store in the state field.
  10397. */
  10398. value: string;
  10399. private _target;
  10400. /**
  10401. * Instantiate the action
  10402. * @param triggerOptions defines the trigger options
  10403. * @param target defines the object containing the state property
  10404. * @param value defines the value to store in the state field
  10405. * @param condition defines the trigger related conditions
  10406. */
  10407. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10408. /**
  10409. * Execute the action and store the value on the target state property.
  10410. */
  10411. execute(): void;
  10412. /**
  10413. * Serializes the actions and its related information.
  10414. * @param parent defines the object to serialize in
  10415. * @returns the serialized object
  10416. */
  10417. serialize(parent: any): any;
  10418. }
  10419. /**
  10420. * This defines an action responsible to set a property of the target
  10421. * to a desired value once triggered.
  10422. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10423. */
  10424. export class SetValueAction extends Action {
  10425. /**
  10426. * The path of the property to set in the target.
  10427. */
  10428. propertyPath: string;
  10429. /**
  10430. * The value to set in the property
  10431. */
  10432. value: any;
  10433. private _target;
  10434. private _effectiveTarget;
  10435. private _property;
  10436. /**
  10437. * Instantiate the action
  10438. * @param triggerOptions defines the trigger options
  10439. * @param target defines the object containing the property
  10440. * @param propertyPath defines the path of the property to set in the target
  10441. * @param value defines the value to set in the property
  10442. * @param condition defines the trigger related conditions
  10443. */
  10444. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10445. /** @hidden */
  10446. _prepare(): void;
  10447. /**
  10448. * Execute the action and set the targetted property to the desired value.
  10449. */
  10450. execute(): void;
  10451. /**
  10452. * Serializes the actions and its related information.
  10453. * @param parent defines the object to serialize in
  10454. * @returns the serialized object
  10455. */
  10456. serialize(parent: any): any;
  10457. }
  10458. /**
  10459. * This defines an action responsible to increment the target value
  10460. * to a desired value once triggered.
  10461. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10462. */
  10463. export class IncrementValueAction extends Action {
  10464. /**
  10465. * The path of the property to increment in the target.
  10466. */
  10467. propertyPath: string;
  10468. /**
  10469. * The value we should increment the property by.
  10470. */
  10471. value: any;
  10472. private _target;
  10473. private _effectiveTarget;
  10474. private _property;
  10475. /**
  10476. * Instantiate the action
  10477. * @param triggerOptions defines the trigger options
  10478. * @param target defines the object containing the property
  10479. * @param propertyPath defines the path of the property to increment in the target
  10480. * @param value defines the value value we should increment the property by
  10481. * @param condition defines the trigger related conditions
  10482. */
  10483. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10484. /** @hidden */
  10485. _prepare(): void;
  10486. /**
  10487. * Execute the action and increment the target of the value amount.
  10488. */
  10489. execute(): void;
  10490. /**
  10491. * Serializes the actions and its related information.
  10492. * @param parent defines the object to serialize in
  10493. * @returns the serialized object
  10494. */
  10495. serialize(parent: any): any;
  10496. }
  10497. /**
  10498. * This defines an action responsible to start an animation once triggered.
  10499. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class PlayAnimationAction extends Action {
  10502. /**
  10503. * Where the animation should start (animation frame)
  10504. */
  10505. from: number;
  10506. /**
  10507. * Where the animation should stop (animation frame)
  10508. */
  10509. to: number;
  10510. /**
  10511. * Define if the animation should loop or stop after the first play.
  10512. */
  10513. loop?: boolean;
  10514. private _target;
  10515. /**
  10516. * Instantiate the action
  10517. * @param triggerOptions defines the trigger options
  10518. * @param target defines the target animation or animation name
  10519. * @param from defines from where the animation should start (animation frame)
  10520. * @param end defines where the animation should stop (animation frame)
  10521. * @param loop defines if the animation should loop or stop after the first play
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10525. /** @hidden */
  10526. _prepare(): void;
  10527. /**
  10528. * Execute the action and play the animation.
  10529. */
  10530. execute(): void;
  10531. /**
  10532. * Serializes the actions and its related information.
  10533. * @param parent defines the object to serialize in
  10534. * @returns the serialized object
  10535. */
  10536. serialize(parent: any): any;
  10537. }
  10538. /**
  10539. * This defines an action responsible to stop an animation once triggered.
  10540. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10541. */
  10542. export class StopAnimationAction extends Action {
  10543. private _target;
  10544. /**
  10545. * Instantiate the action
  10546. * @param triggerOptions defines the trigger options
  10547. * @param target defines the target animation or animation name
  10548. * @param condition defines the trigger related conditions
  10549. */
  10550. constructor(triggerOptions: any, target: any, condition?: Condition);
  10551. /** @hidden */
  10552. _prepare(): void;
  10553. /**
  10554. * Execute the action and stop the animation.
  10555. */
  10556. execute(): void;
  10557. /**
  10558. * Serializes the actions and its related information.
  10559. * @param parent defines the object to serialize in
  10560. * @returns the serialized object
  10561. */
  10562. serialize(parent: any): any;
  10563. }
  10564. /**
  10565. * This defines an action responsible that does nothing once triggered.
  10566. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class DoNothingAction extends Action {
  10569. /**
  10570. * Instantiate the action
  10571. * @param triggerOptions defines the trigger options
  10572. * @param condition defines the trigger related conditions
  10573. */
  10574. constructor(triggerOptions?: any, condition?: Condition);
  10575. /**
  10576. * Execute the action and do nothing.
  10577. */
  10578. execute(): void;
  10579. /**
  10580. * Serializes the actions and its related information.
  10581. * @param parent defines the object to serialize in
  10582. * @returns the serialized object
  10583. */
  10584. serialize(parent: any): any;
  10585. }
  10586. /**
  10587. * This defines an action responsible to trigger several actions once triggered.
  10588. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10589. */
  10590. export class CombineAction extends Action {
  10591. /**
  10592. * The list of aggregated animations to run.
  10593. */
  10594. children: Action[];
  10595. /**
  10596. * Instantiate the action
  10597. * @param triggerOptions defines the trigger options
  10598. * @param children defines the list of aggregated animations to run
  10599. * @param condition defines the trigger related conditions
  10600. */
  10601. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10602. /** @hidden */
  10603. _prepare(): void;
  10604. /**
  10605. * Execute the action and executes all the aggregated actions.
  10606. */
  10607. execute(evt: ActionEvent): void;
  10608. /**
  10609. * Serializes the actions and its related information.
  10610. * @param parent defines the object to serialize in
  10611. * @returns the serialized object
  10612. */
  10613. serialize(parent: any): any;
  10614. }
  10615. /**
  10616. * This defines an action responsible to run code (external event) once triggered.
  10617. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10618. */
  10619. export class ExecuteCodeAction extends Action {
  10620. /**
  10621. * The callback function to run.
  10622. */
  10623. func: (evt: ActionEvent) => void;
  10624. /**
  10625. * Instantiate the action
  10626. * @param triggerOptions defines the trigger options
  10627. * @param func defines the callback function to run
  10628. * @param condition defines the trigger related conditions
  10629. */
  10630. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10631. /**
  10632. * Execute the action and run the attached code.
  10633. */
  10634. execute(evt: ActionEvent): void;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set the parent property of the target once triggered.
  10638. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10639. */
  10640. export class SetParentAction extends Action {
  10641. private _parent;
  10642. private _target;
  10643. /**
  10644. * Instantiate the action
  10645. * @param triggerOptions defines the trigger options
  10646. * @param target defines the target containing the parent property
  10647. * @param parent defines from where the animation should start (animation frame)
  10648. * @param condition defines the trigger related conditions
  10649. */
  10650. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10651. /** @hidden */
  10652. _prepare(): void;
  10653. /**
  10654. * Execute the action and set the parent property.
  10655. */
  10656. execute(): void;
  10657. /**
  10658. * Serializes the actions and its related information.
  10659. * @param parent defines the object to serialize in
  10660. * @returns the serialized object
  10661. */
  10662. serialize(parent: any): any;
  10663. }
  10664. }
  10665. declare module BABYLON {
  10666. /**
  10667. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10668. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10669. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class ActionManager extends AbstractActionManager {
  10672. /**
  10673. * Nothing
  10674. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly NothingTrigger: number;
  10677. /**
  10678. * On pick
  10679. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10680. */
  10681. static readonly OnPickTrigger: number;
  10682. /**
  10683. * On left pick
  10684. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10685. */
  10686. static readonly OnLeftPickTrigger: number;
  10687. /**
  10688. * On right pick
  10689. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnRightPickTrigger: number;
  10692. /**
  10693. * On center pick
  10694. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnCenterPickTrigger: number;
  10697. /**
  10698. * On pick down
  10699. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10700. */
  10701. static readonly OnPickDownTrigger: number;
  10702. /**
  10703. * On double pick
  10704. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10705. */
  10706. static readonly OnDoublePickTrigger: number;
  10707. /**
  10708. * On pick up
  10709. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10710. */
  10711. static readonly OnPickUpTrigger: number;
  10712. /**
  10713. * On pick out.
  10714. * This trigger will only be raised if you also declared a OnPickDown
  10715. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnPickOutTrigger: number;
  10718. /**
  10719. * On long press
  10720. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnLongPressTrigger: number;
  10723. /**
  10724. * On pointer over
  10725. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnPointerOverTrigger: number;
  10728. /**
  10729. * On pointer out
  10730. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnPointerOutTrigger: number;
  10733. /**
  10734. * On every frame
  10735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnEveryFrameTrigger: number;
  10738. /**
  10739. * On intersection enter
  10740. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnIntersectionEnterTrigger: number;
  10743. /**
  10744. * On intersection exit
  10745. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10746. */
  10747. static readonly OnIntersectionExitTrigger: number;
  10748. /**
  10749. * On key down
  10750. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10751. */
  10752. static readonly OnKeyDownTrigger: number;
  10753. /**
  10754. * On key up
  10755. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10756. */
  10757. static readonly OnKeyUpTrigger: number;
  10758. private _scene;
  10759. /**
  10760. * Creates a new action manager
  10761. * @param scene defines the hosting scene
  10762. */
  10763. constructor(scene: Scene);
  10764. /**
  10765. * Releases all associated resources
  10766. */
  10767. dispose(): void;
  10768. /**
  10769. * Gets hosting scene
  10770. * @returns the hosting scene
  10771. */
  10772. getScene(): Scene;
  10773. /**
  10774. * Does this action manager handles actions of any of the given triggers
  10775. * @param triggers defines the triggers to be tested
  10776. * @return a boolean indicating whether one (or more) of the triggers is handled
  10777. */
  10778. hasSpecificTriggers(triggers: number[]): boolean;
  10779. /**
  10780. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10781. * speed.
  10782. * @param triggerA defines the trigger to be tested
  10783. * @param triggerB defines the trigger to be tested
  10784. * @return a boolean indicating whether one (or more) of the triggers is handled
  10785. */
  10786. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10787. /**
  10788. * Does this action manager handles actions of a given trigger
  10789. * @param trigger defines the trigger to be tested
  10790. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10791. * @return whether the trigger is handled
  10792. */
  10793. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10794. /**
  10795. * Does this action manager has pointer triggers
  10796. */
  10797. get hasPointerTriggers(): boolean;
  10798. /**
  10799. * Does this action manager has pick triggers
  10800. */
  10801. get hasPickTriggers(): boolean;
  10802. /**
  10803. * Registers an action to this action manager
  10804. * @param action defines the action to be registered
  10805. * @return the action amended (prepared) after registration
  10806. */
  10807. registerAction(action: IAction): Nullable<IAction>;
  10808. /**
  10809. * Unregisters an action to this action manager
  10810. * @param action defines the action to be unregistered
  10811. * @return a boolean indicating whether the action has been unregistered
  10812. */
  10813. unregisterAction(action: IAction): Boolean;
  10814. /**
  10815. * Process a specific trigger
  10816. * @param trigger defines the trigger to process
  10817. * @param evt defines the event details to be processed
  10818. */
  10819. processTrigger(trigger: number, evt?: IActionEvent): void;
  10820. /** @hidden */
  10821. _getEffectiveTarget(target: any, propertyPath: string): any;
  10822. /** @hidden */
  10823. _getProperty(propertyPath: string): string;
  10824. /**
  10825. * Serialize this manager to a JSON object
  10826. * @param name defines the property name to store this manager
  10827. * @returns a JSON representation of this manager
  10828. */
  10829. serialize(name: string): any;
  10830. /**
  10831. * Creates a new ActionManager from a JSON data
  10832. * @param parsedActions defines the JSON data to read from
  10833. * @param object defines the hosting mesh
  10834. * @param scene defines the hosting scene
  10835. */
  10836. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10837. /**
  10838. * Get a trigger name by index
  10839. * @param trigger defines the trigger index
  10840. * @returns a trigger name
  10841. */
  10842. static GetTriggerName(trigger: number): string;
  10843. }
  10844. }
  10845. declare module BABYLON {
  10846. /**
  10847. * Class representing a ray with position and direction
  10848. */
  10849. export class Ray {
  10850. /** origin point */
  10851. origin: Vector3;
  10852. /** direction */
  10853. direction: Vector3;
  10854. /** length of the ray */
  10855. length: number;
  10856. private static readonly _TmpVector3;
  10857. private _tmpRay;
  10858. /**
  10859. * Creates a new ray
  10860. * @param origin origin point
  10861. * @param direction direction
  10862. * @param length length of the ray
  10863. */
  10864. constructor(
  10865. /** origin point */
  10866. origin: Vector3,
  10867. /** direction */
  10868. direction: Vector3,
  10869. /** length of the ray */
  10870. length?: number);
  10871. /**
  10872. * Checks if the ray intersects a box
  10873. * This does not account for the ray lenght by design to improve perfs.
  10874. * @param minimum bound of the box
  10875. * @param maximum bound of the box
  10876. * @param intersectionTreshold extra extend to be added to the box in all direction
  10877. * @returns if the box was hit
  10878. */
  10879. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10880. /**
  10881. * Checks if the ray intersects a box
  10882. * This does not account for the ray lenght by design to improve perfs.
  10883. * @param box the bounding box to check
  10884. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10885. * @returns if the box was hit
  10886. */
  10887. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10888. /**
  10889. * If the ray hits a sphere
  10890. * @param sphere the bounding sphere to check
  10891. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10892. * @returns true if it hits the sphere
  10893. */
  10894. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10895. /**
  10896. * If the ray hits a triange
  10897. * @param vertex0 triangle vertex
  10898. * @param vertex1 triangle vertex
  10899. * @param vertex2 triangle vertex
  10900. * @returns intersection information if hit
  10901. */
  10902. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10903. /**
  10904. * Checks if ray intersects a plane
  10905. * @param plane the plane to check
  10906. * @returns the distance away it was hit
  10907. */
  10908. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10909. /**
  10910. * Calculate the intercept of a ray on a given axis
  10911. * @param axis to check 'x' | 'y' | 'z'
  10912. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10913. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10914. */
  10915. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10916. /**
  10917. * Checks if ray intersects a mesh
  10918. * @param mesh the mesh to check
  10919. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10920. * @returns picking info of the intersecton
  10921. */
  10922. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10923. /**
  10924. * Checks if ray intersects a mesh
  10925. * @param meshes the meshes to check
  10926. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10927. * @param results array to store result in
  10928. * @returns Array of picking infos
  10929. */
  10930. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10931. private _comparePickingInfo;
  10932. private static smallnum;
  10933. private static rayl;
  10934. /**
  10935. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10936. * @param sega the first point of the segment to test the intersection against
  10937. * @param segb the second point of the segment to test the intersection against
  10938. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10939. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10940. */
  10941. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10942. /**
  10943. * Update the ray from viewport position
  10944. * @param x position
  10945. * @param y y position
  10946. * @param viewportWidth viewport width
  10947. * @param viewportHeight viewport height
  10948. * @param world world matrix
  10949. * @param view view matrix
  10950. * @param projection projection matrix
  10951. * @returns this ray updated
  10952. */
  10953. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10954. /**
  10955. * Creates a ray with origin and direction of 0,0,0
  10956. * @returns the new ray
  10957. */
  10958. static Zero(): Ray;
  10959. /**
  10960. * Creates a new ray from screen space and viewport
  10961. * @param x position
  10962. * @param y y position
  10963. * @param viewportWidth viewport width
  10964. * @param viewportHeight viewport height
  10965. * @param world world matrix
  10966. * @param view view matrix
  10967. * @param projection projection matrix
  10968. * @returns new ray
  10969. */
  10970. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10971. /**
  10972. * 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
  10973. * transformed to the given world matrix.
  10974. * @param origin The origin point
  10975. * @param end The end point
  10976. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10977. * @returns the new ray
  10978. */
  10979. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10980. /**
  10981. * Transforms a ray by a matrix
  10982. * @param ray ray to transform
  10983. * @param matrix matrix to apply
  10984. * @returns the resulting new ray
  10985. */
  10986. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10987. /**
  10988. * Transforms a ray by a matrix
  10989. * @param ray ray to transform
  10990. * @param matrix matrix to apply
  10991. * @param result ray to store result in
  10992. */
  10993. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10994. /**
  10995. * Unproject a ray from screen space to object space
  10996. * @param sourceX defines the screen space x coordinate to use
  10997. * @param sourceY defines the screen space y coordinate to use
  10998. * @param viewportWidth defines the current width of the viewport
  10999. * @param viewportHeight defines the current height of the viewport
  11000. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11001. * @param view defines the view matrix to use
  11002. * @param projection defines the projection matrix to use
  11003. */
  11004. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11005. }
  11006. /**
  11007. * Type used to define predicate used to select faces when a mesh intersection is detected
  11008. */
  11009. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11010. interface Scene {
  11011. /** @hidden */
  11012. _tempPickingRay: Nullable<Ray>;
  11013. /** @hidden */
  11014. _cachedRayForTransform: Ray;
  11015. /** @hidden */
  11016. _pickWithRayInverseMatrix: Matrix;
  11017. /** @hidden */
  11018. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11019. /** @hidden */
  11020. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11021. /** @hidden */
  11022. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. /**
  11027. * Groups all the scene component constants in one place to ease maintenance.
  11028. * @hidden
  11029. */
  11030. export class SceneComponentConstants {
  11031. static readonly NAME_EFFECTLAYER: string;
  11032. static readonly NAME_LAYER: string;
  11033. static readonly NAME_LENSFLARESYSTEM: string;
  11034. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11035. static readonly NAME_PARTICLESYSTEM: string;
  11036. static readonly NAME_GAMEPAD: string;
  11037. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11038. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11039. static readonly NAME_PREPASSRENDERER: string;
  11040. static readonly NAME_DEPTHRENDERER: string;
  11041. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11042. static readonly NAME_SPRITE: string;
  11043. static readonly NAME_SUBSURFACE: string;
  11044. static readonly NAME_OUTLINERENDERER: string;
  11045. static readonly NAME_PROCEDURALTEXTURE: string;
  11046. static readonly NAME_SHADOWGENERATOR: string;
  11047. static readonly NAME_OCTREE: string;
  11048. static readonly NAME_PHYSICSENGINE: string;
  11049. static readonly NAME_AUDIO: string;
  11050. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11051. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11052. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11053. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11054. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11055. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11056. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11057. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11058. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11059. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11060. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11061. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11062. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11063. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11064. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11065. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11066. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11067. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11068. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11069. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11070. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11071. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11072. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11073. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11074. static readonly STEP_AFTERRENDER_AUDIO: number;
  11075. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11076. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11077. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11078. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11079. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11080. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11081. static readonly STEP_POINTERMOVE_SPRITE: number;
  11082. static readonly STEP_POINTERDOWN_SPRITE: number;
  11083. static readonly STEP_POINTERUP_SPRITE: number;
  11084. }
  11085. /**
  11086. * This represents a scene component.
  11087. *
  11088. * This is used to decouple the dependency the scene is having on the different workloads like
  11089. * layers, post processes...
  11090. */
  11091. export interface ISceneComponent {
  11092. /**
  11093. * The name of the component. Each component must have a unique name.
  11094. */
  11095. name: string;
  11096. /**
  11097. * The scene the component belongs to.
  11098. */
  11099. scene: Scene;
  11100. /**
  11101. * Register the component to one instance of a scene.
  11102. */
  11103. register(): void;
  11104. /**
  11105. * Rebuilds the elements related to this component in case of
  11106. * context lost for instance.
  11107. */
  11108. rebuild(): void;
  11109. /**
  11110. * Disposes the component and the associated ressources.
  11111. */
  11112. dispose(): void;
  11113. }
  11114. /**
  11115. * This represents a SERIALIZABLE scene component.
  11116. *
  11117. * This extends Scene Component to add Serialization methods on top.
  11118. */
  11119. export interface ISceneSerializableComponent extends ISceneComponent {
  11120. /**
  11121. * Adds all the elements from the container to the scene
  11122. * @param container the container holding the elements
  11123. */
  11124. addFromContainer(container: AbstractScene): void;
  11125. /**
  11126. * Removes all the elements in the container from the scene
  11127. * @param container contains the elements to remove
  11128. * @param dispose if the removed element should be disposed (default: false)
  11129. */
  11130. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11131. /**
  11132. * Serializes the component data to the specified json object
  11133. * @param serializationObject The object to serialize to
  11134. */
  11135. serialize(serializationObject: any): void;
  11136. }
  11137. /**
  11138. * Strong typing of a Mesh related stage step action
  11139. */
  11140. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11141. /**
  11142. * Strong typing of a Evaluate Sub Mesh related stage step action
  11143. */
  11144. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11145. /**
  11146. * Strong typing of a pre active Mesh related stage step action
  11147. */
  11148. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11149. /**
  11150. * Strong typing of a Camera related stage step action
  11151. */
  11152. export type CameraStageAction = (camera: Camera) => void;
  11153. /**
  11154. * Strong typing of a Camera Frame buffer related stage step action
  11155. */
  11156. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11157. /**
  11158. * Strong typing of a Render Target related stage step action
  11159. */
  11160. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11161. /**
  11162. * Strong typing of a RenderingGroup related stage step action
  11163. */
  11164. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11165. /**
  11166. * Strong typing of a Mesh Render related stage step action
  11167. */
  11168. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11169. /**
  11170. * Strong typing of a simple stage step action
  11171. */
  11172. export type SimpleStageAction = () => void;
  11173. /**
  11174. * Strong typing of a render target action.
  11175. */
  11176. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11177. /**
  11178. * Strong typing of a pointer move action.
  11179. */
  11180. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11181. /**
  11182. * Strong typing of a pointer up/down action.
  11183. */
  11184. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11185. /**
  11186. * Representation of a stage in the scene (Basically a list of ordered steps)
  11187. * @hidden
  11188. */
  11189. export class Stage<T extends Function> extends Array<{
  11190. index: number;
  11191. component: ISceneComponent;
  11192. action: T;
  11193. }> {
  11194. /**
  11195. * Hide ctor from the rest of the world.
  11196. * @param items The items to add.
  11197. */
  11198. private constructor();
  11199. /**
  11200. * Creates a new Stage.
  11201. * @returns A new instance of a Stage
  11202. */
  11203. static Create<T extends Function>(): Stage<T>;
  11204. /**
  11205. * Registers a step in an ordered way in the targeted stage.
  11206. * @param index Defines the position to register the step in
  11207. * @param component Defines the component attached to the step
  11208. * @param action Defines the action to launch during the step
  11209. */
  11210. registerStep(index: number, component: ISceneComponent, action: T): void;
  11211. /**
  11212. * Clears all the steps from the stage.
  11213. */
  11214. clear(): void;
  11215. }
  11216. }
  11217. declare module BABYLON {
  11218. interface Scene {
  11219. /** @hidden */
  11220. _pointerOverSprite: Nullable<Sprite>;
  11221. /** @hidden */
  11222. _pickedDownSprite: Nullable<Sprite>;
  11223. /** @hidden */
  11224. _tempSpritePickingRay: Nullable<Ray>;
  11225. /**
  11226. * All of the sprite managers added to this scene
  11227. * @see https://doc.babylonjs.com/babylon101/sprites
  11228. */
  11229. spriteManagers: Array<ISpriteManager>;
  11230. /**
  11231. * An event triggered when sprites rendering is about to start
  11232. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11233. */
  11234. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11235. /**
  11236. * An event triggered when sprites rendering is done
  11237. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11238. */
  11239. onAfterSpritesRenderingObservable: Observable<Scene>;
  11240. /** @hidden */
  11241. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11242. /** Launch a ray to try to pick a sprite in the scene
  11243. * @param x position on screen
  11244. * @param y position on screen
  11245. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11246. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11247. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11248. * @returns a PickingInfo
  11249. */
  11250. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11251. /** Use the given ray to pick a sprite in the scene
  11252. * @param ray The ray (in world space) to use to pick meshes
  11253. * @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
  11254. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11255. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11256. * @returns a PickingInfo
  11257. */
  11258. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11259. /** @hidden */
  11260. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11261. /** Launch a ray to try to pick sprites in the scene
  11262. * @param x position on screen
  11263. * @param y position on screen
  11264. * @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
  11265. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11266. * @returns a PickingInfo array
  11267. */
  11268. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11269. /** Use the given ray to pick sprites in the scene
  11270. * @param ray The ray (in world space) to use to pick meshes
  11271. * @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
  11272. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11273. * @returns a PickingInfo array
  11274. */
  11275. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11276. /**
  11277. * Force the sprite under the pointer
  11278. * @param sprite defines the sprite to use
  11279. */
  11280. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11281. /**
  11282. * Gets the sprite under the pointer
  11283. * @returns a Sprite or null if no sprite is under the pointer
  11284. */
  11285. getPointerOverSprite(): Nullable<Sprite>;
  11286. }
  11287. /**
  11288. * Defines the sprite scene component responsible to manage sprites
  11289. * in a given scene.
  11290. */
  11291. export class SpriteSceneComponent implements ISceneComponent {
  11292. /**
  11293. * The component name helpfull to identify the component in the list of scene components.
  11294. */
  11295. readonly name: string;
  11296. /**
  11297. * The scene the component belongs to.
  11298. */
  11299. scene: Scene;
  11300. /** @hidden */
  11301. private _spritePredicate;
  11302. /**
  11303. * Creates a new instance of the component for the given scene
  11304. * @param scene Defines the scene to register the component in
  11305. */
  11306. constructor(scene: Scene);
  11307. /**
  11308. * Registers the component in a given scene
  11309. */
  11310. register(): void;
  11311. /**
  11312. * Rebuilds the elements related to this component in case of
  11313. * context lost for instance.
  11314. */
  11315. rebuild(): void;
  11316. /**
  11317. * Disposes the component and the associated ressources.
  11318. */
  11319. dispose(): void;
  11320. private _pickSpriteButKeepRay;
  11321. private _pointerMove;
  11322. private _pointerDown;
  11323. private _pointerUp;
  11324. }
  11325. }
  11326. declare module BABYLON {
  11327. /**
  11328. * Class used to provide helper for timing
  11329. */
  11330. export class TimingTools {
  11331. /**
  11332. * Polyfill for setImmediate
  11333. * @param action defines the action to execute after the current execution block
  11334. */
  11335. static SetImmediate(action: () => void): void;
  11336. }
  11337. }
  11338. declare module BABYLON {
  11339. /**
  11340. * Class used to enable instatition of objects by class name
  11341. */
  11342. export class InstantiationTools {
  11343. /**
  11344. * Use this object to register external classes like custom textures or material
  11345. * to allow the laoders to instantiate them
  11346. */
  11347. static RegisteredExternalClasses: {
  11348. [key: string]: Object;
  11349. };
  11350. /**
  11351. * Tries to instantiate a new object from a given class name
  11352. * @param className defines the class name to instantiate
  11353. * @returns the new object or null if the system was not able to do the instantiation
  11354. */
  11355. static Instantiate(className: string): any;
  11356. }
  11357. }
  11358. declare module BABYLON {
  11359. /**
  11360. * Class used to host copy specific utilities
  11361. */
  11362. export class CopyTools {
  11363. /**
  11364. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11365. * @param texture defines the texture to read pixels from
  11366. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11367. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11368. * @returns The base64 encoded string or null
  11369. */
  11370. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11371. }
  11372. }
  11373. declare module BABYLON {
  11374. /**
  11375. * Define options used to create a depth texture
  11376. */
  11377. export class DepthTextureCreationOptions {
  11378. /** Specifies whether or not a stencil should be allocated in the texture */
  11379. generateStencil?: boolean;
  11380. /** Specifies whether or not bilinear filtering is enable on the texture */
  11381. bilinearFiltering?: boolean;
  11382. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11383. comparisonFunction?: number;
  11384. /** Specifies if the created texture is a cube texture */
  11385. isCube?: boolean;
  11386. /** Specifies the sample count of the depth/stencil texture texture */
  11387. samples?: number;
  11388. }
  11389. }
  11390. declare module BABYLON {
  11391. interface ThinEngine {
  11392. /**
  11393. * Creates a depth stencil cube texture.
  11394. * This is only available in WebGL 2.
  11395. * @param size The size of face edge in the cube texture.
  11396. * @param options The options defining the cube texture.
  11397. * @returns The cube texture
  11398. */
  11399. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11400. /**
  11401. * Creates a cube texture
  11402. * @param rootUrl defines the url where the files to load is located
  11403. * @param scene defines the current scene
  11404. * @param files defines the list of files to load (1 per face)
  11405. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11406. * @param onLoad defines an optional callback raised when the texture is loaded
  11407. * @param onError defines an optional callback raised if there is an issue to load the texture
  11408. * @param format defines the format of the data
  11409. * @param forcedExtension defines the extension to use to pick the right loader
  11410. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11411. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11412. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11413. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11414. * @param loaderOptions options to be passed to the loader
  11415. * @returns the cube texture as an InternalTexture
  11416. */
  11417. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  11418. /**
  11419. * Creates a cube texture
  11420. * @param rootUrl defines the url where the files to load is located
  11421. * @param scene defines the current scene
  11422. * @param files defines the list of files to load (1 per face)
  11423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11424. * @param onLoad defines an optional callback raised when the texture is loaded
  11425. * @param onError defines an optional callback raised if there is an issue to load the texture
  11426. * @param format defines the format of the data
  11427. * @param forcedExtension defines the extension to use to pick the right loader
  11428. * @returns the cube texture as an InternalTexture
  11429. */
  11430. 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;
  11431. /**
  11432. * Creates a cube texture
  11433. * @param rootUrl defines the url where the files to load is located
  11434. * @param scene defines the current scene
  11435. * @param files defines the list of files to load (1 per face)
  11436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11437. * @param onLoad defines an optional callback raised when the texture is loaded
  11438. * @param onError defines an optional callback raised if there is an issue to load the texture
  11439. * @param format defines the format of the data
  11440. * @param forcedExtension defines the extension to use to pick the right loader
  11441. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11442. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11443. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11444. * @returns the cube texture as an InternalTexture
  11445. */
  11446. 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;
  11447. /** @hidden */
  11448. createCubeTextureBase(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, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11449. /** @hidden */
  11450. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11451. /** @hidden */
  11452. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11453. /** @hidden */
  11454. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11455. /** @hidden */
  11456. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11457. /**
  11458. * @hidden
  11459. */
  11460. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11461. }
  11462. }
  11463. declare module BABYLON {
  11464. /**
  11465. * Class for creating a cube texture
  11466. */
  11467. export class CubeTexture extends BaseTexture {
  11468. private _delayedOnLoad;
  11469. /**
  11470. * Observable triggered once the texture has been loaded.
  11471. */
  11472. onLoadObservable: Observable<CubeTexture>;
  11473. /**
  11474. * The url of the texture
  11475. */
  11476. url: string;
  11477. /**
  11478. * Gets or sets the center of the bounding box associated with the cube texture.
  11479. * It must define where the camera used to render the texture was set
  11480. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11481. */
  11482. boundingBoxPosition: Vector3;
  11483. private _boundingBoxSize;
  11484. /**
  11485. * Gets or sets the size of the bounding box associated with the cube texture
  11486. * When defined, the cubemap will switch to local mode
  11487. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11488. * @example https://www.babylonjs-playground.com/#RNASML
  11489. */
  11490. set boundingBoxSize(value: Vector3);
  11491. /**
  11492. * Returns the bounding box size
  11493. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11494. */
  11495. get boundingBoxSize(): Vector3;
  11496. protected _rotationY: number;
  11497. /**
  11498. * Sets texture matrix rotation angle around Y axis in radians.
  11499. */
  11500. set rotationY(value: number);
  11501. /**
  11502. * Gets texture matrix rotation angle around Y axis radians.
  11503. */
  11504. get rotationY(): number;
  11505. /**
  11506. * Are mip maps generated for this texture or not.
  11507. */
  11508. get noMipmap(): boolean;
  11509. private _noMipmap;
  11510. private _files;
  11511. protected _forcedExtension: Nullable<string>;
  11512. private _extensions;
  11513. private _textureMatrix;
  11514. private _format;
  11515. private _createPolynomials;
  11516. private _loaderOptions;
  11517. /**
  11518. * Creates a cube texture from an array of image urls
  11519. * @param files defines an array of image urls
  11520. * @param scene defines the hosting scene
  11521. * @param noMipmap specifies if mip maps are not used
  11522. * @returns a cube texture
  11523. */
  11524. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11525. /**
  11526. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11527. * @param url defines the url of the prefiltered texture
  11528. * @param scene defines the scene the texture is attached to
  11529. * @param forcedExtension defines the extension of the file if different from the url
  11530. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11531. * @return the prefiltered texture
  11532. */
  11533. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11534. /**
  11535. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11536. * as prefiltered data.
  11537. * @param rootUrl defines the url of the texture or the root name of the six images
  11538. * @param null defines the scene or engine the texture is attached to
  11539. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11540. * @param noMipmap defines if mipmaps should be created or not
  11541. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11542. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11543. * @param onError defines a callback triggered in case of error during load
  11544. * @param format defines the internal format to use for the texture once loaded
  11545. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11546. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11547. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11548. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11549. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11550. * @param loaderOptions options to be passed to the loader
  11551. * @return the cube texture
  11552. */
  11553. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  11554. /**
  11555. * Get the current class name of the texture useful for serialization or dynamic coding.
  11556. * @returns "CubeTexture"
  11557. */
  11558. getClassName(): string;
  11559. /**
  11560. * Update the url (and optional buffer) of this texture if url was null during construction.
  11561. * @param url the url of the texture
  11562. * @param forcedExtension defines the extension to use
  11563. * @param onLoad callback called when the texture is loaded (defaults to null)
  11564. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11565. */
  11566. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11567. /**
  11568. * Delays loading of the cube texture
  11569. * @param forcedExtension defines the extension to use
  11570. */
  11571. delayLoad(forcedExtension?: string): void;
  11572. /**
  11573. * Returns the reflection texture matrix
  11574. * @returns the reflection texture matrix
  11575. */
  11576. getReflectionTextureMatrix(): Matrix;
  11577. /**
  11578. * Sets the reflection texture matrix
  11579. * @param value Reflection texture matrix
  11580. */
  11581. setReflectionTextureMatrix(value: Matrix): void;
  11582. /**
  11583. * Parses text to create a cube texture
  11584. * @param parsedTexture define the serialized text to read from
  11585. * @param scene defines the hosting scene
  11586. * @param rootUrl defines the root url of the cube texture
  11587. * @returns a cube texture
  11588. */
  11589. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11590. /**
  11591. * Makes a clone, or deep copy, of the cube texture
  11592. * @returns a new cube texture
  11593. */
  11594. clone(): CubeTexture;
  11595. }
  11596. }
  11597. declare module BABYLON {
  11598. /**
  11599. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11600. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11601. * 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;
  11602. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11603. */
  11604. export class ColorCurves {
  11605. private _dirty;
  11606. private _tempColor;
  11607. private _globalCurve;
  11608. private _highlightsCurve;
  11609. private _midtonesCurve;
  11610. private _shadowsCurve;
  11611. private _positiveCurve;
  11612. private _negativeCurve;
  11613. private _globalHue;
  11614. private _globalDensity;
  11615. private _globalSaturation;
  11616. private _globalExposure;
  11617. /**
  11618. * Gets the global Hue value.
  11619. * 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).
  11620. */
  11621. get globalHue(): number;
  11622. /**
  11623. * Sets the global Hue value.
  11624. * 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).
  11625. */
  11626. set globalHue(value: number);
  11627. /**
  11628. * Gets the global Density value.
  11629. * 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.
  11630. * Values less than zero provide a filter of opposite hue.
  11631. */
  11632. get globalDensity(): number;
  11633. /**
  11634. * Sets the global Density value.
  11635. * 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.
  11636. * Values less than zero provide a filter of opposite hue.
  11637. */
  11638. set globalDensity(value: number);
  11639. /**
  11640. * Gets the global Saturation value.
  11641. * 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.
  11642. */
  11643. get globalSaturation(): number;
  11644. /**
  11645. * Sets the global Saturation value.
  11646. * 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.
  11647. */
  11648. set globalSaturation(value: number);
  11649. /**
  11650. * Gets the global Exposure value.
  11651. * 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.
  11652. */
  11653. get globalExposure(): number;
  11654. /**
  11655. * Sets the global Exposure value.
  11656. * 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.
  11657. */
  11658. set globalExposure(value: number);
  11659. private _highlightsHue;
  11660. private _highlightsDensity;
  11661. private _highlightsSaturation;
  11662. private _highlightsExposure;
  11663. /**
  11664. * Gets the highlights Hue value.
  11665. * 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).
  11666. */
  11667. get highlightsHue(): number;
  11668. /**
  11669. * Sets the highlights Hue value.
  11670. * 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).
  11671. */
  11672. set highlightsHue(value: number);
  11673. /**
  11674. * Gets the highlights Density value.
  11675. * 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.
  11676. * Values less than zero provide a filter of opposite hue.
  11677. */
  11678. get highlightsDensity(): number;
  11679. /**
  11680. * Sets the highlights Density value.
  11681. * 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.
  11682. * Values less than zero provide a filter of opposite hue.
  11683. */
  11684. set highlightsDensity(value: number);
  11685. /**
  11686. * Gets the highlights Saturation value.
  11687. * 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.
  11688. */
  11689. get highlightsSaturation(): number;
  11690. /**
  11691. * Sets the highlights Saturation value.
  11692. * 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.
  11693. */
  11694. set highlightsSaturation(value: number);
  11695. /**
  11696. * Gets the highlights Exposure value.
  11697. * 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.
  11698. */
  11699. get highlightsExposure(): number;
  11700. /**
  11701. * Sets the highlights Exposure value.
  11702. * 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.
  11703. */
  11704. set highlightsExposure(value: number);
  11705. private _midtonesHue;
  11706. private _midtonesDensity;
  11707. private _midtonesSaturation;
  11708. private _midtonesExposure;
  11709. /**
  11710. * Gets the midtones Hue value.
  11711. * 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).
  11712. */
  11713. get midtonesHue(): number;
  11714. /**
  11715. * Sets the midtones Hue value.
  11716. * 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).
  11717. */
  11718. set midtonesHue(value: number);
  11719. /**
  11720. * Gets the midtones Density value.
  11721. * 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.
  11722. * Values less than zero provide a filter of opposite hue.
  11723. */
  11724. get midtonesDensity(): number;
  11725. /**
  11726. * Sets the midtones Density value.
  11727. * 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.
  11728. * Values less than zero provide a filter of opposite hue.
  11729. */
  11730. set midtonesDensity(value: number);
  11731. /**
  11732. * Gets the midtones Saturation value.
  11733. * 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.
  11734. */
  11735. get midtonesSaturation(): number;
  11736. /**
  11737. * Sets the midtones Saturation value.
  11738. * 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.
  11739. */
  11740. set midtonesSaturation(value: number);
  11741. /**
  11742. * Gets the midtones Exposure value.
  11743. * 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.
  11744. */
  11745. get midtonesExposure(): number;
  11746. /**
  11747. * Sets the midtones Exposure value.
  11748. * 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.
  11749. */
  11750. set midtonesExposure(value: number);
  11751. private _shadowsHue;
  11752. private _shadowsDensity;
  11753. private _shadowsSaturation;
  11754. private _shadowsExposure;
  11755. /**
  11756. * Gets the shadows Hue value.
  11757. * 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).
  11758. */
  11759. get shadowsHue(): number;
  11760. /**
  11761. * Sets the shadows Hue value.
  11762. * 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).
  11763. */
  11764. set shadowsHue(value: number);
  11765. /**
  11766. * Gets the shadows Density value.
  11767. * 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.
  11768. * Values less than zero provide a filter of opposite hue.
  11769. */
  11770. get shadowsDensity(): number;
  11771. /**
  11772. * Sets the shadows Density value.
  11773. * 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.
  11774. * Values less than zero provide a filter of opposite hue.
  11775. */
  11776. set shadowsDensity(value: number);
  11777. /**
  11778. * Gets the shadows Saturation value.
  11779. * 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.
  11780. */
  11781. get shadowsSaturation(): number;
  11782. /**
  11783. * Sets the shadows Saturation value.
  11784. * 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.
  11785. */
  11786. set shadowsSaturation(value: number);
  11787. /**
  11788. * Gets the shadows Exposure value.
  11789. * 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.
  11790. */
  11791. get shadowsExposure(): number;
  11792. /**
  11793. * Sets the shadows Exposure value.
  11794. * 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.
  11795. */
  11796. set shadowsExposure(value: number);
  11797. /**
  11798. * Returns the class name
  11799. * @returns The class name
  11800. */
  11801. getClassName(): string;
  11802. /**
  11803. * Binds the color curves to the shader.
  11804. * @param colorCurves The color curve to bind
  11805. * @param effect The effect to bind to
  11806. * @param positiveUniform The positive uniform shader parameter
  11807. * @param neutralUniform The neutral uniform shader parameter
  11808. * @param negativeUniform The negative uniform shader parameter
  11809. */
  11810. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11811. /**
  11812. * Prepare the list of uniforms associated with the ColorCurves effects.
  11813. * @param uniformsList The list of uniforms used in the effect
  11814. */
  11815. static PrepareUniforms(uniformsList: string[]): void;
  11816. /**
  11817. * Returns color grading data based on a hue, density, saturation and exposure value.
  11818. * @param filterHue The hue of the color filter.
  11819. * @param filterDensity The density of the color filter.
  11820. * @param saturation The saturation.
  11821. * @param exposure The exposure.
  11822. * @param result The result data container.
  11823. */
  11824. private getColorGradingDataToRef;
  11825. /**
  11826. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11827. * @param value The input slider value in range [-100,100].
  11828. * @returns Adjusted value.
  11829. */
  11830. private static applyColorGradingSliderNonlinear;
  11831. /**
  11832. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11833. * @param hue The hue (H) input.
  11834. * @param saturation The saturation (S) input.
  11835. * @param brightness The brightness (B) input.
  11836. * @result An RGBA color represented as Vector4.
  11837. */
  11838. private static fromHSBToRef;
  11839. /**
  11840. * Returns a value clamped between min and max
  11841. * @param value The value to clamp
  11842. * @param min The minimum of value
  11843. * @param max The maximum of value
  11844. * @returns The clamped value.
  11845. */
  11846. private static clamp;
  11847. /**
  11848. * Clones the current color curve instance.
  11849. * @return The cloned curves
  11850. */
  11851. clone(): ColorCurves;
  11852. /**
  11853. * Serializes the current color curve instance to a json representation.
  11854. * @return a JSON representation
  11855. */
  11856. serialize(): any;
  11857. /**
  11858. * Parses the color curve from a json representation.
  11859. * @param source the JSON source to parse
  11860. * @return The parsed curves
  11861. */
  11862. static Parse(source: any): ColorCurves;
  11863. }
  11864. }
  11865. declare module BABYLON {
  11866. /**
  11867. * Interface to follow in your material defines to integrate easily the
  11868. * Image proccessing functions.
  11869. * @hidden
  11870. */
  11871. export interface IImageProcessingConfigurationDefines {
  11872. IMAGEPROCESSING: boolean;
  11873. VIGNETTE: boolean;
  11874. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11875. VIGNETTEBLENDMODEOPAQUE: boolean;
  11876. TONEMAPPING: boolean;
  11877. TONEMAPPING_ACES: boolean;
  11878. CONTRAST: boolean;
  11879. EXPOSURE: boolean;
  11880. COLORCURVES: boolean;
  11881. COLORGRADING: boolean;
  11882. COLORGRADING3D: boolean;
  11883. SAMPLER3DGREENDEPTH: boolean;
  11884. SAMPLER3DBGRMAP: boolean;
  11885. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11886. }
  11887. /**
  11888. * @hidden
  11889. */
  11890. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11891. IMAGEPROCESSING: boolean;
  11892. VIGNETTE: boolean;
  11893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11894. VIGNETTEBLENDMODEOPAQUE: boolean;
  11895. TONEMAPPING: boolean;
  11896. TONEMAPPING_ACES: boolean;
  11897. CONTRAST: boolean;
  11898. COLORCURVES: boolean;
  11899. COLORGRADING: boolean;
  11900. COLORGRADING3D: boolean;
  11901. SAMPLER3DGREENDEPTH: boolean;
  11902. SAMPLER3DBGRMAP: boolean;
  11903. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11904. EXPOSURE: boolean;
  11905. constructor();
  11906. }
  11907. /**
  11908. * This groups together the common properties used for image processing either in direct forward pass
  11909. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11910. * or not.
  11911. */
  11912. export class ImageProcessingConfiguration {
  11913. /**
  11914. * Default tone mapping applied in BabylonJS.
  11915. */
  11916. static readonly TONEMAPPING_STANDARD: number;
  11917. /**
  11918. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11919. * to other engines rendering to increase portability.
  11920. */
  11921. static readonly TONEMAPPING_ACES: number;
  11922. /**
  11923. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11924. */
  11925. colorCurves: Nullable<ColorCurves>;
  11926. private _colorCurvesEnabled;
  11927. /**
  11928. * Gets wether the color curves effect is enabled.
  11929. */
  11930. get colorCurvesEnabled(): boolean;
  11931. /**
  11932. * Sets wether the color curves effect is enabled.
  11933. */
  11934. set colorCurvesEnabled(value: boolean);
  11935. private _colorGradingTexture;
  11936. /**
  11937. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11938. */
  11939. get colorGradingTexture(): Nullable<BaseTexture>;
  11940. /**
  11941. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11942. */
  11943. set colorGradingTexture(value: Nullable<BaseTexture>);
  11944. private _colorGradingEnabled;
  11945. /**
  11946. * Gets wether the color grading effect is enabled.
  11947. */
  11948. get colorGradingEnabled(): boolean;
  11949. /**
  11950. * Sets wether the color grading effect is enabled.
  11951. */
  11952. set colorGradingEnabled(value: boolean);
  11953. private _colorGradingWithGreenDepth;
  11954. /**
  11955. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11956. */
  11957. get colorGradingWithGreenDepth(): boolean;
  11958. /**
  11959. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11960. */
  11961. set colorGradingWithGreenDepth(value: boolean);
  11962. private _colorGradingBGR;
  11963. /**
  11964. * Gets wether the color grading texture contains BGR values.
  11965. */
  11966. get colorGradingBGR(): boolean;
  11967. /**
  11968. * Sets wether the color grading texture contains BGR values.
  11969. */
  11970. set colorGradingBGR(value: boolean);
  11971. /** @hidden */
  11972. _exposure: number;
  11973. /**
  11974. * Gets the Exposure used in the effect.
  11975. */
  11976. get exposure(): number;
  11977. /**
  11978. * Sets the Exposure used in the effect.
  11979. */
  11980. set exposure(value: number);
  11981. private _toneMappingEnabled;
  11982. /**
  11983. * Gets wether the tone mapping effect is enabled.
  11984. */
  11985. get toneMappingEnabled(): boolean;
  11986. /**
  11987. * Sets wether the tone mapping effect is enabled.
  11988. */
  11989. set toneMappingEnabled(value: boolean);
  11990. private _toneMappingType;
  11991. /**
  11992. * Gets the type of tone mapping effect.
  11993. */
  11994. get toneMappingType(): number;
  11995. /**
  11996. * Sets the type of tone mapping effect used in BabylonJS.
  11997. */
  11998. set toneMappingType(value: number);
  11999. protected _contrast: number;
  12000. /**
  12001. * Gets the contrast used in the effect.
  12002. */
  12003. get contrast(): number;
  12004. /**
  12005. * Sets the contrast used in the effect.
  12006. */
  12007. set contrast(value: number);
  12008. /**
  12009. * Vignette stretch size.
  12010. */
  12011. vignetteStretch: number;
  12012. /**
  12013. * Vignette centre X Offset.
  12014. */
  12015. vignetteCentreX: number;
  12016. /**
  12017. * Vignette centre Y Offset.
  12018. */
  12019. vignetteCentreY: number;
  12020. /**
  12021. * Vignette weight or intensity of the vignette effect.
  12022. */
  12023. vignetteWeight: number;
  12024. /**
  12025. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12026. * if vignetteEnabled is set to true.
  12027. */
  12028. vignetteColor: Color4;
  12029. /**
  12030. * Camera field of view used by the Vignette effect.
  12031. */
  12032. vignetteCameraFov: number;
  12033. private _vignetteBlendMode;
  12034. /**
  12035. * Gets the vignette blend mode allowing different kind of effect.
  12036. */
  12037. get vignetteBlendMode(): number;
  12038. /**
  12039. * Sets the vignette blend mode allowing different kind of effect.
  12040. */
  12041. set vignetteBlendMode(value: number);
  12042. private _vignetteEnabled;
  12043. /**
  12044. * Gets wether the vignette effect is enabled.
  12045. */
  12046. get vignetteEnabled(): boolean;
  12047. /**
  12048. * Sets wether the vignette effect is enabled.
  12049. */
  12050. set vignetteEnabled(value: boolean);
  12051. private _applyByPostProcess;
  12052. /**
  12053. * Gets wether the image processing is applied through a post process or not.
  12054. */
  12055. get applyByPostProcess(): boolean;
  12056. /**
  12057. * Sets wether the image processing is applied through a post process or not.
  12058. */
  12059. set applyByPostProcess(value: boolean);
  12060. private _isEnabled;
  12061. /**
  12062. * Gets wether the image processing is enabled or not.
  12063. */
  12064. get isEnabled(): boolean;
  12065. /**
  12066. * Sets wether the image processing is enabled or not.
  12067. */
  12068. set isEnabled(value: boolean);
  12069. /**
  12070. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12071. */
  12072. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12073. /**
  12074. * Method called each time the image processing information changes requires to recompile the effect.
  12075. */
  12076. protected _updateParameters(): void;
  12077. /**
  12078. * Gets the current class name.
  12079. * @return "ImageProcessingConfiguration"
  12080. */
  12081. getClassName(): string;
  12082. /**
  12083. * Prepare the list of uniforms associated with the Image Processing effects.
  12084. * @param uniforms The list of uniforms used in the effect
  12085. * @param defines the list of defines currently in use
  12086. */
  12087. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12088. /**
  12089. * Prepare the list of samplers associated with the Image Processing effects.
  12090. * @param samplersList The list of uniforms used in the effect
  12091. * @param defines the list of defines currently in use
  12092. */
  12093. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12094. /**
  12095. * Prepare the list of defines associated to the shader.
  12096. * @param defines the list of defines to complete
  12097. * @param forPostProcess Define if we are currently in post process mode or not
  12098. */
  12099. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12100. /**
  12101. * Returns true if all the image processing information are ready.
  12102. * @returns True if ready, otherwise, false
  12103. */
  12104. isReady(): boolean;
  12105. /**
  12106. * Binds the image processing to the shader.
  12107. * @param effect The effect to bind to
  12108. * @param overrideAspectRatio Override the aspect ratio of the effect
  12109. */
  12110. bind(effect: Effect, overrideAspectRatio?: number): void;
  12111. /**
  12112. * Clones the current image processing instance.
  12113. * @return The cloned image processing
  12114. */
  12115. clone(): ImageProcessingConfiguration;
  12116. /**
  12117. * Serializes the current image processing instance to a json representation.
  12118. * @return a JSON representation
  12119. */
  12120. serialize(): any;
  12121. /**
  12122. * Parses the image processing from a json representation.
  12123. * @param source the JSON source to parse
  12124. * @return The parsed image processing
  12125. */
  12126. static Parse(source: any): ImageProcessingConfiguration;
  12127. private static _VIGNETTEMODE_MULTIPLY;
  12128. private static _VIGNETTEMODE_OPAQUE;
  12129. /**
  12130. * Used to apply the vignette as a mix with the pixel color.
  12131. */
  12132. static get VIGNETTEMODE_MULTIPLY(): number;
  12133. /**
  12134. * Used to apply the vignette as a replacement of the pixel color.
  12135. */
  12136. static get VIGNETTEMODE_OPAQUE(): number;
  12137. }
  12138. }
  12139. declare module BABYLON {
  12140. /** @hidden */
  12141. export var postprocessVertexShader: {
  12142. name: string;
  12143. shader: string;
  12144. };
  12145. }
  12146. declare module BABYLON {
  12147. /**
  12148. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12149. */
  12150. export type RenderTargetTextureSize = number | {
  12151. width: number;
  12152. height: number;
  12153. layers?: number;
  12154. };
  12155. interface ThinEngine {
  12156. /**
  12157. * Creates a new render target texture
  12158. * @param size defines the size of the texture
  12159. * @param options defines the options used to create the texture
  12160. * @returns a new render target texture stored in an InternalTexture
  12161. */
  12162. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12163. /**
  12164. * Creates a depth stencil texture.
  12165. * This is only available in WebGL 2 or with the depth texture extension available.
  12166. * @param size The size of face edge in the texture.
  12167. * @param options The options defining the texture.
  12168. * @returns The texture
  12169. */
  12170. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12171. /** @hidden */
  12172. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12173. }
  12174. }
  12175. declare module BABYLON {
  12176. /**
  12177. * Defines the kind of connection point for node based material
  12178. */
  12179. export enum NodeMaterialBlockConnectionPointTypes {
  12180. /** Float */
  12181. Float = 1,
  12182. /** Int */
  12183. Int = 2,
  12184. /** Vector2 */
  12185. Vector2 = 4,
  12186. /** Vector3 */
  12187. Vector3 = 8,
  12188. /** Vector4 */
  12189. Vector4 = 16,
  12190. /** Color3 */
  12191. Color3 = 32,
  12192. /** Color4 */
  12193. Color4 = 64,
  12194. /** Matrix */
  12195. Matrix = 128,
  12196. /** Custom object */
  12197. Object = 256,
  12198. /** Detect type based on connection */
  12199. AutoDetect = 1024,
  12200. /** Output type that will be defined by input type */
  12201. BasedOnInput = 2048
  12202. }
  12203. }
  12204. declare module BABYLON {
  12205. /**
  12206. * Enum used to define the target of a block
  12207. */
  12208. export enum NodeMaterialBlockTargets {
  12209. /** Vertex shader */
  12210. Vertex = 1,
  12211. /** Fragment shader */
  12212. Fragment = 2,
  12213. /** Neutral */
  12214. Neutral = 4,
  12215. /** Vertex and Fragment */
  12216. VertexAndFragment = 3
  12217. }
  12218. }
  12219. declare module BABYLON {
  12220. /**
  12221. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12222. */
  12223. export enum NodeMaterialBlockConnectionPointMode {
  12224. /** Value is an uniform */
  12225. Uniform = 0,
  12226. /** Value is a mesh attribute */
  12227. Attribute = 1,
  12228. /** Value is a varying between vertex and fragment shaders */
  12229. Varying = 2,
  12230. /** Mode is undefined */
  12231. Undefined = 3
  12232. }
  12233. }
  12234. declare module BABYLON {
  12235. /**
  12236. * Enum used to define system values e.g. values automatically provided by the system
  12237. */
  12238. export enum NodeMaterialSystemValues {
  12239. /** World */
  12240. World = 1,
  12241. /** View */
  12242. View = 2,
  12243. /** Projection */
  12244. Projection = 3,
  12245. /** ViewProjection */
  12246. ViewProjection = 4,
  12247. /** WorldView */
  12248. WorldView = 5,
  12249. /** WorldViewProjection */
  12250. WorldViewProjection = 6,
  12251. /** CameraPosition */
  12252. CameraPosition = 7,
  12253. /** Fog Color */
  12254. FogColor = 8,
  12255. /** Delta time */
  12256. DeltaTime = 9
  12257. }
  12258. }
  12259. declare module BABYLON {
  12260. /**
  12261. * Represents a camera frustum
  12262. */
  12263. export class Frustum {
  12264. /**
  12265. * Gets the planes representing the frustum
  12266. * @param transform matrix to be applied to the returned planes
  12267. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12268. */
  12269. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12270. /**
  12271. * Gets the near frustum plane transformed by the transform matrix
  12272. * @param transform transformation matrix to be applied to the resulting frustum plane
  12273. * @param frustumPlane the resuling frustum plane
  12274. */
  12275. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12276. /**
  12277. * Gets the far frustum plane transformed by the transform matrix
  12278. * @param transform transformation matrix to be applied to the resulting frustum plane
  12279. * @param frustumPlane the resuling frustum plane
  12280. */
  12281. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12282. /**
  12283. * Gets the left frustum plane transformed by the transform matrix
  12284. * @param transform transformation matrix to be applied to the resulting frustum plane
  12285. * @param frustumPlane the resuling frustum plane
  12286. */
  12287. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12288. /**
  12289. * Gets the right frustum plane transformed by the transform matrix
  12290. * @param transform transformation matrix to be applied to the resulting frustum plane
  12291. * @param frustumPlane the resuling frustum plane
  12292. */
  12293. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12294. /**
  12295. * Gets the top frustum plane transformed by the transform matrix
  12296. * @param transform transformation matrix to be applied to the resulting frustum plane
  12297. * @param frustumPlane the resuling frustum plane
  12298. */
  12299. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12300. /**
  12301. * Gets the bottom frustum plane transformed by the transform matrix
  12302. * @param transform transformation matrix to be applied to the resulting frustum plane
  12303. * @param frustumPlane the resuling frustum plane
  12304. */
  12305. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12306. /**
  12307. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12308. * @param transform transformation matrix to be applied to the resulting frustum planes
  12309. * @param frustumPlanes the resuling frustum planes
  12310. */
  12311. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12312. }
  12313. }
  12314. declare module BABYLON {
  12315. /**
  12316. * Contains position and normal vectors for a vertex
  12317. */
  12318. export class PositionNormalVertex {
  12319. /** the position of the vertex (defaut: 0,0,0) */
  12320. position: Vector3;
  12321. /** the normal of the vertex (defaut: 0,1,0) */
  12322. normal: Vector3;
  12323. /**
  12324. * Creates a PositionNormalVertex
  12325. * @param position the position of the vertex (defaut: 0,0,0)
  12326. * @param normal the normal of the vertex (defaut: 0,1,0)
  12327. */
  12328. constructor(
  12329. /** the position of the vertex (defaut: 0,0,0) */
  12330. position?: Vector3,
  12331. /** the normal of the vertex (defaut: 0,1,0) */
  12332. normal?: Vector3);
  12333. /**
  12334. * Clones the PositionNormalVertex
  12335. * @returns the cloned PositionNormalVertex
  12336. */
  12337. clone(): PositionNormalVertex;
  12338. }
  12339. /**
  12340. * Contains position, normal and uv vectors for a vertex
  12341. */
  12342. export class PositionNormalTextureVertex {
  12343. /** the position of the vertex (defaut: 0,0,0) */
  12344. position: Vector3;
  12345. /** the normal of the vertex (defaut: 0,1,0) */
  12346. normal: Vector3;
  12347. /** the uv of the vertex (default: 0,0) */
  12348. uv: Vector2;
  12349. /**
  12350. * Creates a PositionNormalTextureVertex
  12351. * @param position the position of the vertex (defaut: 0,0,0)
  12352. * @param normal the normal of the vertex (defaut: 0,1,0)
  12353. * @param uv the uv of the vertex (default: 0,0)
  12354. */
  12355. constructor(
  12356. /** the position of the vertex (defaut: 0,0,0) */
  12357. position?: Vector3,
  12358. /** the normal of the vertex (defaut: 0,1,0) */
  12359. normal?: Vector3,
  12360. /** the uv of the vertex (default: 0,0) */
  12361. uv?: Vector2);
  12362. /**
  12363. * Clones the PositionNormalTextureVertex
  12364. * @returns the cloned PositionNormalTextureVertex
  12365. */
  12366. clone(): PositionNormalTextureVertex;
  12367. }
  12368. }
  12369. declare module BABYLON {
  12370. /**
  12371. * Enum defining the type of animations supported by InputBlock
  12372. */
  12373. export enum AnimatedInputBlockTypes {
  12374. /** No animation */
  12375. None = 0,
  12376. /** Time based animation. Will only work for floats */
  12377. Time = 1
  12378. }
  12379. }
  12380. declare module BABYLON {
  12381. /**
  12382. * Block used to expose an input value
  12383. */
  12384. export class InputBlock extends NodeMaterialBlock {
  12385. private _mode;
  12386. private _associatedVariableName;
  12387. private _storedValue;
  12388. private _valueCallback;
  12389. private _type;
  12390. private _animationType;
  12391. /** Gets or set a value used to limit the range of float values */
  12392. min: number;
  12393. /** Gets or set a value used to limit the range of float values */
  12394. max: number;
  12395. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12396. isBoolean: boolean;
  12397. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12398. matrixMode: number;
  12399. /** @hidden */
  12400. _systemValue: Nullable<NodeMaterialSystemValues>;
  12401. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12402. isConstant: boolean;
  12403. /** Gets or sets the group to use to display this block in the Inspector */
  12404. groupInInspector: string;
  12405. /** Gets an observable raised when the value is changed */
  12406. onValueChangedObservable: Observable<InputBlock>;
  12407. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12408. convertToGammaSpace: boolean;
  12409. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12410. convertToLinearSpace: boolean;
  12411. /**
  12412. * Gets or sets the connection point type (default is float)
  12413. */
  12414. get type(): NodeMaterialBlockConnectionPointTypes;
  12415. /**
  12416. * Creates a new InputBlock
  12417. * @param name defines the block name
  12418. * @param target defines the target of that block (Vertex by default)
  12419. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12420. */
  12421. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12422. /**
  12423. * Validates if a name is a reserve word.
  12424. * @param newName the new name to be given to the node.
  12425. * @returns false if the name is a reserve word, else true.
  12426. */
  12427. validateBlockName(newName: string): boolean;
  12428. /**
  12429. * Gets the output component
  12430. */
  12431. get output(): NodeMaterialConnectionPoint;
  12432. /**
  12433. * Set the source of this connection point to a vertex attribute
  12434. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12435. * @returns the current connection point
  12436. */
  12437. setAsAttribute(attributeName?: string): InputBlock;
  12438. /**
  12439. * Set the source of this connection point to a system value
  12440. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12441. * @returns the current connection point
  12442. */
  12443. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12444. /**
  12445. * Gets or sets the value of that point.
  12446. * Please note that this value will be ignored if valueCallback is defined
  12447. */
  12448. get value(): any;
  12449. set value(value: any);
  12450. /**
  12451. * Gets or sets a callback used to get the value of that point.
  12452. * Please note that setting this value will force the connection point to ignore the value property
  12453. */
  12454. get valueCallback(): () => any;
  12455. set valueCallback(value: () => any);
  12456. /**
  12457. * Gets or sets the associated variable name in the shader
  12458. */
  12459. get associatedVariableName(): string;
  12460. set associatedVariableName(value: string);
  12461. /** Gets or sets the type of animation applied to the input */
  12462. get animationType(): AnimatedInputBlockTypes;
  12463. set animationType(value: AnimatedInputBlockTypes);
  12464. /**
  12465. * Gets a boolean indicating that this connection point not defined yet
  12466. */
  12467. get isUndefined(): boolean;
  12468. /**
  12469. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12470. * In this case the connection point name must be the name of the uniform to use.
  12471. * Can only be set on inputs
  12472. */
  12473. get isUniform(): boolean;
  12474. set isUniform(value: boolean);
  12475. /**
  12476. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12477. * In this case the connection point name must be the name of the attribute to use
  12478. * Can only be set on inputs
  12479. */
  12480. get isAttribute(): boolean;
  12481. set isAttribute(value: boolean);
  12482. /**
  12483. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12484. * Can only be set on exit points
  12485. */
  12486. get isVarying(): boolean;
  12487. set isVarying(value: boolean);
  12488. /**
  12489. * Gets a boolean indicating that the current connection point is a system value
  12490. */
  12491. get isSystemValue(): boolean;
  12492. /**
  12493. * Gets or sets the current well known value or null if not defined as a system value
  12494. */
  12495. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12496. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12497. /**
  12498. * Gets the current class name
  12499. * @returns the class name
  12500. */
  12501. getClassName(): string;
  12502. /**
  12503. * Animate the input if animationType !== None
  12504. * @param scene defines the rendering scene
  12505. */
  12506. animate(scene: Scene): void;
  12507. private _emitDefine;
  12508. initialize(state: NodeMaterialBuildState): void;
  12509. /**
  12510. * Set the input block to its default value (based on its type)
  12511. */
  12512. setDefaultValue(): void;
  12513. private _emitConstant;
  12514. /** @hidden */
  12515. get _noContextSwitch(): boolean;
  12516. private _emit;
  12517. /** @hidden */
  12518. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12519. /** @hidden */
  12520. _transmit(effect: Effect, scene: Scene): void;
  12521. protected _buildBlock(state: NodeMaterialBuildState): void;
  12522. protected _dumpPropertiesCode(): string;
  12523. dispose(): void;
  12524. serialize(): any;
  12525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12526. }
  12527. }
  12528. declare module BABYLON {
  12529. /**
  12530. * Enum used to define the compatibility state between two connection points
  12531. */
  12532. export enum NodeMaterialConnectionPointCompatibilityStates {
  12533. /** Points are compatibles */
  12534. Compatible = 0,
  12535. /** Points are incompatible because of their types */
  12536. TypeIncompatible = 1,
  12537. /** Points are incompatible because of their targets (vertex vs fragment) */
  12538. TargetIncompatible = 2
  12539. }
  12540. /**
  12541. * Defines the direction of a connection point
  12542. */
  12543. export enum NodeMaterialConnectionPointDirection {
  12544. /** Input */
  12545. Input = 0,
  12546. /** Output */
  12547. Output = 1
  12548. }
  12549. /**
  12550. * Defines a connection point for a block
  12551. */
  12552. export class NodeMaterialConnectionPoint {
  12553. /**
  12554. * Checks if two types are equivalent
  12555. * @param type1 type 1 to check
  12556. * @param type2 type 2 to check
  12557. * @returns true if both types are equivalent, else false
  12558. */
  12559. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12560. /** @hidden */
  12561. _ownerBlock: NodeMaterialBlock;
  12562. /** @hidden */
  12563. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12564. private _endpoints;
  12565. private _associatedVariableName;
  12566. private _direction;
  12567. /** @hidden */
  12568. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12569. /** @hidden */
  12570. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12571. /** @hidden */
  12572. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12573. private _type;
  12574. /** @hidden */
  12575. _enforceAssociatedVariableName: boolean;
  12576. /** Gets the direction of the point */
  12577. get direction(): NodeMaterialConnectionPointDirection;
  12578. /** Indicates that this connection point needs dual validation before being connected to another point */
  12579. needDualDirectionValidation: boolean;
  12580. /**
  12581. * Gets or sets the additional types supported by this connection point
  12582. */
  12583. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12584. /**
  12585. * Gets or sets the additional types excluded by this connection point
  12586. */
  12587. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12588. /**
  12589. * Observable triggered when this point is connected
  12590. */
  12591. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12592. /**
  12593. * Gets or sets the associated variable name in the shader
  12594. */
  12595. get associatedVariableName(): string;
  12596. set associatedVariableName(value: string);
  12597. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12598. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12599. /**
  12600. * Gets or sets the connection point type (default is float)
  12601. */
  12602. get type(): NodeMaterialBlockConnectionPointTypes;
  12603. set type(value: NodeMaterialBlockConnectionPointTypes);
  12604. /**
  12605. * Gets or sets the connection point name
  12606. */
  12607. name: string;
  12608. /**
  12609. * Gets or sets the connection point name
  12610. */
  12611. displayName: string;
  12612. /**
  12613. * Gets or sets a boolean indicating that this connection point can be omitted
  12614. */
  12615. isOptional: boolean;
  12616. /**
  12617. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12618. */
  12619. isExposedOnFrame: boolean;
  12620. /**
  12621. * Gets or sets number indicating the position that the port is exposed to on a frame
  12622. */
  12623. exposedPortPosition: number;
  12624. /**
  12625. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12626. */
  12627. define: string;
  12628. /** @hidden */
  12629. _prioritizeVertex: boolean;
  12630. private _target;
  12631. /** Gets or sets the target of that connection point */
  12632. get target(): NodeMaterialBlockTargets;
  12633. set target(value: NodeMaterialBlockTargets);
  12634. /**
  12635. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12636. */
  12637. get isConnected(): boolean;
  12638. /**
  12639. * Gets a boolean indicating that the current point is connected to an input block
  12640. */
  12641. get isConnectedToInputBlock(): boolean;
  12642. /**
  12643. * Gets a the connected input block (if any)
  12644. */
  12645. get connectInputBlock(): Nullable<InputBlock>;
  12646. /** Get the other side of the connection (if any) */
  12647. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12648. /** Get the block that owns this connection point */
  12649. get ownerBlock(): NodeMaterialBlock;
  12650. /** Get the block connected on the other side of this connection (if any) */
  12651. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12652. /** Get the block connected on the endpoints of this connection (if any) */
  12653. get connectedBlocks(): Array<NodeMaterialBlock>;
  12654. /** Gets the list of connected endpoints */
  12655. get endpoints(): NodeMaterialConnectionPoint[];
  12656. /** Gets a boolean indicating if that output point is connected to at least one input */
  12657. get hasEndpoints(): boolean;
  12658. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12659. get isConnectedInVertexShader(): boolean;
  12660. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12661. get isConnectedInFragmentShader(): boolean;
  12662. /**
  12663. * Creates a block suitable to be used as an input for this input point.
  12664. * If null is returned, a block based on the point type will be created.
  12665. * @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
  12666. */
  12667. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12668. /**
  12669. * Creates a new connection point
  12670. * @param name defines the connection point name
  12671. * @param ownerBlock defines the block hosting this connection point
  12672. * @param direction defines the direction of the connection point
  12673. */
  12674. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12675. /**
  12676. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12677. * @returns the class name
  12678. */
  12679. getClassName(): string;
  12680. /**
  12681. * Gets a boolean indicating if the current point can be connected to another point
  12682. * @param connectionPoint defines the other connection point
  12683. * @returns a boolean
  12684. */
  12685. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12686. /**
  12687. * Gets a number indicating if the current point can be connected to another point
  12688. * @param connectionPoint defines the other connection point
  12689. * @returns a number defining the compatibility state
  12690. */
  12691. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12692. /**
  12693. * Connect this point to another connection point
  12694. * @param connectionPoint defines the other connection point
  12695. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12696. * @returns the current connection point
  12697. */
  12698. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12699. /**
  12700. * Disconnect this point from one of his endpoint
  12701. * @param endpoint defines the other connection point
  12702. * @returns the current connection point
  12703. */
  12704. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12705. /**
  12706. * Serializes this point in a JSON representation
  12707. * @param isInput defines if the connection point is an input (default is true)
  12708. * @returns the serialized point object
  12709. */
  12710. serialize(isInput?: boolean): any;
  12711. /**
  12712. * Release resources
  12713. */
  12714. dispose(): void;
  12715. }
  12716. }
  12717. declare module BABYLON {
  12718. /**
  12719. * Enum used to define the material modes
  12720. */
  12721. export enum NodeMaterialModes {
  12722. /** Regular material */
  12723. Material = 0,
  12724. /** For post process */
  12725. PostProcess = 1,
  12726. /** For particle system */
  12727. Particle = 2,
  12728. /** For procedural texture */
  12729. ProceduralTexture = 3
  12730. }
  12731. }
  12732. declare module BABYLON {
  12733. /** @hidden */
  12734. export var helperFunctions: {
  12735. name: string;
  12736. shader: string;
  12737. };
  12738. }
  12739. declare module BABYLON {
  12740. /**
  12741. * Block used to read a texture from a sampler
  12742. */
  12743. export class TextureBlock extends NodeMaterialBlock {
  12744. private _defineName;
  12745. private _linearDefineName;
  12746. private _gammaDefineName;
  12747. private _tempTextureRead;
  12748. private _samplerName;
  12749. private _transformedUVName;
  12750. private _textureTransformName;
  12751. private _textureInfoName;
  12752. private _mainUVName;
  12753. private _mainUVDefineName;
  12754. private _fragmentOnly;
  12755. /**
  12756. * Gets or sets the texture associated with the node
  12757. */
  12758. texture: Nullable<Texture>;
  12759. /**
  12760. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12761. */
  12762. convertToGammaSpace: boolean;
  12763. /**
  12764. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12765. */
  12766. convertToLinearSpace: boolean;
  12767. /**
  12768. * Create a new TextureBlock
  12769. * @param name defines the block name
  12770. */
  12771. constructor(name: string, fragmentOnly?: boolean);
  12772. /**
  12773. * Gets the current class name
  12774. * @returns the class name
  12775. */
  12776. getClassName(): string;
  12777. /**
  12778. * Gets the uv input component
  12779. */
  12780. get uv(): NodeMaterialConnectionPoint;
  12781. /**
  12782. * Gets the rgba output component
  12783. */
  12784. get rgba(): NodeMaterialConnectionPoint;
  12785. /**
  12786. * Gets the rgb output component
  12787. */
  12788. get rgb(): NodeMaterialConnectionPoint;
  12789. /**
  12790. * Gets the r output component
  12791. */
  12792. get r(): NodeMaterialConnectionPoint;
  12793. /**
  12794. * Gets the g output component
  12795. */
  12796. get g(): NodeMaterialConnectionPoint;
  12797. /**
  12798. * Gets the b output component
  12799. */
  12800. get b(): NodeMaterialConnectionPoint;
  12801. /**
  12802. * Gets the a output component
  12803. */
  12804. get a(): NodeMaterialConnectionPoint;
  12805. get target(): NodeMaterialBlockTargets;
  12806. autoConfigure(material: NodeMaterial): void;
  12807. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12809. isReady(): boolean;
  12810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12811. private get _isMixed();
  12812. private _injectVertexCode;
  12813. private _writeTextureRead;
  12814. private _writeOutput;
  12815. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12816. protected _dumpPropertiesCode(): string;
  12817. serialize(): any;
  12818. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12819. }
  12820. }
  12821. declare module BABYLON {
  12822. /** @hidden */
  12823. export var reflectionFunction: {
  12824. name: string;
  12825. shader: string;
  12826. };
  12827. }
  12828. declare module BABYLON {
  12829. /**
  12830. * Base block used to read a reflection texture from a sampler
  12831. */
  12832. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12833. /** @hidden */
  12834. _define3DName: string;
  12835. /** @hidden */
  12836. _defineCubicName: string;
  12837. /** @hidden */
  12838. _defineExplicitName: string;
  12839. /** @hidden */
  12840. _defineProjectionName: string;
  12841. /** @hidden */
  12842. _defineLocalCubicName: string;
  12843. /** @hidden */
  12844. _defineSphericalName: string;
  12845. /** @hidden */
  12846. _definePlanarName: string;
  12847. /** @hidden */
  12848. _defineEquirectangularName: string;
  12849. /** @hidden */
  12850. _defineMirroredEquirectangularFixedName: string;
  12851. /** @hidden */
  12852. _defineEquirectangularFixedName: string;
  12853. /** @hidden */
  12854. _defineSkyboxName: string;
  12855. /** @hidden */
  12856. _defineOppositeZ: string;
  12857. /** @hidden */
  12858. _cubeSamplerName: string;
  12859. /** @hidden */
  12860. _2DSamplerName: string;
  12861. protected _positionUVWName: string;
  12862. protected _directionWName: string;
  12863. protected _reflectionVectorName: string;
  12864. /** @hidden */
  12865. _reflectionCoordsName: string;
  12866. /** @hidden */
  12867. _reflectionMatrixName: string;
  12868. protected _reflectionColorName: string;
  12869. /**
  12870. * Gets or sets the texture associated with the node
  12871. */
  12872. texture: Nullable<BaseTexture>;
  12873. /**
  12874. * Create a new ReflectionTextureBaseBlock
  12875. * @param name defines the block name
  12876. */
  12877. constructor(name: string);
  12878. /**
  12879. * Gets the current class name
  12880. * @returns the class name
  12881. */
  12882. getClassName(): string;
  12883. /**
  12884. * Gets the world position input component
  12885. */
  12886. abstract get position(): NodeMaterialConnectionPoint;
  12887. /**
  12888. * Gets the world position input component
  12889. */
  12890. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12891. /**
  12892. * Gets the world normal input component
  12893. */
  12894. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12895. /**
  12896. * Gets the world input component
  12897. */
  12898. abstract get world(): NodeMaterialConnectionPoint;
  12899. /**
  12900. * Gets the camera (or eye) position component
  12901. */
  12902. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12903. /**
  12904. * Gets the view input component
  12905. */
  12906. abstract get view(): NodeMaterialConnectionPoint;
  12907. protected _getTexture(): Nullable<BaseTexture>;
  12908. autoConfigure(material: NodeMaterial): void;
  12909. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12910. isReady(): boolean;
  12911. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12912. /**
  12913. * Gets the code to inject in the vertex shader
  12914. * @param state current state of the node material building
  12915. * @returns the shader code
  12916. */
  12917. handleVertexSide(state: NodeMaterialBuildState): string;
  12918. /**
  12919. * Handles the inits for the fragment code path
  12920. * @param state node material build state
  12921. */
  12922. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12923. /**
  12924. * Generates the reflection coords code for the fragment code path
  12925. * @param worldNormalVarName name of the world normal variable
  12926. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12927. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12928. * @returns the shader code
  12929. */
  12930. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12931. /**
  12932. * Generates the reflection color code for the fragment code path
  12933. * @param lodVarName name of the lod variable
  12934. * @param swizzleLookupTexture swizzle to use for the final color variable
  12935. * @returns the shader code
  12936. */
  12937. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12938. /**
  12939. * Generates the code corresponding to the connected output points
  12940. * @param state node material build state
  12941. * @param varName name of the variable to output
  12942. * @returns the shader code
  12943. */
  12944. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12945. protected _buildBlock(state: NodeMaterialBuildState): this;
  12946. protected _dumpPropertiesCode(): string;
  12947. serialize(): any;
  12948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12949. }
  12950. }
  12951. declare module BABYLON {
  12952. /**
  12953. * Defines a connection point to be used for points with a custom object type
  12954. */
  12955. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12956. private _blockType;
  12957. private _blockName;
  12958. private _nameForCheking?;
  12959. /**
  12960. * Creates a new connection point
  12961. * @param name defines the connection point name
  12962. * @param ownerBlock defines the block hosting this connection point
  12963. * @param direction defines the direction of the connection point
  12964. */
  12965. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12966. /**
  12967. * Gets a number indicating if the current point can be connected to another point
  12968. * @param connectionPoint defines the other connection point
  12969. * @returns a number defining the compatibility state
  12970. */
  12971. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12972. /**
  12973. * Creates a block suitable to be used as an input for this input point.
  12974. * If null is returned, a block based on the point type will be created.
  12975. * @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
  12976. */
  12977. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12978. }
  12979. }
  12980. declare module BABYLON {
  12981. /**
  12982. * Enum defining the type of properties that can be edited in the property pages in the NME
  12983. */
  12984. export enum PropertyTypeForEdition {
  12985. /** property is a boolean */
  12986. Boolean = 0,
  12987. /** property is a float */
  12988. Float = 1,
  12989. /** property is a Vector2 */
  12990. Vector2 = 2,
  12991. /** property is a list of values */
  12992. List = 3
  12993. }
  12994. /**
  12995. * Interface that defines an option in a variable of type list
  12996. */
  12997. export interface IEditablePropertyListOption {
  12998. /** label of the option */
  12999. "label": string;
  13000. /** value of the option */
  13001. "value": number;
  13002. }
  13003. /**
  13004. * Interface that defines the options available for an editable property
  13005. */
  13006. export interface IEditablePropertyOption {
  13007. /** min value */
  13008. "min"?: number;
  13009. /** max value */
  13010. "max"?: number;
  13011. /** notifiers: indicates which actions to take when the property is changed */
  13012. "notifiers"?: {
  13013. /** the material should be rebuilt */
  13014. "rebuild"?: boolean;
  13015. /** the preview should be updated */
  13016. "update"?: boolean;
  13017. };
  13018. /** list of the options for a variable of type list */
  13019. "options"?: IEditablePropertyListOption[];
  13020. }
  13021. /**
  13022. * Interface that describes an editable property
  13023. */
  13024. export interface IPropertyDescriptionForEdition {
  13025. /** name of the property */
  13026. "propertyName": string;
  13027. /** display name of the property */
  13028. "displayName": string;
  13029. /** type of the property */
  13030. "type": PropertyTypeForEdition;
  13031. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13032. "groupName": string;
  13033. /** options for the property */
  13034. "options": IEditablePropertyOption;
  13035. }
  13036. /**
  13037. * Decorator that flags a property in a node material block as being editable
  13038. */
  13039. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13040. }
  13041. declare module BABYLON {
  13042. /**
  13043. * Block used to implement the refraction part of the sub surface module of the PBR material
  13044. */
  13045. export class RefractionBlock extends NodeMaterialBlock {
  13046. /** @hidden */
  13047. _define3DName: string;
  13048. /** @hidden */
  13049. _refractionMatrixName: string;
  13050. /** @hidden */
  13051. _defineLODRefractionAlpha: string;
  13052. /** @hidden */
  13053. _defineLinearSpecularRefraction: string;
  13054. /** @hidden */
  13055. _defineOppositeZ: string;
  13056. /** @hidden */
  13057. _cubeSamplerName: string;
  13058. /** @hidden */
  13059. _2DSamplerName: string;
  13060. /** @hidden */
  13061. _vRefractionMicrosurfaceInfosName: string;
  13062. /** @hidden */
  13063. _vRefractionInfosName: string;
  13064. /** @hidden */
  13065. _vRefractionFilteringInfoName: string;
  13066. private _scene;
  13067. /**
  13068. * The properties below are set by the main PBR block prior to calling methods of this class.
  13069. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13070. * It's less burden on the user side in the editor part.
  13071. */
  13072. /** @hidden */
  13073. viewConnectionPoint: NodeMaterialConnectionPoint;
  13074. /** @hidden */
  13075. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13076. /**
  13077. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13078. * Materials half opaque for instance using refraction could benefit from this control.
  13079. */
  13080. linkRefractionWithTransparency: boolean;
  13081. /**
  13082. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13083. */
  13084. invertRefractionY: boolean;
  13085. /**
  13086. * Gets or sets the texture associated with the node
  13087. */
  13088. texture: Nullable<BaseTexture>;
  13089. /**
  13090. * Create a new RefractionBlock
  13091. * @param name defines the block name
  13092. */
  13093. constructor(name: string);
  13094. /**
  13095. * Gets the current class name
  13096. * @returns the class name
  13097. */
  13098. getClassName(): string;
  13099. /**
  13100. * Gets the intensity input component
  13101. */
  13102. get intensity(): NodeMaterialConnectionPoint;
  13103. /**
  13104. * Gets the tint at distance input component
  13105. */
  13106. get tintAtDistance(): NodeMaterialConnectionPoint;
  13107. /**
  13108. * Gets the view input component
  13109. */
  13110. get view(): NodeMaterialConnectionPoint;
  13111. /**
  13112. * Gets the refraction object output component
  13113. */
  13114. get refraction(): NodeMaterialConnectionPoint;
  13115. /**
  13116. * Returns true if the block has a texture
  13117. */
  13118. get hasTexture(): boolean;
  13119. protected _getTexture(): Nullable<BaseTexture>;
  13120. autoConfigure(material: NodeMaterial): void;
  13121. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13122. isReady(): boolean;
  13123. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13124. /**
  13125. * Gets the main code of the block (fragment side)
  13126. * @param state current state of the node material building
  13127. * @returns the shader code
  13128. */
  13129. getCode(state: NodeMaterialBuildState): string;
  13130. protected _buildBlock(state: NodeMaterialBuildState): this;
  13131. protected _dumpPropertiesCode(): string;
  13132. serialize(): any;
  13133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13134. }
  13135. }
  13136. declare module BABYLON {
  13137. /**
  13138. * Base block used as input for post process
  13139. */
  13140. export class CurrentScreenBlock extends NodeMaterialBlock {
  13141. private _samplerName;
  13142. private _linearDefineName;
  13143. private _gammaDefineName;
  13144. private _mainUVName;
  13145. private _tempTextureRead;
  13146. /**
  13147. * Gets or sets the texture associated with the node
  13148. */
  13149. texture: Nullable<BaseTexture>;
  13150. /**
  13151. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13152. */
  13153. convertToGammaSpace: boolean;
  13154. /**
  13155. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13156. */
  13157. convertToLinearSpace: boolean;
  13158. /**
  13159. * Create a new CurrentScreenBlock
  13160. * @param name defines the block name
  13161. */
  13162. constructor(name: string);
  13163. /**
  13164. * Gets the current class name
  13165. * @returns the class name
  13166. */
  13167. getClassName(): string;
  13168. /**
  13169. * Gets the uv input component
  13170. */
  13171. get uv(): NodeMaterialConnectionPoint;
  13172. /**
  13173. * Gets the rgba output component
  13174. */
  13175. get rgba(): NodeMaterialConnectionPoint;
  13176. /**
  13177. * Gets the rgb output component
  13178. */
  13179. get rgb(): NodeMaterialConnectionPoint;
  13180. /**
  13181. * Gets the r output component
  13182. */
  13183. get r(): NodeMaterialConnectionPoint;
  13184. /**
  13185. * Gets the g output component
  13186. */
  13187. get g(): NodeMaterialConnectionPoint;
  13188. /**
  13189. * Gets the b output component
  13190. */
  13191. get b(): NodeMaterialConnectionPoint;
  13192. /**
  13193. * Gets the a output component
  13194. */
  13195. get a(): NodeMaterialConnectionPoint;
  13196. /**
  13197. * Initialize the block and prepare the context for build
  13198. * @param state defines the state that will be used for the build
  13199. */
  13200. initialize(state: NodeMaterialBuildState): void;
  13201. get target(): NodeMaterialBlockTargets;
  13202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13203. isReady(): boolean;
  13204. private _injectVertexCode;
  13205. private _writeTextureRead;
  13206. private _writeOutput;
  13207. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13208. serialize(): any;
  13209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13210. }
  13211. }
  13212. declare module BABYLON {
  13213. /**
  13214. * Base block used for the particle texture
  13215. */
  13216. export class ParticleTextureBlock extends NodeMaterialBlock {
  13217. private _samplerName;
  13218. private _linearDefineName;
  13219. private _gammaDefineName;
  13220. private _tempTextureRead;
  13221. /**
  13222. * Gets or sets the texture associated with the node
  13223. */
  13224. texture: Nullable<BaseTexture>;
  13225. /**
  13226. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13227. */
  13228. convertToGammaSpace: boolean;
  13229. /**
  13230. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13231. */
  13232. convertToLinearSpace: boolean;
  13233. /**
  13234. * Create a new ParticleTextureBlock
  13235. * @param name defines the block name
  13236. */
  13237. constructor(name: string);
  13238. /**
  13239. * Gets the current class name
  13240. * @returns the class name
  13241. */
  13242. getClassName(): string;
  13243. /**
  13244. * Gets the uv input component
  13245. */
  13246. get uv(): NodeMaterialConnectionPoint;
  13247. /**
  13248. * Gets the rgba output component
  13249. */
  13250. get rgba(): NodeMaterialConnectionPoint;
  13251. /**
  13252. * Gets the rgb output component
  13253. */
  13254. get rgb(): NodeMaterialConnectionPoint;
  13255. /**
  13256. * Gets the r output component
  13257. */
  13258. get r(): NodeMaterialConnectionPoint;
  13259. /**
  13260. * Gets the g output component
  13261. */
  13262. get g(): NodeMaterialConnectionPoint;
  13263. /**
  13264. * Gets the b output component
  13265. */
  13266. get b(): NodeMaterialConnectionPoint;
  13267. /**
  13268. * Gets the a output component
  13269. */
  13270. get a(): NodeMaterialConnectionPoint;
  13271. /**
  13272. * Initialize the block and prepare the context for build
  13273. * @param state defines the state that will be used for the build
  13274. */
  13275. initialize(state: NodeMaterialBuildState): void;
  13276. autoConfigure(material: NodeMaterial): void;
  13277. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13278. isReady(): boolean;
  13279. private _writeOutput;
  13280. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13281. serialize(): any;
  13282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13283. }
  13284. }
  13285. declare module BABYLON {
  13286. /**
  13287. * Class used to store shared data between 2 NodeMaterialBuildState
  13288. */
  13289. export class NodeMaterialBuildStateSharedData {
  13290. /**
  13291. * Gets the list of emitted varyings
  13292. */
  13293. temps: string[];
  13294. /**
  13295. * Gets the list of emitted varyings
  13296. */
  13297. varyings: string[];
  13298. /**
  13299. * Gets the varying declaration string
  13300. */
  13301. varyingDeclaration: string;
  13302. /**
  13303. * Input blocks
  13304. */
  13305. inputBlocks: InputBlock[];
  13306. /**
  13307. * Input blocks
  13308. */
  13309. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13310. /**
  13311. * Bindable blocks (Blocks that need to set data to the effect)
  13312. */
  13313. bindableBlocks: NodeMaterialBlock[];
  13314. /**
  13315. * List of blocks that can provide a compilation fallback
  13316. */
  13317. blocksWithFallbacks: NodeMaterialBlock[];
  13318. /**
  13319. * List of blocks that can provide a define update
  13320. */
  13321. blocksWithDefines: NodeMaterialBlock[];
  13322. /**
  13323. * List of blocks that can provide a repeatable content
  13324. */
  13325. repeatableContentBlocks: NodeMaterialBlock[];
  13326. /**
  13327. * List of blocks that can provide a dynamic list of uniforms
  13328. */
  13329. dynamicUniformBlocks: NodeMaterialBlock[];
  13330. /**
  13331. * List of blocks that can block the isReady function for the material
  13332. */
  13333. blockingBlocks: NodeMaterialBlock[];
  13334. /**
  13335. * Gets the list of animated inputs
  13336. */
  13337. animatedInputs: InputBlock[];
  13338. /**
  13339. * Build Id used to avoid multiple recompilations
  13340. */
  13341. buildId: number;
  13342. /** List of emitted variables */
  13343. variableNames: {
  13344. [key: string]: number;
  13345. };
  13346. /** List of emitted defines */
  13347. defineNames: {
  13348. [key: string]: number;
  13349. };
  13350. /** Should emit comments? */
  13351. emitComments: boolean;
  13352. /** Emit build activity */
  13353. verbose: boolean;
  13354. /** Gets or sets the hosting scene */
  13355. scene: Scene;
  13356. /**
  13357. * Gets the compilation hints emitted at compilation time
  13358. */
  13359. hints: {
  13360. needWorldViewMatrix: boolean;
  13361. needWorldViewProjectionMatrix: boolean;
  13362. needAlphaBlending: boolean;
  13363. needAlphaTesting: boolean;
  13364. };
  13365. /**
  13366. * List of compilation checks
  13367. */
  13368. checks: {
  13369. emitVertex: boolean;
  13370. emitFragment: boolean;
  13371. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13372. };
  13373. /**
  13374. * Is vertex program allowed to be empty?
  13375. */
  13376. allowEmptyVertexProgram: boolean;
  13377. /** Creates a new shared data */
  13378. constructor();
  13379. /**
  13380. * Emits console errors and exceptions if there is a failing check
  13381. */
  13382. emitErrors(): void;
  13383. }
  13384. }
  13385. declare module BABYLON {
  13386. /**
  13387. * Class used to store node based material build state
  13388. */
  13389. export class NodeMaterialBuildState {
  13390. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13391. supportUniformBuffers: boolean;
  13392. /**
  13393. * Gets the list of emitted attributes
  13394. */
  13395. attributes: string[];
  13396. /**
  13397. * Gets the list of emitted uniforms
  13398. */
  13399. uniforms: string[];
  13400. /**
  13401. * Gets the list of emitted constants
  13402. */
  13403. constants: string[];
  13404. /**
  13405. * Gets the list of emitted samplers
  13406. */
  13407. samplers: string[];
  13408. /**
  13409. * Gets the list of emitted functions
  13410. */
  13411. functions: {
  13412. [key: string]: string;
  13413. };
  13414. /**
  13415. * Gets the list of emitted extensions
  13416. */
  13417. extensions: {
  13418. [key: string]: string;
  13419. };
  13420. /**
  13421. * Gets the target of the compilation state
  13422. */
  13423. target: NodeMaterialBlockTargets;
  13424. /**
  13425. * Gets the list of emitted counters
  13426. */
  13427. counters: {
  13428. [key: string]: number;
  13429. };
  13430. /**
  13431. * Shared data between multiple NodeMaterialBuildState instances
  13432. */
  13433. sharedData: NodeMaterialBuildStateSharedData;
  13434. /** @hidden */
  13435. _vertexState: NodeMaterialBuildState;
  13436. /** @hidden */
  13437. _attributeDeclaration: string;
  13438. /** @hidden */
  13439. _uniformDeclaration: string;
  13440. /** @hidden */
  13441. _constantDeclaration: string;
  13442. /** @hidden */
  13443. _samplerDeclaration: string;
  13444. /** @hidden */
  13445. _varyingTransfer: string;
  13446. /** @hidden */
  13447. _injectAtEnd: string;
  13448. private _repeatableContentAnchorIndex;
  13449. /** @hidden */
  13450. _builtCompilationString: string;
  13451. /**
  13452. * Gets the emitted compilation strings
  13453. */
  13454. compilationString: string;
  13455. /**
  13456. * Finalize the compilation strings
  13457. * @param state defines the current compilation state
  13458. */
  13459. finalize(state: NodeMaterialBuildState): void;
  13460. /** @hidden */
  13461. get _repeatableContentAnchor(): string;
  13462. /** @hidden */
  13463. _getFreeVariableName(prefix: string): string;
  13464. /** @hidden */
  13465. _getFreeDefineName(prefix: string): string;
  13466. /** @hidden */
  13467. _excludeVariableName(name: string): void;
  13468. /** @hidden */
  13469. _emit2DSampler(name: string): void;
  13470. /** @hidden */
  13471. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13472. /** @hidden */
  13473. _emitExtension(name: string, extension: string, define?: string): void;
  13474. /** @hidden */
  13475. _emitFunction(name: string, code: string, comments: string): void;
  13476. /** @hidden */
  13477. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13478. replaceStrings?: {
  13479. search: RegExp;
  13480. replace: string;
  13481. }[];
  13482. repeatKey?: string;
  13483. }): string;
  13484. /** @hidden */
  13485. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13486. repeatKey?: string;
  13487. removeAttributes?: boolean;
  13488. removeUniforms?: boolean;
  13489. removeVaryings?: boolean;
  13490. removeIfDef?: boolean;
  13491. replaceStrings?: {
  13492. search: RegExp;
  13493. replace: string;
  13494. }[];
  13495. }, storeKey?: string): void;
  13496. /** @hidden */
  13497. _registerTempVariable(name: string): boolean;
  13498. /** @hidden */
  13499. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13500. /** @hidden */
  13501. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13502. /** @hidden */
  13503. _emitFloat(value: number): string;
  13504. }
  13505. }
  13506. declare module BABYLON {
  13507. /**
  13508. * Helper class used to generate session unique ID
  13509. */
  13510. export class UniqueIdGenerator {
  13511. private static _UniqueIdCounter;
  13512. /**
  13513. * Gets an unique (relatively to the current scene) Id
  13514. */
  13515. static get UniqueId(): number;
  13516. }
  13517. }
  13518. declare module BABYLON {
  13519. /**
  13520. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13521. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13522. */
  13523. export class EffectFallbacks implements IEffectFallbacks {
  13524. private _defines;
  13525. private _currentRank;
  13526. private _maxRank;
  13527. private _mesh;
  13528. /**
  13529. * Removes the fallback from the bound mesh.
  13530. */
  13531. unBindMesh(): void;
  13532. /**
  13533. * Adds a fallback on the specified property.
  13534. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13535. * @param define The name of the define in the shader
  13536. */
  13537. addFallback(rank: number, define: string): void;
  13538. /**
  13539. * Sets the mesh to use CPU skinning when needing to fallback.
  13540. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13541. * @param mesh The mesh to use the fallbacks.
  13542. */
  13543. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13544. /**
  13545. * Checks to see if more fallbacks are still availible.
  13546. */
  13547. get hasMoreFallbacks(): boolean;
  13548. /**
  13549. * Removes the defines that should be removed when falling back.
  13550. * @param currentDefines defines the current define statements for the shader.
  13551. * @param effect defines the current effect we try to compile
  13552. * @returns The resulting defines with defines of the current rank removed.
  13553. */
  13554. reduce(currentDefines: string, effect: Effect): string;
  13555. }
  13556. }
  13557. declare module BABYLON {
  13558. /**
  13559. * Defines a block that can be used inside a node based material
  13560. */
  13561. export class NodeMaterialBlock {
  13562. private _buildId;
  13563. private _buildTarget;
  13564. private _target;
  13565. private _isFinalMerger;
  13566. private _isInput;
  13567. private _name;
  13568. protected _isUnique: boolean;
  13569. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13570. inputsAreExclusive: boolean;
  13571. /** @hidden */
  13572. _codeVariableName: string;
  13573. /** @hidden */
  13574. _inputs: NodeMaterialConnectionPoint[];
  13575. /** @hidden */
  13576. _outputs: NodeMaterialConnectionPoint[];
  13577. /** @hidden */
  13578. _preparationId: number;
  13579. /** @hidden */
  13580. readonly _originalTargetIsNeutral: boolean;
  13581. /**
  13582. * Gets the name of the block
  13583. */
  13584. get name(): string;
  13585. /**
  13586. * Sets the name of the block. Will check if the name is valid.
  13587. */
  13588. set name(newName: string);
  13589. /**
  13590. * Gets or sets the unique id of the node
  13591. */
  13592. uniqueId: number;
  13593. /**
  13594. * Gets or sets the comments associated with this block
  13595. */
  13596. comments: string;
  13597. /**
  13598. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13599. */
  13600. get isUnique(): boolean;
  13601. /**
  13602. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13603. */
  13604. get isFinalMerger(): boolean;
  13605. /**
  13606. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13607. */
  13608. get isInput(): boolean;
  13609. /**
  13610. * Gets or sets the build Id
  13611. */
  13612. get buildId(): number;
  13613. set buildId(value: number);
  13614. /**
  13615. * Gets or sets the target of the block
  13616. */
  13617. get target(): NodeMaterialBlockTargets;
  13618. set target(value: NodeMaterialBlockTargets);
  13619. /**
  13620. * Gets the list of input points
  13621. */
  13622. get inputs(): NodeMaterialConnectionPoint[];
  13623. /** Gets the list of output points */
  13624. get outputs(): NodeMaterialConnectionPoint[];
  13625. /**
  13626. * Find an input by its name
  13627. * @param name defines the name of the input to look for
  13628. * @returns the input or null if not found
  13629. */
  13630. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13631. /**
  13632. * Find an output by its name
  13633. * @param name defines the name of the outputto look for
  13634. * @returns the output or null if not found
  13635. */
  13636. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13637. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13638. visibleInInspector: boolean;
  13639. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13640. visibleOnFrame: boolean;
  13641. /**
  13642. * Creates a new NodeMaterialBlock
  13643. * @param name defines the block name
  13644. * @param target defines the target of that block (Vertex by default)
  13645. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13646. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13647. */
  13648. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13649. /**
  13650. * Initialize the block and prepare the context for build
  13651. * @param state defines the state that will be used for the build
  13652. */
  13653. initialize(state: NodeMaterialBuildState): void;
  13654. /**
  13655. * Bind data to effect. Will only be called for blocks with isBindable === true
  13656. * @param effect defines the effect to bind data to
  13657. * @param nodeMaterial defines the hosting NodeMaterial
  13658. * @param mesh defines the mesh that will be rendered
  13659. * @param subMesh defines the submesh that will be rendered
  13660. */
  13661. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13662. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13663. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13664. protected _writeFloat(value: number): string;
  13665. /**
  13666. * Gets the current class name e.g. "NodeMaterialBlock"
  13667. * @returns the class name
  13668. */
  13669. getClassName(): string;
  13670. /**
  13671. * Register a new input. Must be called inside a block constructor
  13672. * @param name defines the connection point name
  13673. * @param type defines the connection point type
  13674. * @param isOptional defines a boolean indicating that this input can be omitted
  13675. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13676. * @param point an already created connection point. If not provided, create a new one
  13677. * @returns the current block
  13678. */
  13679. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13680. /**
  13681. * Register a new output. Must be called inside a block constructor
  13682. * @param name defines the connection point name
  13683. * @param type defines the connection point type
  13684. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13685. * @param point an already created connection point. If not provided, create a new one
  13686. * @returns the current block
  13687. */
  13688. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13689. /**
  13690. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13691. * @param forOutput defines an optional connection point to check compatibility with
  13692. * @returns the first available input or null
  13693. */
  13694. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13695. /**
  13696. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13697. * @param forBlock defines an optional block to check compatibility with
  13698. * @returns the first available input or null
  13699. */
  13700. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13701. /**
  13702. * Gets the sibling of the given output
  13703. * @param current defines the current output
  13704. * @returns the next output in the list or null
  13705. */
  13706. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13707. /**
  13708. * Connect current block with another block
  13709. * @param other defines the block to connect with
  13710. * @param options define the various options to help pick the right connections
  13711. * @returns the current block
  13712. */
  13713. connectTo(other: NodeMaterialBlock, options?: {
  13714. input?: string;
  13715. output?: string;
  13716. outputSwizzle?: string;
  13717. }): this | undefined;
  13718. protected _buildBlock(state: NodeMaterialBuildState): void;
  13719. /**
  13720. * Add uniforms, samplers and uniform buffers at compilation time
  13721. * @param state defines the state to update
  13722. * @param nodeMaterial defines the node material requesting the update
  13723. * @param defines defines the material defines to update
  13724. * @param uniformBuffers defines the list of uniform buffer names
  13725. */
  13726. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13727. /**
  13728. * Add potential fallbacks if shader compilation fails
  13729. * @param mesh defines the mesh to be rendered
  13730. * @param fallbacks defines the current prioritized list of fallbacks
  13731. */
  13732. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13733. /**
  13734. * Initialize defines for shader compilation
  13735. * @param mesh defines the mesh to be rendered
  13736. * @param nodeMaterial defines the node material requesting the update
  13737. * @param defines defines the material defines to update
  13738. * @param useInstances specifies that instances should be used
  13739. */
  13740. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13741. /**
  13742. * Update defines for shader compilation
  13743. * @param mesh defines the mesh to be rendered
  13744. * @param nodeMaterial defines the node material requesting the update
  13745. * @param defines defines the material defines to update
  13746. * @param useInstances specifies that instances should be used
  13747. * @param subMesh defines which submesh to render
  13748. */
  13749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13750. /**
  13751. * Lets the block try to connect some inputs automatically
  13752. * @param material defines the hosting NodeMaterial
  13753. */
  13754. autoConfigure(material: NodeMaterial): void;
  13755. /**
  13756. * Function called when a block is declared as repeatable content generator
  13757. * @param vertexShaderState defines the current compilation state for the vertex shader
  13758. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13759. * @param mesh defines the mesh to be rendered
  13760. * @param defines defines the material defines to update
  13761. */
  13762. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13763. /**
  13764. * Checks if the block is ready
  13765. * @param mesh defines the mesh to be rendered
  13766. * @param nodeMaterial defines the node material requesting the update
  13767. * @param defines defines the material defines to update
  13768. * @param useInstances specifies that instances should be used
  13769. * @returns true if the block is ready
  13770. */
  13771. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13772. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13773. private _processBuild;
  13774. /**
  13775. * Validates the new name for the block node.
  13776. * @param newName the new name to be given to the node.
  13777. * @returns false if the name is a reserve word, else true.
  13778. */
  13779. validateBlockName(newName: string): boolean;
  13780. /**
  13781. * Compile the current node and generate the shader code
  13782. * @param state defines the current compilation state (uniforms, samplers, current string)
  13783. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13784. * @returns true if already built
  13785. */
  13786. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13787. protected _inputRename(name: string): string;
  13788. protected _outputRename(name: string): string;
  13789. protected _dumpPropertiesCode(): string;
  13790. /** @hidden */
  13791. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13792. /** @hidden */
  13793. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13794. /**
  13795. * Clone the current block to a new identical block
  13796. * @param scene defines the hosting scene
  13797. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13798. * @returns a copy of the current block
  13799. */
  13800. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13801. /**
  13802. * Serializes this block in a JSON representation
  13803. * @returns the serialized block object
  13804. */
  13805. serialize(): any;
  13806. /** @hidden */
  13807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13808. private _deserializePortDisplayNamesAndExposedOnFrame;
  13809. /**
  13810. * Release resources
  13811. */
  13812. dispose(): void;
  13813. }
  13814. }
  13815. declare module BABYLON {
  13816. /**
  13817. * Base class of materials working in push mode in babylon JS
  13818. * @hidden
  13819. */
  13820. export class PushMaterial extends Material {
  13821. protected _activeEffect: Effect;
  13822. protected _normalMatrix: Matrix;
  13823. constructor(name: string, scene: Scene);
  13824. getEffect(): Effect;
  13825. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13826. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13827. /**
  13828. * Binds the given world matrix to the active effect
  13829. *
  13830. * @param world the matrix to bind
  13831. */
  13832. bindOnlyWorldMatrix(world: Matrix): void;
  13833. /**
  13834. * Binds the given normal matrix to the active effect
  13835. *
  13836. * @param normalMatrix the matrix to bind
  13837. */
  13838. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13839. bind(world: Matrix, mesh?: Mesh): void;
  13840. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13841. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13842. }
  13843. }
  13844. declare module BABYLON {
  13845. /**
  13846. * Root class for all node material optimizers
  13847. */
  13848. export class NodeMaterialOptimizer {
  13849. /**
  13850. * Function used to optimize a NodeMaterial graph
  13851. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13852. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13853. */
  13854. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13855. }
  13856. }
  13857. declare module BABYLON {
  13858. /**
  13859. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13860. */
  13861. export class TransformBlock extends NodeMaterialBlock {
  13862. /**
  13863. * Defines the value to use to complement W value to transform it to a Vector4
  13864. */
  13865. complementW: number;
  13866. /**
  13867. * Defines the value to use to complement z value to transform it to a Vector4
  13868. */
  13869. complementZ: number;
  13870. /**
  13871. * Creates a new TransformBlock
  13872. * @param name defines the block name
  13873. */
  13874. constructor(name: string);
  13875. /**
  13876. * Gets the current class name
  13877. * @returns the class name
  13878. */
  13879. getClassName(): string;
  13880. /**
  13881. * Gets the vector input
  13882. */
  13883. get vector(): NodeMaterialConnectionPoint;
  13884. /**
  13885. * Gets the output component
  13886. */
  13887. get output(): NodeMaterialConnectionPoint;
  13888. /**
  13889. * Gets the xyz output component
  13890. */
  13891. get xyz(): NodeMaterialConnectionPoint;
  13892. /**
  13893. * Gets the matrix transform input
  13894. */
  13895. get transform(): NodeMaterialConnectionPoint;
  13896. protected _buildBlock(state: NodeMaterialBuildState): this;
  13897. /**
  13898. * Update defines for shader compilation
  13899. * @param mesh defines the mesh to be rendered
  13900. * @param nodeMaterial defines the node material requesting the update
  13901. * @param defines defines the material defines to update
  13902. * @param useInstances specifies that instances should be used
  13903. * @param subMesh defines which submesh to render
  13904. */
  13905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13906. serialize(): any;
  13907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13908. protected _dumpPropertiesCode(): string;
  13909. }
  13910. }
  13911. declare module BABYLON {
  13912. /**
  13913. * Block used to output the vertex position
  13914. */
  13915. export class VertexOutputBlock extends NodeMaterialBlock {
  13916. /**
  13917. * Creates a new VertexOutputBlock
  13918. * @param name defines the block name
  13919. */
  13920. constructor(name: string);
  13921. /**
  13922. * Gets the current class name
  13923. * @returns the class name
  13924. */
  13925. getClassName(): string;
  13926. /**
  13927. * Gets the vector input component
  13928. */
  13929. get vector(): NodeMaterialConnectionPoint;
  13930. protected _buildBlock(state: NodeMaterialBuildState): this;
  13931. }
  13932. }
  13933. declare module BABYLON {
  13934. /**
  13935. * Block used to output the final color
  13936. */
  13937. export class FragmentOutputBlock extends NodeMaterialBlock {
  13938. /**
  13939. * Create a new FragmentOutputBlock
  13940. * @param name defines the block name
  13941. */
  13942. constructor(name: string);
  13943. /**
  13944. * Gets the current class name
  13945. * @returns the class name
  13946. */
  13947. getClassName(): string;
  13948. /**
  13949. * Gets the rgba input component
  13950. */
  13951. get rgba(): NodeMaterialConnectionPoint;
  13952. /**
  13953. * Gets the rgb input component
  13954. */
  13955. get rgb(): NodeMaterialConnectionPoint;
  13956. /**
  13957. * Gets the a input component
  13958. */
  13959. get a(): NodeMaterialConnectionPoint;
  13960. protected _buildBlock(state: NodeMaterialBuildState): this;
  13961. }
  13962. }
  13963. declare module BABYLON {
  13964. /**
  13965. * Block used for the particle ramp gradient section
  13966. */
  13967. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13968. /**
  13969. * Create a new ParticleRampGradientBlock
  13970. * @param name defines the block name
  13971. */
  13972. constructor(name: string);
  13973. /**
  13974. * Gets the current class name
  13975. * @returns the class name
  13976. */
  13977. getClassName(): string;
  13978. /**
  13979. * Gets the color input component
  13980. */
  13981. get color(): NodeMaterialConnectionPoint;
  13982. /**
  13983. * Gets the rampColor output component
  13984. */
  13985. get rampColor(): NodeMaterialConnectionPoint;
  13986. /**
  13987. * Initialize the block and prepare the context for build
  13988. * @param state defines the state that will be used for the build
  13989. */
  13990. initialize(state: NodeMaterialBuildState): void;
  13991. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13992. }
  13993. }
  13994. declare module BABYLON {
  13995. /**
  13996. * Block used for the particle blend multiply section
  13997. */
  13998. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13999. /**
  14000. * Create a new ParticleBlendMultiplyBlock
  14001. * @param name defines the block name
  14002. */
  14003. constructor(name: string);
  14004. /**
  14005. * Gets the current class name
  14006. * @returns the class name
  14007. */
  14008. getClassName(): string;
  14009. /**
  14010. * Gets the color input component
  14011. */
  14012. get color(): NodeMaterialConnectionPoint;
  14013. /**
  14014. * Gets the alphaTexture input component
  14015. */
  14016. get alphaTexture(): NodeMaterialConnectionPoint;
  14017. /**
  14018. * Gets the alphaColor input component
  14019. */
  14020. get alphaColor(): NodeMaterialConnectionPoint;
  14021. /**
  14022. * Gets the blendColor output component
  14023. */
  14024. get blendColor(): NodeMaterialConnectionPoint;
  14025. /**
  14026. * Initialize the block and prepare the context for build
  14027. * @param state defines the state that will be used for the build
  14028. */
  14029. initialize(state: NodeMaterialBuildState): void;
  14030. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14031. }
  14032. }
  14033. declare module BABYLON {
  14034. /**
  14035. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14036. */
  14037. export class VectorMergerBlock extends NodeMaterialBlock {
  14038. /**
  14039. * Create a new VectorMergerBlock
  14040. * @param name defines the block name
  14041. */
  14042. constructor(name: string);
  14043. /**
  14044. * Gets the current class name
  14045. * @returns the class name
  14046. */
  14047. getClassName(): string;
  14048. /**
  14049. * Gets the xyz component (input)
  14050. */
  14051. get xyzIn(): NodeMaterialConnectionPoint;
  14052. /**
  14053. * Gets the xy component (input)
  14054. */
  14055. get xyIn(): NodeMaterialConnectionPoint;
  14056. /**
  14057. * Gets the x component (input)
  14058. */
  14059. get x(): NodeMaterialConnectionPoint;
  14060. /**
  14061. * Gets the y component (input)
  14062. */
  14063. get y(): NodeMaterialConnectionPoint;
  14064. /**
  14065. * Gets the z component (input)
  14066. */
  14067. get z(): NodeMaterialConnectionPoint;
  14068. /**
  14069. * Gets the w component (input)
  14070. */
  14071. get w(): NodeMaterialConnectionPoint;
  14072. /**
  14073. * Gets the xyzw component (output)
  14074. */
  14075. get xyzw(): NodeMaterialConnectionPoint;
  14076. /**
  14077. * Gets the xyz component (output)
  14078. */
  14079. get xyzOut(): NodeMaterialConnectionPoint;
  14080. /**
  14081. * Gets the xy component (output)
  14082. */
  14083. get xyOut(): NodeMaterialConnectionPoint;
  14084. /**
  14085. * Gets the xy component (output)
  14086. * @deprecated Please use xyOut instead.
  14087. */
  14088. get xy(): NodeMaterialConnectionPoint;
  14089. /**
  14090. * Gets the xyz component (output)
  14091. * @deprecated Please use xyzOut instead.
  14092. */
  14093. get xyz(): NodeMaterialConnectionPoint;
  14094. protected _buildBlock(state: NodeMaterialBuildState): this;
  14095. }
  14096. }
  14097. declare module BABYLON {
  14098. /**
  14099. * Block used to remap a float from a range to a new one
  14100. */
  14101. export class RemapBlock extends NodeMaterialBlock {
  14102. /**
  14103. * Gets or sets the source range
  14104. */
  14105. sourceRange: Vector2;
  14106. /**
  14107. * Gets or sets the target range
  14108. */
  14109. targetRange: Vector2;
  14110. /**
  14111. * Creates a new RemapBlock
  14112. * @param name defines the block name
  14113. */
  14114. constructor(name: string);
  14115. /**
  14116. * Gets the current class name
  14117. * @returns the class name
  14118. */
  14119. getClassName(): string;
  14120. /**
  14121. * Gets the input component
  14122. */
  14123. get input(): NodeMaterialConnectionPoint;
  14124. /**
  14125. * Gets the source min input component
  14126. */
  14127. get sourceMin(): NodeMaterialConnectionPoint;
  14128. /**
  14129. * Gets the source max input component
  14130. */
  14131. get sourceMax(): NodeMaterialConnectionPoint;
  14132. /**
  14133. * Gets the target min input component
  14134. */
  14135. get targetMin(): NodeMaterialConnectionPoint;
  14136. /**
  14137. * Gets the target max input component
  14138. */
  14139. get targetMax(): NodeMaterialConnectionPoint;
  14140. /**
  14141. * Gets the output component
  14142. */
  14143. get output(): NodeMaterialConnectionPoint;
  14144. protected _buildBlock(state: NodeMaterialBuildState): this;
  14145. protected _dumpPropertiesCode(): string;
  14146. serialize(): any;
  14147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14148. }
  14149. }
  14150. declare module BABYLON {
  14151. /**
  14152. * Block used to multiply 2 values
  14153. */
  14154. export class MultiplyBlock extends NodeMaterialBlock {
  14155. /**
  14156. * Creates a new MultiplyBlock
  14157. * @param name defines the block name
  14158. */
  14159. constructor(name: string);
  14160. /**
  14161. * Gets the current class name
  14162. * @returns the class name
  14163. */
  14164. getClassName(): string;
  14165. /**
  14166. * Gets the left operand input component
  14167. */
  14168. get left(): NodeMaterialConnectionPoint;
  14169. /**
  14170. * Gets the right operand input component
  14171. */
  14172. get right(): NodeMaterialConnectionPoint;
  14173. /**
  14174. * Gets the output component
  14175. */
  14176. get output(): NodeMaterialConnectionPoint;
  14177. protected _buildBlock(state: NodeMaterialBuildState): this;
  14178. }
  14179. }
  14180. declare module BABYLON {
  14181. /** Interface used by value gradients (color, factor, ...) */
  14182. export interface IValueGradient {
  14183. /**
  14184. * Gets or sets the gradient value (between 0 and 1)
  14185. */
  14186. gradient: number;
  14187. }
  14188. /** Class used to store color4 gradient */
  14189. export class ColorGradient implements IValueGradient {
  14190. /**
  14191. * Gets or sets the gradient value (between 0 and 1)
  14192. */
  14193. gradient: number;
  14194. /**
  14195. * Gets or sets first associated color
  14196. */
  14197. color1: Color4;
  14198. /**
  14199. * Gets or sets second associated color
  14200. */
  14201. color2?: Color4 | undefined;
  14202. /**
  14203. * Creates a new color4 gradient
  14204. * @param gradient gets or sets the gradient value (between 0 and 1)
  14205. * @param color1 gets or sets first associated color
  14206. * @param color2 gets or sets first second color
  14207. */
  14208. constructor(
  14209. /**
  14210. * Gets or sets the gradient value (between 0 and 1)
  14211. */
  14212. gradient: number,
  14213. /**
  14214. * Gets or sets first associated color
  14215. */
  14216. color1: Color4,
  14217. /**
  14218. * Gets or sets second associated color
  14219. */
  14220. color2?: Color4 | undefined);
  14221. /**
  14222. * Will get a color picked randomly between color1 and color2.
  14223. * If color2 is undefined then color1 will be used
  14224. * @param result defines the target Color4 to store the result in
  14225. */
  14226. getColorToRef(result: Color4): void;
  14227. }
  14228. /** Class used to store color 3 gradient */
  14229. export class Color3Gradient implements IValueGradient {
  14230. /**
  14231. * Gets or sets the gradient value (between 0 and 1)
  14232. */
  14233. gradient: number;
  14234. /**
  14235. * Gets or sets the associated color
  14236. */
  14237. color: Color3;
  14238. /**
  14239. * Creates a new color3 gradient
  14240. * @param gradient gets or sets the gradient value (between 0 and 1)
  14241. * @param color gets or sets associated color
  14242. */
  14243. constructor(
  14244. /**
  14245. * Gets or sets the gradient value (between 0 and 1)
  14246. */
  14247. gradient: number,
  14248. /**
  14249. * Gets or sets the associated color
  14250. */
  14251. color: Color3);
  14252. }
  14253. /** Class used to store factor gradient */
  14254. export class FactorGradient implements IValueGradient {
  14255. /**
  14256. * Gets or sets the gradient value (between 0 and 1)
  14257. */
  14258. gradient: number;
  14259. /**
  14260. * Gets or sets first associated factor
  14261. */
  14262. factor1: number;
  14263. /**
  14264. * Gets or sets second associated factor
  14265. */
  14266. factor2?: number | undefined;
  14267. /**
  14268. * Creates a new factor gradient
  14269. * @param gradient gets or sets the gradient value (between 0 and 1)
  14270. * @param factor1 gets or sets first associated factor
  14271. * @param factor2 gets or sets second associated factor
  14272. */
  14273. constructor(
  14274. /**
  14275. * Gets or sets the gradient value (between 0 and 1)
  14276. */
  14277. gradient: number,
  14278. /**
  14279. * Gets or sets first associated factor
  14280. */
  14281. factor1: number,
  14282. /**
  14283. * Gets or sets second associated factor
  14284. */
  14285. factor2?: number | undefined);
  14286. /**
  14287. * Will get a number picked randomly between factor1 and factor2.
  14288. * If factor2 is undefined then factor1 will be used
  14289. * @returns the picked number
  14290. */
  14291. getFactor(): number;
  14292. }
  14293. /**
  14294. * Helper used to simplify some generic gradient tasks
  14295. */
  14296. export class GradientHelper {
  14297. /**
  14298. * Gets the current gradient from an array of IValueGradient
  14299. * @param ratio defines the current ratio to get
  14300. * @param gradients defines the array of IValueGradient
  14301. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14302. */
  14303. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14304. }
  14305. }
  14306. declare module BABYLON {
  14307. interface ThinEngine {
  14308. /**
  14309. * Creates a raw texture
  14310. * @param data defines the data to store in the texture
  14311. * @param width defines the width of the texture
  14312. * @param height defines the height of the texture
  14313. * @param format defines the format of the data
  14314. * @param generateMipMaps defines if the engine should generate the mip levels
  14315. * @param invertY defines if data must be stored with Y axis inverted
  14316. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14317. * @param compression defines the compression used (null by default)
  14318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14319. * @returns the raw texture inside an InternalTexture
  14320. */
  14321. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14322. /**
  14323. * Update a raw texture
  14324. * @param texture defines the texture to update
  14325. * @param data defines the data to store in the texture
  14326. * @param format defines the format of the data
  14327. * @param invertY defines if data must be stored with Y axis inverted
  14328. */
  14329. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14330. /**
  14331. * Update a raw texture
  14332. * @param texture defines the texture to update
  14333. * @param data defines the data to store in the texture
  14334. * @param format defines the format of the data
  14335. * @param invertY defines if data must be stored with Y axis inverted
  14336. * @param compression defines the compression used (null by default)
  14337. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14338. */
  14339. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14340. /**
  14341. * Creates a new raw cube texture
  14342. * @param data defines the array of data to use to create each face
  14343. * @param size defines the size of the textures
  14344. * @param format defines the format of the data
  14345. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14346. * @param generateMipMaps defines if the engine should generate the mip levels
  14347. * @param invertY defines if data must be stored with Y axis inverted
  14348. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14349. * @param compression defines the compression used (null by default)
  14350. * @returns the cube texture as an InternalTexture
  14351. */
  14352. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14353. /**
  14354. * Update a raw cube texture
  14355. * @param texture defines the texture to udpdate
  14356. * @param data defines the data to store
  14357. * @param format defines the data format
  14358. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14359. * @param invertY defines if data must be stored with Y axis inverted
  14360. */
  14361. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14362. /**
  14363. * Update a raw cube texture
  14364. * @param texture defines the texture to udpdate
  14365. * @param data defines the data to store
  14366. * @param format defines the data format
  14367. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14368. * @param invertY defines if data must be stored with Y axis inverted
  14369. * @param compression defines the compression used (null by default)
  14370. */
  14371. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14372. /**
  14373. * Update a raw cube texture
  14374. * @param texture defines the texture to udpdate
  14375. * @param data defines the data to store
  14376. * @param format defines the data format
  14377. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14378. * @param invertY defines if data must be stored with Y axis inverted
  14379. * @param compression defines the compression used (null by default)
  14380. * @param level defines which level of the texture to update
  14381. */
  14382. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14383. /**
  14384. * Creates a new raw cube texture from a specified url
  14385. * @param url defines the url where the data is located
  14386. * @param scene defines the current scene
  14387. * @param size defines the size of the textures
  14388. * @param format defines the format of the data
  14389. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14390. * @param noMipmap defines if the engine should avoid generating the mip levels
  14391. * @param callback defines a callback used to extract texture data from loaded data
  14392. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14393. * @param onLoad defines a callback called when texture is loaded
  14394. * @param onError defines a callback called if there is an error
  14395. * @returns the cube texture as an InternalTexture
  14396. */
  14397. 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;
  14398. /**
  14399. * Creates a new raw cube texture from a specified url
  14400. * @param url defines the url where the data is located
  14401. * @param scene defines the current scene
  14402. * @param size defines the size of the textures
  14403. * @param format defines the format of the data
  14404. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14405. * @param noMipmap defines if the engine should avoid generating the mip levels
  14406. * @param callback defines a callback used to extract texture data from loaded data
  14407. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14408. * @param onLoad defines a callback called when texture is loaded
  14409. * @param onError defines a callback called if there is an error
  14410. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14411. * @param invertY defines if data must be stored with Y axis inverted
  14412. * @returns the cube texture as an InternalTexture
  14413. */
  14414. 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;
  14415. /**
  14416. * Creates a new raw 3D texture
  14417. * @param data defines the data used to create the texture
  14418. * @param width defines the width of the texture
  14419. * @param height defines the height of the texture
  14420. * @param depth defines the depth of the texture
  14421. * @param format defines the format of the texture
  14422. * @param generateMipMaps defines if the engine must generate mip levels
  14423. * @param invertY defines if data must be stored with Y axis inverted
  14424. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14425. * @param compression defines the compressed used (can be null)
  14426. * @param textureType defines the compressed used (can be null)
  14427. * @returns a new raw 3D texture (stored in an InternalTexture)
  14428. */
  14429. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14430. /**
  14431. * Update a raw 3D texture
  14432. * @param texture defines the texture to update
  14433. * @param data defines the data to store
  14434. * @param format defines the data format
  14435. * @param invertY defines if data must be stored with Y axis inverted
  14436. */
  14437. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14438. /**
  14439. * Update a raw 3D texture
  14440. * @param texture defines the texture to update
  14441. * @param data defines the data to store
  14442. * @param format defines the data format
  14443. * @param invertY defines if data must be stored with Y axis inverted
  14444. * @param compression defines the used compression (can be null)
  14445. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14446. */
  14447. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14448. /**
  14449. * Creates a new raw 2D array texture
  14450. * @param data defines the data used to create the texture
  14451. * @param width defines the width of the texture
  14452. * @param height defines the height of the texture
  14453. * @param depth defines the number of layers of the texture
  14454. * @param format defines the format of the texture
  14455. * @param generateMipMaps defines if the engine must generate mip levels
  14456. * @param invertY defines if data must be stored with Y axis inverted
  14457. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14458. * @param compression defines the compressed used (can be null)
  14459. * @param textureType defines the compressed used (can be null)
  14460. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14461. */
  14462. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14463. /**
  14464. * Update a raw 2D array texture
  14465. * @param texture defines the texture to update
  14466. * @param data defines the data to store
  14467. * @param format defines the data format
  14468. * @param invertY defines if data must be stored with Y axis inverted
  14469. */
  14470. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14471. /**
  14472. * Update a raw 2D array texture
  14473. * @param texture defines the texture to update
  14474. * @param data defines the data to store
  14475. * @param format defines the data format
  14476. * @param invertY defines if data must be stored with Y axis inverted
  14477. * @param compression defines the used compression (can be null)
  14478. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14479. */
  14480. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14481. }
  14482. }
  14483. declare module BABYLON {
  14484. /**
  14485. * Raw texture can help creating a texture directly from an array of data.
  14486. * This can be super useful if you either get the data from an uncompressed source or
  14487. * if you wish to create your texture pixel by pixel.
  14488. */
  14489. export class RawTexture extends Texture {
  14490. /**
  14491. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14492. */
  14493. format: number;
  14494. /**
  14495. * Instantiates a new RawTexture.
  14496. * Raw texture can help creating a texture directly from an array of data.
  14497. * This can be super useful if you either get the data from an uncompressed source or
  14498. * if you wish to create your texture pixel by pixel.
  14499. * @param data define the array of data to use to create the texture
  14500. * @param width define the width of the texture
  14501. * @param height define the height of the texture
  14502. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14503. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14504. * @param generateMipMaps define whether mip maps should be generated or not
  14505. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14506. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14507. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14508. */
  14509. constructor(data: ArrayBufferView, width: number, height: number,
  14510. /**
  14511. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14512. */
  14513. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14514. /**
  14515. * Updates the texture underlying data.
  14516. * @param data Define the new data of the texture
  14517. */
  14518. update(data: ArrayBufferView): void;
  14519. /**
  14520. * Creates a luminance texture from some data.
  14521. * @param data Define the texture data
  14522. * @param width Define the width of the texture
  14523. * @param height Define the height of the texture
  14524. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14525. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14526. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14527. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14528. * @returns the luminance texture
  14529. */
  14530. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14531. /**
  14532. * Creates a luminance alpha texture from some data.
  14533. * @param data Define the texture data
  14534. * @param width Define the width of the texture
  14535. * @param height Define the height of the texture
  14536. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14537. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14538. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14539. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14540. * @returns the luminance alpha texture
  14541. */
  14542. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14543. /**
  14544. * Creates an alpha texture from some data.
  14545. * @param data Define the texture data
  14546. * @param width Define the width of the texture
  14547. * @param height Define the height of the texture
  14548. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14549. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14550. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14551. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14552. * @returns the alpha texture
  14553. */
  14554. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14555. /**
  14556. * Creates a RGB texture from some data.
  14557. * @param data Define the texture data
  14558. * @param width Define the width of the texture
  14559. * @param height Define the height of the texture
  14560. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14561. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14562. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14563. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14564. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14565. * @returns the RGB alpha texture
  14566. */
  14567. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14568. /**
  14569. * Creates a RGBA texture from some data.
  14570. * @param data Define the texture data
  14571. * @param width Define the width of the texture
  14572. * @param height Define the height of the texture
  14573. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14574. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14575. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14576. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14577. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14578. * @returns the RGBA texture
  14579. */
  14580. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14581. /**
  14582. * Creates a R texture from some data.
  14583. * @param data Define the texture data
  14584. * @param width Define the width of the texture
  14585. * @param height Define the height of the texture
  14586. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14587. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14588. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14589. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14590. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14591. * @returns the R texture
  14592. */
  14593. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14594. }
  14595. }
  14596. declare module BABYLON {
  14597. interface ThinEngine {
  14598. /**
  14599. * Update a dynamic index buffer
  14600. * @param indexBuffer defines the target index buffer
  14601. * @param indices defines the data to update
  14602. * @param offset defines the offset in the target index buffer where update should start
  14603. */
  14604. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14605. /**
  14606. * Updates a dynamic vertex buffer.
  14607. * @param vertexBuffer the vertex buffer to update
  14608. * @param data the data used to update the vertex buffer
  14609. * @param byteOffset the byte offset of the data
  14610. * @param byteLength the byte length of the data
  14611. */
  14612. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14613. }
  14614. }
  14615. declare module BABYLON {
  14616. interface AbstractScene {
  14617. /**
  14618. * The list of procedural textures added to the scene
  14619. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14620. */
  14621. proceduralTextures: Array<ProceduralTexture>;
  14622. }
  14623. /**
  14624. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14625. * in a given scene.
  14626. */
  14627. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14628. /**
  14629. * The component name helpfull to identify the component in the list of scene components.
  14630. */
  14631. readonly name: string;
  14632. /**
  14633. * The scene the component belongs to.
  14634. */
  14635. scene: Scene;
  14636. /**
  14637. * Creates a new instance of the component for the given scene
  14638. * @param scene Defines the scene to register the component in
  14639. */
  14640. constructor(scene: Scene);
  14641. /**
  14642. * Registers the component in a given scene
  14643. */
  14644. register(): void;
  14645. /**
  14646. * Rebuilds the elements related to this component in case of
  14647. * context lost for instance.
  14648. */
  14649. rebuild(): void;
  14650. /**
  14651. * Disposes the component and the associated ressources.
  14652. */
  14653. dispose(): void;
  14654. private _beforeClear;
  14655. }
  14656. }
  14657. declare module BABYLON {
  14658. interface ThinEngine {
  14659. /**
  14660. * Creates a new render target cube texture
  14661. * @param size defines the size of the texture
  14662. * @param options defines the options used to create the texture
  14663. * @returns a new render target cube texture stored in an InternalTexture
  14664. */
  14665. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14666. }
  14667. }
  14668. declare module BABYLON {
  14669. /** @hidden */
  14670. export var proceduralVertexShader: {
  14671. name: string;
  14672. shader: string;
  14673. };
  14674. }
  14675. declare module BABYLON {
  14676. /**
  14677. * 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.
  14678. * This is the base class of any Procedural texture and contains most of the shareable code.
  14679. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14680. */
  14681. export class ProceduralTexture extends Texture {
  14682. /**
  14683. * Define if the texture is enabled or not (disabled texture will not render)
  14684. */
  14685. isEnabled: boolean;
  14686. /**
  14687. * Define if the texture must be cleared before rendering (default is true)
  14688. */
  14689. autoClear: boolean;
  14690. /**
  14691. * Callback called when the texture is generated
  14692. */
  14693. onGenerated: () => void;
  14694. /**
  14695. * Event raised when the texture is generated
  14696. */
  14697. onGeneratedObservable: Observable<ProceduralTexture>;
  14698. /**
  14699. * Event raised before the texture is generated
  14700. */
  14701. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14702. /**
  14703. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14704. */
  14705. nodeMaterialSource: Nullable<NodeMaterial>;
  14706. /** @hidden */
  14707. _generateMipMaps: boolean;
  14708. /** @hidden **/
  14709. _effect: Effect;
  14710. /** @hidden */
  14711. _textures: {
  14712. [key: string]: Texture;
  14713. };
  14714. /** @hidden */
  14715. protected _fallbackTexture: Nullable<Texture>;
  14716. private _size;
  14717. private _textureType;
  14718. private _currentRefreshId;
  14719. private _frameId;
  14720. private _refreshRate;
  14721. private _vertexBuffers;
  14722. private _indexBuffer;
  14723. private _uniforms;
  14724. private _samplers;
  14725. private _fragment;
  14726. private _floats;
  14727. private _ints;
  14728. private _floatsArrays;
  14729. private _colors3;
  14730. private _colors4;
  14731. private _vectors2;
  14732. private _vectors3;
  14733. private _matrices;
  14734. private _fallbackTextureUsed;
  14735. private _fullEngine;
  14736. private _cachedDefines;
  14737. private _contentUpdateId;
  14738. private _contentData;
  14739. /**
  14740. * Instantiates a new procedural texture.
  14741. * 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.
  14742. * This is the base class of any Procedural texture and contains most of the shareable code.
  14743. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14744. * @param name Define the name of the texture
  14745. * @param size Define the size of the texture to create
  14746. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14747. * @param scene Define the scene the texture belongs to
  14748. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14749. * @param generateMipMaps Define if the texture should creates mip maps or not
  14750. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14751. * @param textureType The FBO internal texture type
  14752. */
  14753. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14754. /**
  14755. * The effect that is created when initializing the post process.
  14756. * @returns The created effect corresponding the the postprocess.
  14757. */
  14758. getEffect(): Effect;
  14759. /**
  14760. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14761. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14762. */
  14763. getContent(): Nullable<Promise<ArrayBufferView>>;
  14764. private _createIndexBuffer;
  14765. /** @hidden */
  14766. _rebuild(): void;
  14767. /**
  14768. * Resets the texture in order to recreate its associated resources.
  14769. * This can be called in case of context loss
  14770. */
  14771. reset(): void;
  14772. protected _getDefines(): string;
  14773. /**
  14774. * Is the texture ready to be used ? (rendered at least once)
  14775. * @returns true if ready, otherwise, false.
  14776. */
  14777. isReady(): boolean;
  14778. /**
  14779. * Resets the refresh counter of the texture and start bak from scratch.
  14780. * Could be useful to regenerate the texture if it is setup to render only once.
  14781. */
  14782. resetRefreshCounter(): void;
  14783. /**
  14784. * Set the fragment shader to use in order to render the texture.
  14785. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14786. */
  14787. setFragment(fragment: any): void;
  14788. /**
  14789. * Define the refresh rate of the texture or the rendering frequency.
  14790. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14791. */
  14792. get refreshRate(): number;
  14793. set refreshRate(value: number);
  14794. /** @hidden */
  14795. _shouldRender(): boolean;
  14796. /**
  14797. * Get the size the texture is rendering at.
  14798. * @returns the size (on cube texture it is always squared)
  14799. */
  14800. getRenderSize(): RenderTargetTextureSize;
  14801. /**
  14802. * Resize the texture to new value.
  14803. * @param size Define the new size the texture should have
  14804. * @param generateMipMaps Define whether the new texture should create mip maps
  14805. */
  14806. resize(size: number, generateMipMaps: boolean): void;
  14807. private _checkUniform;
  14808. /**
  14809. * Set a texture in the shader program used to render.
  14810. * @param name Define the name of the uniform samplers as defined in the shader
  14811. * @param texture Define the texture to bind to this sampler
  14812. * @return the texture itself allowing "fluent" like uniform updates
  14813. */
  14814. setTexture(name: string, texture: Texture): ProceduralTexture;
  14815. /**
  14816. * Set a float in the shader.
  14817. * @param name Define the name of the uniform as defined in the shader
  14818. * @param value Define the value to give to the uniform
  14819. * @return the texture itself allowing "fluent" like uniform updates
  14820. */
  14821. setFloat(name: string, value: number): ProceduralTexture;
  14822. /**
  14823. * Set a int in the shader.
  14824. * @param name Define the name of the uniform as defined in the shader
  14825. * @param value Define the value to give to the uniform
  14826. * @return the texture itself allowing "fluent" like uniform updates
  14827. */
  14828. setInt(name: string, value: number): ProceduralTexture;
  14829. /**
  14830. * Set an array of floats in the shader.
  14831. * @param name Define the name of the uniform as defined in the shader
  14832. * @param value Define the value to give to the uniform
  14833. * @return the texture itself allowing "fluent" like uniform updates
  14834. */
  14835. setFloats(name: string, value: number[]): ProceduralTexture;
  14836. /**
  14837. * Set a vec3 in the shader from a Color3.
  14838. * @param name Define the name of the uniform as defined in the shader
  14839. * @param value Define the value to give to the uniform
  14840. * @return the texture itself allowing "fluent" like uniform updates
  14841. */
  14842. setColor3(name: string, value: Color3): ProceduralTexture;
  14843. /**
  14844. * Set a vec4 in the shader from a Color4.
  14845. * @param name Define the name of the uniform as defined in the shader
  14846. * @param value Define the value to give to the uniform
  14847. * @return the texture itself allowing "fluent" like uniform updates
  14848. */
  14849. setColor4(name: string, value: Color4): ProceduralTexture;
  14850. /**
  14851. * Set a vec2 in the shader from a Vector2.
  14852. * @param name Define the name of the uniform as defined in the shader
  14853. * @param value Define the value to give to the uniform
  14854. * @return the texture itself allowing "fluent" like uniform updates
  14855. */
  14856. setVector2(name: string, value: Vector2): ProceduralTexture;
  14857. /**
  14858. * Set a vec3 in the shader from a Vector3.
  14859. * @param name Define the name of the uniform as defined in the shader
  14860. * @param value Define the value to give to the uniform
  14861. * @return the texture itself allowing "fluent" like uniform updates
  14862. */
  14863. setVector3(name: string, value: Vector3): ProceduralTexture;
  14864. /**
  14865. * Set a mat4 in the shader from a MAtrix.
  14866. * @param name Define the name of the uniform as defined in the shader
  14867. * @param value Define the value to give to the uniform
  14868. * @return the texture itself allowing "fluent" like uniform updates
  14869. */
  14870. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14871. /**
  14872. * Render the texture to its associated render target.
  14873. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14874. */
  14875. render(useCameraPostProcess?: boolean): void;
  14876. /**
  14877. * Clone the texture.
  14878. * @returns the cloned texture
  14879. */
  14880. clone(): ProceduralTexture;
  14881. /**
  14882. * Dispose the texture and release its asoociated resources.
  14883. */
  14884. dispose(): void;
  14885. }
  14886. }
  14887. declare module BABYLON {
  14888. /**
  14889. * This represents the base class for particle system in Babylon.
  14890. * 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.
  14891. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14892. * @example https://doc.babylonjs.com/babylon101/particles
  14893. */
  14894. export class BaseParticleSystem {
  14895. /**
  14896. * Source color is added to the destination color without alpha affecting the result
  14897. */
  14898. static BLENDMODE_ONEONE: number;
  14899. /**
  14900. * Blend current color and particle color using particle’s alpha
  14901. */
  14902. static BLENDMODE_STANDARD: number;
  14903. /**
  14904. * Add current color and particle color multiplied by particle’s alpha
  14905. */
  14906. static BLENDMODE_ADD: number;
  14907. /**
  14908. * Multiply current color with particle color
  14909. */
  14910. static BLENDMODE_MULTIPLY: number;
  14911. /**
  14912. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14913. */
  14914. static BLENDMODE_MULTIPLYADD: number;
  14915. /**
  14916. * List of animations used by the particle system.
  14917. */
  14918. animations: Animation[];
  14919. /**
  14920. * Gets or sets the unique id of the particle system
  14921. */
  14922. uniqueId: number;
  14923. /**
  14924. * The id of the Particle system.
  14925. */
  14926. id: string;
  14927. /**
  14928. * The friendly name of the Particle system.
  14929. */
  14930. name: string;
  14931. /**
  14932. * Snippet ID if the particle system was created from the snippet server
  14933. */
  14934. snippetId: string;
  14935. /**
  14936. * The rendering group used by the Particle system to chose when to render.
  14937. */
  14938. renderingGroupId: number;
  14939. /**
  14940. * The emitter represents the Mesh or position we are attaching the particle system to.
  14941. */
  14942. emitter: Nullable<AbstractMesh | Vector3>;
  14943. /**
  14944. * The maximum number of particles to emit per frame
  14945. */
  14946. emitRate: number;
  14947. /**
  14948. * If you want to launch only a few particles at once, that can be done, as well.
  14949. */
  14950. manualEmitCount: number;
  14951. /**
  14952. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14953. */
  14954. updateSpeed: number;
  14955. /**
  14956. * The amount of time the particle system is running (depends of the overall update speed).
  14957. */
  14958. targetStopDuration: number;
  14959. /**
  14960. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14961. */
  14962. disposeOnStop: boolean;
  14963. /**
  14964. * Minimum power of emitting particles.
  14965. */
  14966. minEmitPower: number;
  14967. /**
  14968. * Maximum power of emitting particles.
  14969. */
  14970. maxEmitPower: number;
  14971. /**
  14972. * Minimum life time of emitting particles.
  14973. */
  14974. minLifeTime: number;
  14975. /**
  14976. * Maximum life time of emitting particles.
  14977. */
  14978. maxLifeTime: number;
  14979. /**
  14980. * Minimum Size of emitting particles.
  14981. */
  14982. minSize: number;
  14983. /**
  14984. * Maximum Size of emitting particles.
  14985. */
  14986. maxSize: number;
  14987. /**
  14988. * Minimum scale of emitting particles on X axis.
  14989. */
  14990. minScaleX: number;
  14991. /**
  14992. * Maximum scale of emitting particles on X axis.
  14993. */
  14994. maxScaleX: number;
  14995. /**
  14996. * Minimum scale of emitting particles on Y axis.
  14997. */
  14998. minScaleY: number;
  14999. /**
  15000. * Maximum scale of emitting particles on Y axis.
  15001. */
  15002. maxScaleY: number;
  15003. /**
  15004. * Gets or sets the minimal initial rotation in radians.
  15005. */
  15006. minInitialRotation: number;
  15007. /**
  15008. * Gets or sets the maximal initial rotation in radians.
  15009. */
  15010. maxInitialRotation: number;
  15011. /**
  15012. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15013. */
  15014. minAngularSpeed: number;
  15015. /**
  15016. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15017. */
  15018. maxAngularSpeed: number;
  15019. /**
  15020. * The texture used to render each particle. (this can be a spritesheet)
  15021. */
  15022. particleTexture: Nullable<BaseTexture>;
  15023. /**
  15024. * The layer mask we are rendering the particles through.
  15025. */
  15026. layerMask: number;
  15027. /**
  15028. * This can help using your own shader to render the particle system.
  15029. * The according effect will be created
  15030. */
  15031. customShader: any;
  15032. /**
  15033. * By default particle system starts as soon as they are created. This prevents the
  15034. * automatic start to happen and let you decide when to start emitting particles.
  15035. */
  15036. preventAutoStart: boolean;
  15037. private _noiseTexture;
  15038. /**
  15039. * Gets or sets a texture used to add random noise to particle positions
  15040. */
  15041. get noiseTexture(): Nullable<ProceduralTexture>;
  15042. set noiseTexture(value: Nullable<ProceduralTexture>);
  15043. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15044. noiseStrength: Vector3;
  15045. /**
  15046. * Callback triggered when the particle animation is ending.
  15047. */
  15048. onAnimationEnd: Nullable<() => void>;
  15049. /**
  15050. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15051. */
  15052. blendMode: number;
  15053. /**
  15054. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15055. * to override the particles.
  15056. */
  15057. forceDepthWrite: boolean;
  15058. /** 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 */
  15059. preWarmCycles: number;
  15060. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15061. preWarmStepOffset: number;
  15062. /**
  15063. * 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)
  15064. */
  15065. spriteCellChangeSpeed: number;
  15066. /**
  15067. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15068. */
  15069. startSpriteCellID: number;
  15070. /**
  15071. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15072. */
  15073. endSpriteCellID: number;
  15074. /**
  15075. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15076. */
  15077. spriteCellWidth: number;
  15078. /**
  15079. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15080. */
  15081. spriteCellHeight: number;
  15082. /**
  15083. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15084. */
  15085. spriteRandomStartCell: boolean;
  15086. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15087. translationPivot: Vector2;
  15088. /** @hidden */
  15089. protected _isAnimationSheetEnabled: boolean;
  15090. /**
  15091. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15092. */
  15093. beginAnimationOnStart: boolean;
  15094. /**
  15095. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15096. */
  15097. beginAnimationFrom: number;
  15098. /**
  15099. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15100. */
  15101. beginAnimationTo: number;
  15102. /**
  15103. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15104. */
  15105. beginAnimationLoop: boolean;
  15106. /**
  15107. * Gets or sets a world offset applied to all particles
  15108. */
  15109. worldOffset: Vector3;
  15110. /**
  15111. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15112. */
  15113. get isAnimationSheetEnabled(): boolean;
  15114. set isAnimationSheetEnabled(value: boolean);
  15115. /**
  15116. * Get hosting scene
  15117. * @returns the scene
  15118. */
  15119. getScene(): Nullable<Scene>;
  15120. /**
  15121. * You can use gravity if you want to give an orientation to your particles.
  15122. */
  15123. gravity: Vector3;
  15124. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15125. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15126. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15127. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15128. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15129. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15130. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15131. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15132. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15133. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15134. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15135. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15136. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15137. /**
  15138. * Defines the delay in milliseconds before starting the system (0 by default)
  15139. */
  15140. startDelay: number;
  15141. /**
  15142. * Gets the current list of drag gradients.
  15143. * You must use addDragGradient and removeDragGradient to udpate this list
  15144. * @returns the list of drag gradients
  15145. */
  15146. getDragGradients(): Nullable<Array<FactorGradient>>;
  15147. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15148. limitVelocityDamping: number;
  15149. /**
  15150. * Gets the current list of limit velocity gradients.
  15151. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15152. * @returns the list of limit velocity gradients
  15153. */
  15154. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15155. /**
  15156. * Gets the current list of color gradients.
  15157. * You must use addColorGradient and removeColorGradient to udpate this list
  15158. * @returns the list of color gradients
  15159. */
  15160. getColorGradients(): Nullable<Array<ColorGradient>>;
  15161. /**
  15162. * Gets the current list of size gradients.
  15163. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15164. * @returns the list of size gradients
  15165. */
  15166. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15167. /**
  15168. * Gets the current list of color remap gradients.
  15169. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15170. * @returns the list of color remap gradients
  15171. */
  15172. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15173. /**
  15174. * Gets the current list of alpha remap gradients.
  15175. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15176. * @returns the list of alpha remap gradients
  15177. */
  15178. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15179. /**
  15180. * Gets the current list of life time gradients.
  15181. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15182. * @returns the list of life time gradients
  15183. */
  15184. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15185. /**
  15186. * Gets the current list of angular speed gradients.
  15187. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15188. * @returns the list of angular speed gradients
  15189. */
  15190. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15191. /**
  15192. * Gets the current list of velocity gradients.
  15193. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15194. * @returns the list of velocity gradients
  15195. */
  15196. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15197. /**
  15198. * Gets the current list of start size gradients.
  15199. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15200. * @returns the list of start size gradients
  15201. */
  15202. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15203. /**
  15204. * Gets the current list of emit rate gradients.
  15205. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15206. * @returns the list of emit rate gradients
  15207. */
  15208. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15209. /**
  15210. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15211. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15212. */
  15213. get direction1(): Vector3;
  15214. set direction1(value: Vector3);
  15215. /**
  15216. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15217. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15218. */
  15219. get direction2(): Vector3;
  15220. set direction2(value: Vector3);
  15221. /**
  15222. * 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.
  15223. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15224. */
  15225. get minEmitBox(): Vector3;
  15226. set minEmitBox(value: Vector3);
  15227. /**
  15228. * 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.
  15229. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15230. */
  15231. get maxEmitBox(): Vector3;
  15232. set maxEmitBox(value: Vector3);
  15233. /**
  15234. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15235. */
  15236. color1: Color4;
  15237. /**
  15238. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15239. */
  15240. color2: Color4;
  15241. /**
  15242. * Color the particle will have at the end of its lifetime
  15243. */
  15244. colorDead: Color4;
  15245. /**
  15246. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15247. */
  15248. textureMask: Color4;
  15249. /**
  15250. * The particle emitter type defines the emitter used by the particle system.
  15251. * It can be for example box, sphere, or cone...
  15252. */
  15253. particleEmitterType: IParticleEmitterType;
  15254. /** @hidden */
  15255. _isSubEmitter: boolean;
  15256. /**
  15257. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15258. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15259. */
  15260. billboardMode: number;
  15261. protected _isBillboardBased: boolean;
  15262. /**
  15263. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15264. */
  15265. get isBillboardBased(): boolean;
  15266. set isBillboardBased(value: boolean);
  15267. /**
  15268. * The scene the particle system belongs to.
  15269. */
  15270. protected _scene: Nullable<Scene>;
  15271. /**
  15272. * The engine the particle system belongs to.
  15273. */
  15274. protected _engine: ThinEngine;
  15275. /**
  15276. * Local cache of defines for image processing.
  15277. */
  15278. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15279. /**
  15280. * Default configuration related to image processing available in the standard Material.
  15281. */
  15282. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15283. /**
  15284. * Gets the image processing configuration used either in this material.
  15285. */
  15286. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15287. /**
  15288. * Sets the Default image processing configuration used either in the this material.
  15289. *
  15290. * If sets to null, the scene one is in use.
  15291. */
  15292. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15293. /**
  15294. * Attaches a new image processing configuration to the Standard Material.
  15295. * @param configuration
  15296. */
  15297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15298. /** @hidden */
  15299. protected _reset(): void;
  15300. /** @hidden */
  15301. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15302. /**
  15303. * Instantiates a particle system.
  15304. * 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.
  15305. * @param name The name of the particle system
  15306. */
  15307. constructor(name: string);
  15308. /**
  15309. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15310. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15311. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15312. * @returns the emitter
  15313. */
  15314. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15315. /**
  15316. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15317. * @param radius The radius of the hemisphere to emit from
  15318. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15319. * @returns the emitter
  15320. */
  15321. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15322. /**
  15323. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15324. * @param radius The radius of the sphere to emit from
  15325. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15326. * @returns the emitter
  15327. */
  15328. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15329. /**
  15330. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15331. * @param radius The radius of the sphere to emit from
  15332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15334. * @returns the emitter
  15335. */
  15336. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15337. /**
  15338. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15339. * @param radius The radius of the emission cylinder
  15340. * @param height The height of the emission cylinder
  15341. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15342. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15343. * @returns the emitter
  15344. */
  15345. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15346. /**
  15347. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15348. * @param radius The radius of the cylinder to emit from
  15349. * @param height The height of the emission cylinder
  15350. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15351. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15352. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15353. * @returns the emitter
  15354. */
  15355. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15356. /**
  15357. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15358. * @param radius The radius of the cone to emit from
  15359. * @param angle The base angle of the cone
  15360. * @returns the emitter
  15361. */
  15362. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15363. /**
  15364. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15365. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15366. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15367. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15368. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15369. * @returns the emitter
  15370. */
  15371. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15372. }
  15373. }
  15374. declare module BABYLON {
  15375. /**
  15376. * Type of sub emitter
  15377. */
  15378. export enum SubEmitterType {
  15379. /**
  15380. * Attached to the particle over it's lifetime
  15381. */
  15382. ATTACHED = 0,
  15383. /**
  15384. * Created when the particle dies
  15385. */
  15386. END = 1
  15387. }
  15388. /**
  15389. * Sub emitter class used to emit particles from an existing particle
  15390. */
  15391. export class SubEmitter {
  15392. /**
  15393. * the particle system to be used by the sub emitter
  15394. */
  15395. particleSystem: ParticleSystem;
  15396. /**
  15397. * Type of the submitter (Default: END)
  15398. */
  15399. type: SubEmitterType;
  15400. /**
  15401. * 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)
  15402. * Note: This only is supported when using an emitter of type Mesh
  15403. */
  15404. inheritDirection: boolean;
  15405. /**
  15406. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15407. */
  15408. inheritedVelocityAmount: number;
  15409. /**
  15410. * Creates a sub emitter
  15411. * @param particleSystem the particle system to be used by the sub emitter
  15412. */
  15413. constructor(
  15414. /**
  15415. * the particle system to be used by the sub emitter
  15416. */
  15417. particleSystem: ParticleSystem);
  15418. /**
  15419. * Clones the sub emitter
  15420. * @returns the cloned sub emitter
  15421. */
  15422. clone(): SubEmitter;
  15423. /**
  15424. * Serialize current object to a JSON object
  15425. * @returns the serialized object
  15426. */
  15427. serialize(): any;
  15428. /** @hidden */
  15429. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15430. /**
  15431. * Creates a new SubEmitter from a serialized JSON version
  15432. * @param serializationObject defines the JSON object to read from
  15433. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15434. * @param rootUrl defines the rootUrl for data loading
  15435. * @returns a new SubEmitter
  15436. */
  15437. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15438. /** Release associated resources */
  15439. dispose(): void;
  15440. }
  15441. }
  15442. declare module BABYLON {
  15443. /** @hidden */
  15444. export var clipPlaneFragmentDeclaration: {
  15445. name: string;
  15446. shader: string;
  15447. };
  15448. }
  15449. declare module BABYLON {
  15450. /** @hidden */
  15451. export var imageProcessingDeclaration: {
  15452. name: string;
  15453. shader: string;
  15454. };
  15455. }
  15456. declare module BABYLON {
  15457. /** @hidden */
  15458. export var imageProcessingFunctions: {
  15459. name: string;
  15460. shader: string;
  15461. };
  15462. }
  15463. declare module BABYLON {
  15464. /** @hidden */
  15465. export var clipPlaneFragment: {
  15466. name: string;
  15467. shader: string;
  15468. };
  15469. }
  15470. declare module BABYLON {
  15471. /** @hidden */
  15472. export var particlesPixelShader: {
  15473. name: string;
  15474. shader: string;
  15475. };
  15476. }
  15477. declare module BABYLON {
  15478. /** @hidden */
  15479. export var clipPlaneVertexDeclaration: {
  15480. name: string;
  15481. shader: string;
  15482. };
  15483. }
  15484. declare module BABYLON {
  15485. /** @hidden */
  15486. export var clipPlaneVertex: {
  15487. name: string;
  15488. shader: string;
  15489. };
  15490. }
  15491. declare module BABYLON {
  15492. /** @hidden */
  15493. export var particlesVertexShader: {
  15494. name: string;
  15495. shader: string;
  15496. };
  15497. }
  15498. declare module BABYLON {
  15499. /**
  15500. * Interface used to define entities containing multiple clip planes
  15501. */
  15502. export interface IClipPlanesHolder {
  15503. /**
  15504. * Gets or sets the active clipplane 1
  15505. */
  15506. clipPlane: Nullable<Plane>;
  15507. /**
  15508. * Gets or sets the active clipplane 2
  15509. */
  15510. clipPlane2: Nullable<Plane>;
  15511. /**
  15512. * Gets or sets the active clipplane 3
  15513. */
  15514. clipPlane3: Nullable<Plane>;
  15515. /**
  15516. * Gets or sets the active clipplane 4
  15517. */
  15518. clipPlane4: Nullable<Plane>;
  15519. /**
  15520. * Gets or sets the active clipplane 5
  15521. */
  15522. clipPlane5: Nullable<Plane>;
  15523. /**
  15524. * Gets or sets the active clipplane 6
  15525. */
  15526. clipPlane6: Nullable<Plane>;
  15527. }
  15528. }
  15529. declare module BABYLON {
  15530. /**
  15531. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15532. *
  15533. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15534. *
  15535. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15536. */
  15537. export class ThinMaterialHelper {
  15538. /**
  15539. * Binds the clip plane information from the holder to the effect.
  15540. * @param effect The effect we are binding the data to
  15541. * @param holder The entity containing the clip plane information
  15542. */
  15543. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15544. }
  15545. }
  15546. declare module BABYLON {
  15547. interface ThinEngine {
  15548. /**
  15549. * Sets alpha constants used by some alpha blending modes
  15550. * @param r defines the red component
  15551. * @param g defines the green component
  15552. * @param b defines the blue component
  15553. * @param a defines the alpha component
  15554. */
  15555. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15556. /**
  15557. * Sets the current alpha mode
  15558. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15559. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15560. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15561. */
  15562. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15563. /**
  15564. * Gets the current alpha mode
  15565. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15566. * @returns the current alpha mode
  15567. */
  15568. getAlphaMode(): number;
  15569. /**
  15570. * Sets the current alpha equation
  15571. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15572. */
  15573. setAlphaEquation(equation: number): void;
  15574. /**
  15575. * Gets the current alpha equation.
  15576. * @returns the current alpha equation
  15577. */
  15578. getAlphaEquation(): number;
  15579. }
  15580. }
  15581. declare module BABYLON {
  15582. /**
  15583. * This represents a particle system in Babylon.
  15584. * 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.
  15585. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15586. * @example https://doc.babylonjs.com/babylon101/particles
  15587. */
  15588. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15589. /**
  15590. * Billboard mode will only apply to Y axis
  15591. */
  15592. static readonly BILLBOARDMODE_Y: number;
  15593. /**
  15594. * Billboard mode will apply to all axes
  15595. */
  15596. static readonly BILLBOARDMODE_ALL: number;
  15597. /**
  15598. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15599. */
  15600. static readonly BILLBOARDMODE_STRETCHED: number;
  15601. /**
  15602. * This function can be defined to provide custom update for active particles.
  15603. * This function will be called instead of regular update (age, position, color, etc.).
  15604. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15605. */
  15606. updateFunction: (particles: Particle[]) => void;
  15607. private _emitterWorldMatrix;
  15608. /**
  15609. * This function can be defined to specify initial direction for every new particle.
  15610. * It by default use the emitterType defined function
  15611. */
  15612. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15613. /**
  15614. * This function can be defined to specify initial position for every new particle.
  15615. * It by default use the emitterType defined function
  15616. */
  15617. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15618. /**
  15619. * @hidden
  15620. */
  15621. _inheritedVelocityOffset: Vector3;
  15622. /**
  15623. * An event triggered when the system is disposed
  15624. */
  15625. onDisposeObservable: Observable<IParticleSystem>;
  15626. /**
  15627. * An event triggered when the system is stopped
  15628. */
  15629. onStoppedObservable: Observable<IParticleSystem>;
  15630. private _onDisposeObserver;
  15631. /**
  15632. * Sets a callback that will be triggered when the system is disposed
  15633. */
  15634. set onDispose(callback: () => void);
  15635. private _particles;
  15636. private _epsilon;
  15637. private _capacity;
  15638. private _stockParticles;
  15639. private _newPartsExcess;
  15640. private _vertexData;
  15641. private _vertexBuffer;
  15642. private _vertexBuffers;
  15643. private _spriteBuffer;
  15644. private _indexBuffer;
  15645. private _effect;
  15646. private _customEffect;
  15647. private _cachedDefines;
  15648. private _scaledColorStep;
  15649. private _colorDiff;
  15650. private _scaledDirection;
  15651. private _scaledGravity;
  15652. private _currentRenderId;
  15653. private _alive;
  15654. private _useInstancing;
  15655. private _vertexArrayObject;
  15656. private _started;
  15657. private _stopped;
  15658. private _actualFrame;
  15659. private _scaledUpdateSpeed;
  15660. private _vertexBufferSize;
  15661. /** @hidden */
  15662. _currentEmitRateGradient: Nullable<FactorGradient>;
  15663. /** @hidden */
  15664. _currentEmitRate1: number;
  15665. /** @hidden */
  15666. _currentEmitRate2: number;
  15667. /** @hidden */
  15668. _currentStartSizeGradient: Nullable<FactorGradient>;
  15669. /** @hidden */
  15670. _currentStartSize1: number;
  15671. /** @hidden */
  15672. _currentStartSize2: number;
  15673. private readonly _rawTextureWidth;
  15674. private _rampGradientsTexture;
  15675. private _useRampGradients;
  15676. /** Gets or sets a matrix to use to compute projection */
  15677. defaultProjectionMatrix: Matrix;
  15678. /** Gets or sets a matrix to use to compute view */
  15679. defaultViewMatrix: Matrix;
  15680. /** Gets or sets a boolean indicating that ramp gradients must be used
  15681. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15682. */
  15683. get useRampGradients(): boolean;
  15684. set useRampGradients(value: boolean);
  15685. /**
  15686. * 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.
  15687. * 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: [])
  15688. */
  15689. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15690. private _subEmitters;
  15691. /**
  15692. * @hidden
  15693. * If the particle systems emitter should be disposed when the particle system is disposed
  15694. */
  15695. _disposeEmitterOnDispose: boolean;
  15696. /**
  15697. * The current active Sub-systems, this property is used by the root particle system only.
  15698. */
  15699. activeSubSystems: Array<ParticleSystem>;
  15700. /**
  15701. * Specifies if the particles are updated in emitter local space or world space
  15702. */
  15703. isLocal: boolean;
  15704. private _rootParticleSystem;
  15705. /**
  15706. * Gets the current list of active particles
  15707. */
  15708. get particles(): Particle[];
  15709. /**
  15710. * Gets the number of particles active at the same time.
  15711. * @returns The number of active particles.
  15712. */
  15713. getActiveCount(): number;
  15714. /**
  15715. * Returns the string "ParticleSystem"
  15716. * @returns a string containing the class name
  15717. */
  15718. getClassName(): string;
  15719. /**
  15720. * Gets a boolean indicating that the system is stopping
  15721. * @returns true if the system is currently stopping
  15722. */
  15723. isStopping(): boolean;
  15724. /**
  15725. * Gets the custom effect used to render the particles
  15726. * @param blendMode Blend mode for which the effect should be retrieved
  15727. * @returns The effect
  15728. */
  15729. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15730. /**
  15731. * Sets the custom effect used to render the particles
  15732. * @param effect The effect to set
  15733. * @param blendMode Blend mode for which the effect should be set
  15734. */
  15735. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15736. /** @hidden */
  15737. private _onBeforeDrawParticlesObservable;
  15738. /**
  15739. * Observable that will be called just before the particles are drawn
  15740. */
  15741. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15742. /**
  15743. * Gets the name of the particle vertex shader
  15744. */
  15745. get vertexShaderName(): string;
  15746. /**
  15747. * Instantiates a particle system.
  15748. * 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.
  15749. * @param name The name of the particle system
  15750. * @param capacity The max number of particles alive at the same time
  15751. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15752. * @param customEffect a custom effect used to change the way particles are rendered by default
  15753. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15754. * @param epsilon Offset used to render the particles
  15755. */
  15756. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15757. private _addFactorGradient;
  15758. private _removeFactorGradient;
  15759. /**
  15760. * Adds a new life time gradient
  15761. * @param gradient defines the gradient to use (between 0 and 1)
  15762. * @param factor defines the life time factor to affect to the specified gradient
  15763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15764. * @returns the current particle system
  15765. */
  15766. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15767. /**
  15768. * Remove a specific life time gradient
  15769. * @param gradient defines the gradient to remove
  15770. * @returns the current particle system
  15771. */
  15772. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15773. /**
  15774. * Adds a new size gradient
  15775. * @param gradient defines the gradient to use (between 0 and 1)
  15776. * @param factor defines the size factor to affect to the specified gradient
  15777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15778. * @returns the current particle system
  15779. */
  15780. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15781. /**
  15782. * Remove a specific size gradient
  15783. * @param gradient defines the gradient to remove
  15784. * @returns the current particle system
  15785. */
  15786. removeSizeGradient(gradient: number): IParticleSystem;
  15787. /**
  15788. * Adds a new color remap gradient
  15789. * @param gradient defines the gradient to use (between 0 and 1)
  15790. * @param min defines the color remap minimal range
  15791. * @param max defines the color remap maximal range
  15792. * @returns the current particle system
  15793. */
  15794. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15795. /**
  15796. * Remove a specific color remap gradient
  15797. * @param gradient defines the gradient to remove
  15798. * @returns the current particle system
  15799. */
  15800. removeColorRemapGradient(gradient: number): IParticleSystem;
  15801. /**
  15802. * Adds a new alpha remap gradient
  15803. * @param gradient defines the gradient to use (between 0 and 1)
  15804. * @param min defines the alpha remap minimal range
  15805. * @param max defines the alpha remap maximal range
  15806. * @returns the current particle system
  15807. */
  15808. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15809. /**
  15810. * Remove a specific alpha remap gradient
  15811. * @param gradient defines the gradient to remove
  15812. * @returns the current particle system
  15813. */
  15814. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15815. /**
  15816. * Adds a new angular speed gradient
  15817. * @param gradient defines the gradient to use (between 0 and 1)
  15818. * @param factor defines the angular speed to affect to the specified gradient
  15819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15820. * @returns the current particle system
  15821. */
  15822. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15823. /**
  15824. * Remove a specific angular speed gradient
  15825. * @param gradient defines the gradient to remove
  15826. * @returns the current particle system
  15827. */
  15828. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15829. /**
  15830. * Adds a new velocity gradient
  15831. * @param gradient defines the gradient to use (between 0 and 1)
  15832. * @param factor defines the velocity to affect to the specified gradient
  15833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15834. * @returns the current particle system
  15835. */
  15836. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15837. /**
  15838. * Remove a specific velocity gradient
  15839. * @param gradient defines the gradient to remove
  15840. * @returns the current particle system
  15841. */
  15842. removeVelocityGradient(gradient: number): IParticleSystem;
  15843. /**
  15844. * Adds a new limit velocity gradient
  15845. * @param gradient defines the gradient to use (between 0 and 1)
  15846. * @param factor defines the limit velocity value to affect to the specified gradient
  15847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15848. * @returns the current particle system
  15849. */
  15850. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15851. /**
  15852. * Remove a specific limit velocity gradient
  15853. * @param gradient defines the gradient to remove
  15854. * @returns the current particle system
  15855. */
  15856. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15857. /**
  15858. * Adds a new drag gradient
  15859. * @param gradient defines the gradient to use (between 0 and 1)
  15860. * @param factor defines the drag value to affect to the specified gradient
  15861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15862. * @returns the current particle system
  15863. */
  15864. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15865. /**
  15866. * Remove a specific drag gradient
  15867. * @param gradient defines the gradient to remove
  15868. * @returns the current particle system
  15869. */
  15870. removeDragGradient(gradient: number): IParticleSystem;
  15871. /**
  15872. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15873. * @param gradient defines the gradient to use (between 0 and 1)
  15874. * @param factor defines the emit rate value to affect to the specified gradient
  15875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15876. * @returns the current particle system
  15877. */
  15878. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15879. /**
  15880. * Remove a specific emit rate gradient
  15881. * @param gradient defines the gradient to remove
  15882. * @returns the current particle system
  15883. */
  15884. removeEmitRateGradient(gradient: number): IParticleSystem;
  15885. /**
  15886. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15887. * @param gradient defines the gradient to use (between 0 and 1)
  15888. * @param factor defines the start size value to affect to the specified gradient
  15889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15890. * @returns the current particle system
  15891. */
  15892. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15893. /**
  15894. * Remove a specific start size gradient
  15895. * @param gradient defines the gradient to remove
  15896. * @returns the current particle system
  15897. */
  15898. removeStartSizeGradient(gradient: number): IParticleSystem;
  15899. private _createRampGradientTexture;
  15900. /**
  15901. * Gets the current list of ramp gradients.
  15902. * You must use addRampGradient and removeRampGradient to udpate this list
  15903. * @returns the list of ramp gradients
  15904. */
  15905. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15906. /** Force the system to rebuild all gradients that need to be resync */
  15907. forceRefreshGradients(): void;
  15908. private _syncRampGradientTexture;
  15909. /**
  15910. * Adds a new ramp gradient used to remap particle colors
  15911. * @param gradient defines the gradient to use (between 0 and 1)
  15912. * @param color defines the color to affect to the specified gradient
  15913. * @returns the current particle system
  15914. */
  15915. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15916. /**
  15917. * Remove a specific ramp gradient
  15918. * @param gradient defines the gradient to remove
  15919. * @returns the current particle system
  15920. */
  15921. removeRampGradient(gradient: number): ParticleSystem;
  15922. /**
  15923. * Adds a new color gradient
  15924. * @param gradient defines the gradient to use (between 0 and 1)
  15925. * @param color1 defines the color to affect to the specified gradient
  15926. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15927. * @returns this particle system
  15928. */
  15929. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15930. /**
  15931. * Remove a specific color gradient
  15932. * @param gradient defines the gradient to remove
  15933. * @returns this particle system
  15934. */
  15935. removeColorGradient(gradient: number): IParticleSystem;
  15936. private _fetchR;
  15937. protected _reset(): void;
  15938. private _resetEffect;
  15939. private _createVertexBuffers;
  15940. private _createIndexBuffer;
  15941. /**
  15942. * Gets the maximum number of particles active at the same time.
  15943. * @returns The max number of active particles.
  15944. */
  15945. getCapacity(): number;
  15946. /**
  15947. * Gets whether there are still active particles in the system.
  15948. * @returns True if it is alive, otherwise false.
  15949. */
  15950. isAlive(): boolean;
  15951. /**
  15952. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15953. * @returns True if it has been started, otherwise false.
  15954. */
  15955. isStarted(): boolean;
  15956. private _prepareSubEmitterInternalArray;
  15957. /**
  15958. * Starts the particle system and begins to emit
  15959. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15960. */
  15961. start(delay?: number): void;
  15962. /**
  15963. * Stops the particle system.
  15964. * @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.
  15965. */
  15966. stop(stopSubEmitters?: boolean): void;
  15967. /**
  15968. * Remove all active particles
  15969. */
  15970. reset(): void;
  15971. /**
  15972. * @hidden (for internal use only)
  15973. */
  15974. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15975. /**
  15976. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15977. * Its lifetime will start back at 0.
  15978. */
  15979. recycleParticle: (particle: Particle) => void;
  15980. private _stopSubEmitters;
  15981. private _createParticle;
  15982. private _removeFromRoot;
  15983. private _emitFromParticle;
  15984. private _update;
  15985. /** @hidden */
  15986. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15987. /** @hidden */
  15988. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15989. /**
  15990. * Fill the defines array according to the current settings of the particle system
  15991. * @param defines Array to be updated
  15992. * @param blendMode blend mode to take into account when updating the array
  15993. */
  15994. fillDefines(defines: Array<string>, blendMode: number): void;
  15995. /**
  15996. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15997. * @param uniforms Uniforms array to fill
  15998. * @param attributes Attributes array to fill
  15999. * @param samplers Samplers array to fill
  16000. */
  16001. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16002. /** @hidden */
  16003. private _getEffect;
  16004. /**
  16005. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16006. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16007. */
  16008. animate(preWarmOnly?: boolean): void;
  16009. private _appendParticleVertices;
  16010. /**
  16011. * Rebuilds the particle system.
  16012. */
  16013. rebuild(): void;
  16014. /**
  16015. * Is this system ready to be used/rendered
  16016. * @return true if the system is ready
  16017. */
  16018. isReady(): boolean;
  16019. private _render;
  16020. /**
  16021. * Renders the particle system in its current state.
  16022. * @returns the current number of particles
  16023. */
  16024. render(): number;
  16025. /**
  16026. * Disposes the particle system and free the associated resources
  16027. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16028. */
  16029. dispose(disposeTexture?: boolean): void;
  16030. /**
  16031. * Clones the particle system.
  16032. * @param name The name of the cloned object
  16033. * @param newEmitter The new emitter to use
  16034. * @returns the cloned particle system
  16035. */
  16036. clone(name: string, newEmitter: any): ParticleSystem;
  16037. /**
  16038. * Serializes the particle system to a JSON object
  16039. * @param serializeTexture defines if the texture must be serialized as well
  16040. * @returns the JSON object
  16041. */
  16042. serialize(serializeTexture?: boolean): any;
  16043. /** @hidden */
  16044. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16045. /** @hidden */
  16046. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16047. /**
  16048. * Parses a JSON object to create a particle system.
  16049. * @param parsedParticleSystem The JSON object to parse
  16050. * @param sceneOrEngine The scene or the engine to create the particle system in
  16051. * @param rootUrl The root url to use to load external dependencies like texture
  16052. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16053. * @returns the Parsed particle system
  16054. */
  16055. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16056. }
  16057. }
  16058. declare module BABYLON {
  16059. /**
  16060. * A particle represents one of the element emitted by a particle system.
  16061. * This is mainly define by its coordinates, direction, velocity and age.
  16062. */
  16063. export class Particle {
  16064. /**
  16065. * The particle system the particle belongs to.
  16066. */
  16067. particleSystem: ParticleSystem;
  16068. private static _Count;
  16069. /**
  16070. * Unique ID of the particle
  16071. */
  16072. id: number;
  16073. /**
  16074. * The world position of the particle in the scene.
  16075. */
  16076. position: Vector3;
  16077. /**
  16078. * The world direction of the particle in the scene.
  16079. */
  16080. direction: Vector3;
  16081. /**
  16082. * The color of the particle.
  16083. */
  16084. color: Color4;
  16085. /**
  16086. * The color change of the particle per step.
  16087. */
  16088. colorStep: Color4;
  16089. /**
  16090. * Defines how long will the life of the particle be.
  16091. */
  16092. lifeTime: number;
  16093. /**
  16094. * The current age of the particle.
  16095. */
  16096. age: number;
  16097. /**
  16098. * The current size of the particle.
  16099. */
  16100. size: number;
  16101. /**
  16102. * The current scale of the particle.
  16103. */
  16104. scale: Vector2;
  16105. /**
  16106. * The current angle of the particle.
  16107. */
  16108. angle: number;
  16109. /**
  16110. * Defines how fast is the angle changing.
  16111. */
  16112. angularSpeed: number;
  16113. /**
  16114. * Defines the cell index used by the particle to be rendered from a sprite.
  16115. */
  16116. cellIndex: number;
  16117. /**
  16118. * The information required to support color remapping
  16119. */
  16120. remapData: Vector4;
  16121. /** @hidden */
  16122. _randomCellOffset?: number;
  16123. /** @hidden */
  16124. _initialDirection: Nullable<Vector3>;
  16125. /** @hidden */
  16126. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16127. /** @hidden */
  16128. _initialStartSpriteCellID: number;
  16129. /** @hidden */
  16130. _initialEndSpriteCellID: number;
  16131. /** @hidden */
  16132. _currentColorGradient: Nullable<ColorGradient>;
  16133. /** @hidden */
  16134. _currentColor1: Color4;
  16135. /** @hidden */
  16136. _currentColor2: Color4;
  16137. /** @hidden */
  16138. _currentSizeGradient: Nullable<FactorGradient>;
  16139. /** @hidden */
  16140. _currentSize1: number;
  16141. /** @hidden */
  16142. _currentSize2: number;
  16143. /** @hidden */
  16144. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16145. /** @hidden */
  16146. _currentAngularSpeed1: number;
  16147. /** @hidden */
  16148. _currentAngularSpeed2: number;
  16149. /** @hidden */
  16150. _currentVelocityGradient: Nullable<FactorGradient>;
  16151. /** @hidden */
  16152. _currentVelocity1: number;
  16153. /** @hidden */
  16154. _currentVelocity2: number;
  16155. /** @hidden */
  16156. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16157. /** @hidden */
  16158. _currentLimitVelocity1: number;
  16159. /** @hidden */
  16160. _currentLimitVelocity2: number;
  16161. /** @hidden */
  16162. _currentDragGradient: Nullable<FactorGradient>;
  16163. /** @hidden */
  16164. _currentDrag1: number;
  16165. /** @hidden */
  16166. _currentDrag2: number;
  16167. /** @hidden */
  16168. _randomNoiseCoordinates1: Vector3;
  16169. /** @hidden */
  16170. _randomNoiseCoordinates2: Vector3;
  16171. /** @hidden */
  16172. _localPosition?: Vector3;
  16173. /**
  16174. * Creates a new instance Particle
  16175. * @param particleSystem the particle system the particle belongs to
  16176. */
  16177. constructor(
  16178. /**
  16179. * The particle system the particle belongs to.
  16180. */
  16181. particleSystem: ParticleSystem);
  16182. private updateCellInfoFromSystem;
  16183. /**
  16184. * Defines how the sprite cell index is updated for the particle
  16185. */
  16186. updateCellIndex(): void;
  16187. /** @hidden */
  16188. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16189. /** @hidden */
  16190. _inheritParticleInfoToSubEmitters(): void;
  16191. /** @hidden */
  16192. _reset(): void;
  16193. /**
  16194. * Copy the properties of particle to another one.
  16195. * @param other the particle to copy the information to.
  16196. */
  16197. copyTo(other: Particle): void;
  16198. }
  16199. }
  16200. declare module BABYLON {
  16201. /**
  16202. * Particle emitter represents a volume emitting particles.
  16203. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16204. */
  16205. export interface IParticleEmitterType {
  16206. /**
  16207. * Called by the particle System when the direction is computed for the created particle.
  16208. * @param worldMatrix is the world matrix of the particle system
  16209. * @param directionToUpdate is the direction vector to update with the result
  16210. * @param particle is the particle we are computed the direction for
  16211. * @param isLocal defines if the direction should be set in local space
  16212. */
  16213. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16214. /**
  16215. * Called by the particle System when the position is computed for the created particle.
  16216. * @param worldMatrix is the world matrix of the particle system
  16217. * @param positionToUpdate is the position vector to update with the result
  16218. * @param particle is the particle we are computed the position for
  16219. * @param isLocal defines if the position should be set in local space
  16220. */
  16221. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16222. /**
  16223. * Clones the current emitter and returns a copy of it
  16224. * @returns the new emitter
  16225. */
  16226. clone(): IParticleEmitterType;
  16227. /**
  16228. * Called by the GPUParticleSystem to setup the update shader
  16229. * @param effect defines the update shader
  16230. */
  16231. applyToShader(effect: Effect): void;
  16232. /**
  16233. * Returns a string to use to update the GPU particles update shader
  16234. * @returns the effect defines string
  16235. */
  16236. getEffectDefines(): string;
  16237. /**
  16238. * Returns a string representing the class name
  16239. * @returns a string containing the class name
  16240. */
  16241. getClassName(): string;
  16242. /**
  16243. * Serializes the particle system to a JSON object.
  16244. * @returns the JSON object
  16245. */
  16246. serialize(): any;
  16247. /**
  16248. * Parse properties from a JSON object
  16249. * @param serializationObject defines the JSON object
  16250. * @param scene defines the hosting scene
  16251. */
  16252. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16253. }
  16254. }
  16255. declare module BABYLON {
  16256. /**
  16257. * Particle emitter emitting particles from the inside of a box.
  16258. * It emits the particles randomly between 2 given directions.
  16259. */
  16260. export class BoxParticleEmitter implements IParticleEmitterType {
  16261. /**
  16262. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16263. */
  16264. direction1: Vector3;
  16265. /**
  16266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16267. */
  16268. direction2: Vector3;
  16269. /**
  16270. * 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.
  16271. */
  16272. minEmitBox: Vector3;
  16273. /**
  16274. * 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.
  16275. */
  16276. maxEmitBox: Vector3;
  16277. /**
  16278. * Creates a new instance BoxParticleEmitter
  16279. */
  16280. constructor();
  16281. /**
  16282. * Called by the particle System when the direction is computed for the created particle.
  16283. * @param worldMatrix is the world matrix of the particle system
  16284. * @param directionToUpdate is the direction vector to update with the result
  16285. * @param particle is the particle we are computed the direction for
  16286. * @param isLocal defines if the direction should be set in local space
  16287. */
  16288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16289. /**
  16290. * Called by the particle System when the position is computed for the created particle.
  16291. * @param worldMatrix is the world matrix of the particle system
  16292. * @param positionToUpdate is the position vector to update with the result
  16293. * @param particle is the particle we are computed the position for
  16294. * @param isLocal defines if the position should be set in local space
  16295. */
  16296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16297. /**
  16298. * Clones the current emitter and returns a copy of it
  16299. * @returns the new emitter
  16300. */
  16301. clone(): BoxParticleEmitter;
  16302. /**
  16303. * Called by the GPUParticleSystem to setup the update shader
  16304. * @param effect defines the update shader
  16305. */
  16306. applyToShader(effect: Effect): void;
  16307. /**
  16308. * Returns a string to use to update the GPU particles update shader
  16309. * @returns a string containng the defines string
  16310. */
  16311. getEffectDefines(): string;
  16312. /**
  16313. * Returns the string "BoxParticleEmitter"
  16314. * @returns a string containing the class name
  16315. */
  16316. getClassName(): string;
  16317. /**
  16318. * Serializes the particle system to a JSON object.
  16319. * @returns the JSON object
  16320. */
  16321. serialize(): any;
  16322. /**
  16323. * Parse properties from a JSON object
  16324. * @param serializationObject defines the JSON object
  16325. */
  16326. parse(serializationObject: any): void;
  16327. }
  16328. }
  16329. declare module BABYLON {
  16330. /**
  16331. * Particle emitter emitting particles from the inside of a cone.
  16332. * It emits the particles alongside the cone volume from the base to the particle.
  16333. * The emission direction might be randomized.
  16334. */
  16335. export class ConeParticleEmitter implements IParticleEmitterType {
  16336. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16337. directionRandomizer: number;
  16338. private _radius;
  16339. private _angle;
  16340. private _height;
  16341. /**
  16342. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16343. */
  16344. radiusRange: number;
  16345. /**
  16346. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16347. */
  16348. heightRange: number;
  16349. /**
  16350. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16351. */
  16352. emitFromSpawnPointOnly: boolean;
  16353. /**
  16354. * Gets or sets the radius of the emission cone
  16355. */
  16356. get radius(): number;
  16357. set radius(value: number);
  16358. /**
  16359. * Gets or sets the angle of the emission cone
  16360. */
  16361. get angle(): number;
  16362. set angle(value: number);
  16363. private _buildHeight;
  16364. /**
  16365. * Creates a new instance ConeParticleEmitter
  16366. * @param radius the radius of the emission cone (1 by default)
  16367. * @param angle the cone base angle (PI by default)
  16368. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16369. */
  16370. constructor(radius?: number, angle?: number,
  16371. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16372. directionRandomizer?: number);
  16373. /**
  16374. * Called by the particle System when the direction is computed for the created particle.
  16375. * @param worldMatrix is the world matrix of the particle system
  16376. * @param directionToUpdate is the direction vector to update with the result
  16377. * @param particle is the particle we are computed the direction for
  16378. * @param isLocal defines if the direction should be set in local space
  16379. */
  16380. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16381. /**
  16382. * Called by the particle System when the position is computed for the created particle.
  16383. * @param worldMatrix is the world matrix of the particle system
  16384. * @param positionToUpdate is the position vector to update with the result
  16385. * @param particle is the particle we are computed the position for
  16386. * @param isLocal defines if the position should be set in local space
  16387. */
  16388. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16389. /**
  16390. * Clones the current emitter and returns a copy of it
  16391. * @returns the new emitter
  16392. */
  16393. clone(): ConeParticleEmitter;
  16394. /**
  16395. * Called by the GPUParticleSystem to setup the update shader
  16396. * @param effect defines the update shader
  16397. */
  16398. applyToShader(effect: Effect): void;
  16399. /**
  16400. * Returns a string to use to update the GPU particles update shader
  16401. * @returns a string containng the defines string
  16402. */
  16403. getEffectDefines(): string;
  16404. /**
  16405. * Returns the string "ConeParticleEmitter"
  16406. * @returns a string containing the class name
  16407. */
  16408. getClassName(): string;
  16409. /**
  16410. * Serializes the particle system to a JSON object.
  16411. * @returns the JSON object
  16412. */
  16413. serialize(): any;
  16414. /**
  16415. * Parse properties from a JSON object
  16416. * @param serializationObject defines the JSON object
  16417. */
  16418. parse(serializationObject: any): void;
  16419. }
  16420. }
  16421. declare module BABYLON {
  16422. /**
  16423. * Particle emitter emitting particles from the inside of a cylinder.
  16424. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16425. */
  16426. export class CylinderParticleEmitter implements IParticleEmitterType {
  16427. /**
  16428. * The radius of the emission cylinder.
  16429. */
  16430. radius: number;
  16431. /**
  16432. * The height of the emission cylinder.
  16433. */
  16434. height: number;
  16435. /**
  16436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16437. */
  16438. radiusRange: number;
  16439. /**
  16440. * How much to randomize the particle direction [0-1].
  16441. */
  16442. directionRandomizer: number;
  16443. /**
  16444. * Creates a new instance CylinderParticleEmitter
  16445. * @param radius the radius of the emission cylinder (1 by default)
  16446. * @param height the height of the emission cylinder (1 by default)
  16447. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16448. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16449. */
  16450. constructor(
  16451. /**
  16452. * The radius of the emission cylinder.
  16453. */
  16454. radius?: number,
  16455. /**
  16456. * The height of the emission cylinder.
  16457. */
  16458. height?: number,
  16459. /**
  16460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16461. */
  16462. radiusRange?: number,
  16463. /**
  16464. * How much to randomize the particle direction [0-1].
  16465. */
  16466. directionRandomizer?: number);
  16467. /**
  16468. * Called by the particle System when the direction is computed for the created particle.
  16469. * @param worldMatrix is the world matrix of the particle system
  16470. * @param directionToUpdate is the direction vector to update with the result
  16471. * @param particle is the particle we are computed the direction for
  16472. * @param isLocal defines if the direction should be set in local space
  16473. */
  16474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16475. /**
  16476. * Called by the particle System when the position is computed for the created particle.
  16477. * @param worldMatrix is the world matrix of the particle system
  16478. * @param positionToUpdate is the position vector to update with the result
  16479. * @param particle is the particle we are computed the position for
  16480. * @param isLocal defines if the position should be set in local space
  16481. */
  16482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16483. /**
  16484. * Clones the current emitter and returns a copy of it
  16485. * @returns the new emitter
  16486. */
  16487. clone(): CylinderParticleEmitter;
  16488. /**
  16489. * Called by the GPUParticleSystem to setup the update shader
  16490. * @param effect defines the update shader
  16491. */
  16492. applyToShader(effect: Effect): void;
  16493. /**
  16494. * Returns a string to use to update the GPU particles update shader
  16495. * @returns a string containng the defines string
  16496. */
  16497. getEffectDefines(): string;
  16498. /**
  16499. * Returns the string "CylinderParticleEmitter"
  16500. * @returns a string containing the class name
  16501. */
  16502. getClassName(): string;
  16503. /**
  16504. * Serializes the particle system to a JSON object.
  16505. * @returns the JSON object
  16506. */
  16507. serialize(): any;
  16508. /**
  16509. * Parse properties from a JSON object
  16510. * @param serializationObject defines the JSON object
  16511. */
  16512. parse(serializationObject: any): void;
  16513. }
  16514. /**
  16515. * Particle emitter emitting particles from the inside of a cylinder.
  16516. * It emits the particles randomly between two vectors.
  16517. */
  16518. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16519. /**
  16520. * The min limit of the emission direction.
  16521. */
  16522. direction1: Vector3;
  16523. /**
  16524. * The max limit of the emission direction.
  16525. */
  16526. direction2: Vector3;
  16527. /**
  16528. * Creates a new instance CylinderDirectedParticleEmitter
  16529. * @param radius the radius of the emission cylinder (1 by default)
  16530. * @param height the height of the emission cylinder (1 by default)
  16531. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16532. * @param direction1 the min limit of the emission direction (up vector by default)
  16533. * @param direction2 the max limit of the emission direction (up vector by default)
  16534. */
  16535. constructor(radius?: number, height?: number, radiusRange?: number,
  16536. /**
  16537. * The min limit of the emission direction.
  16538. */
  16539. direction1?: Vector3,
  16540. /**
  16541. * The max limit of the emission direction.
  16542. */
  16543. direction2?: Vector3);
  16544. /**
  16545. * Called by the particle System when the direction is computed for the created particle.
  16546. * @param worldMatrix is the world matrix of the particle system
  16547. * @param directionToUpdate is the direction vector to update with the result
  16548. * @param particle is the particle we are computed the direction for
  16549. */
  16550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16551. /**
  16552. * Clones the current emitter and returns a copy of it
  16553. * @returns the new emitter
  16554. */
  16555. clone(): CylinderDirectedParticleEmitter;
  16556. /**
  16557. * Called by the GPUParticleSystem to setup the update shader
  16558. * @param effect defines the update shader
  16559. */
  16560. applyToShader(effect: Effect): void;
  16561. /**
  16562. * Returns a string to use to update the GPU particles update shader
  16563. * @returns a string containng the defines string
  16564. */
  16565. getEffectDefines(): string;
  16566. /**
  16567. * Returns the string "CylinderDirectedParticleEmitter"
  16568. * @returns a string containing the class name
  16569. */
  16570. getClassName(): string;
  16571. /**
  16572. * Serializes the particle system to a JSON object.
  16573. * @returns the JSON object
  16574. */
  16575. serialize(): any;
  16576. /**
  16577. * Parse properties from a JSON object
  16578. * @param serializationObject defines the JSON object
  16579. */
  16580. parse(serializationObject: any): void;
  16581. }
  16582. }
  16583. declare module BABYLON {
  16584. /**
  16585. * Particle emitter emitting particles from the inside of a hemisphere.
  16586. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16587. */
  16588. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16589. /**
  16590. * The radius of the emission hemisphere.
  16591. */
  16592. radius: number;
  16593. /**
  16594. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16595. */
  16596. radiusRange: number;
  16597. /**
  16598. * How much to randomize the particle direction [0-1].
  16599. */
  16600. directionRandomizer: number;
  16601. /**
  16602. * Creates a new instance HemisphericParticleEmitter
  16603. * @param radius the radius of the emission hemisphere (1 by default)
  16604. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16605. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16606. */
  16607. constructor(
  16608. /**
  16609. * The radius of the emission hemisphere.
  16610. */
  16611. radius?: number,
  16612. /**
  16613. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16614. */
  16615. radiusRange?: number,
  16616. /**
  16617. * How much to randomize the particle direction [0-1].
  16618. */
  16619. directionRandomizer?: number);
  16620. /**
  16621. * Called by the particle System when the direction is computed for the created particle.
  16622. * @param worldMatrix is the world matrix of the particle system
  16623. * @param directionToUpdate is the direction vector to update with the result
  16624. * @param particle is the particle we are computed the direction for
  16625. * @param isLocal defines if the direction should be set in local space
  16626. */
  16627. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16628. /**
  16629. * Called by the particle System when the position is computed for the created particle.
  16630. * @param worldMatrix is the world matrix of the particle system
  16631. * @param positionToUpdate is the position vector to update with the result
  16632. * @param particle is the particle we are computed the position for
  16633. * @param isLocal defines if the position should be set in local space
  16634. */
  16635. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16636. /**
  16637. * Clones the current emitter and returns a copy of it
  16638. * @returns the new emitter
  16639. */
  16640. clone(): HemisphericParticleEmitter;
  16641. /**
  16642. * Called by the GPUParticleSystem to setup the update shader
  16643. * @param effect defines the update shader
  16644. */
  16645. applyToShader(effect: Effect): void;
  16646. /**
  16647. * Returns a string to use to update the GPU particles update shader
  16648. * @returns a string containng the defines string
  16649. */
  16650. getEffectDefines(): string;
  16651. /**
  16652. * Returns the string "HemisphericParticleEmitter"
  16653. * @returns a string containing the class name
  16654. */
  16655. getClassName(): string;
  16656. /**
  16657. * Serializes the particle system to a JSON object.
  16658. * @returns the JSON object
  16659. */
  16660. serialize(): any;
  16661. /**
  16662. * Parse properties from a JSON object
  16663. * @param serializationObject defines the JSON object
  16664. */
  16665. parse(serializationObject: any): void;
  16666. }
  16667. }
  16668. declare module BABYLON {
  16669. /**
  16670. * Particle emitter emitting particles from a point.
  16671. * It emits the particles randomly between 2 given directions.
  16672. */
  16673. export class PointParticleEmitter implements IParticleEmitterType {
  16674. /**
  16675. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16676. */
  16677. direction1: Vector3;
  16678. /**
  16679. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16680. */
  16681. direction2: Vector3;
  16682. /**
  16683. * Creates a new instance PointParticleEmitter
  16684. */
  16685. constructor();
  16686. /**
  16687. * Called by the particle System when the direction is computed for the created particle.
  16688. * @param worldMatrix is the world matrix of the particle system
  16689. * @param directionToUpdate is the direction vector to update with the result
  16690. * @param particle is the particle we are computed the direction for
  16691. * @param isLocal defines if the direction should be set in local space
  16692. */
  16693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16694. /**
  16695. * Called by the particle System when the position is computed for the created particle.
  16696. * @param worldMatrix is the world matrix of the particle system
  16697. * @param positionToUpdate is the position vector to update with the result
  16698. * @param particle is the particle we are computed the position for
  16699. * @param isLocal defines if the position should be set in local space
  16700. */
  16701. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16702. /**
  16703. * Clones the current emitter and returns a copy of it
  16704. * @returns the new emitter
  16705. */
  16706. clone(): PointParticleEmitter;
  16707. /**
  16708. * Called by the GPUParticleSystem to setup the update shader
  16709. * @param effect defines the update shader
  16710. */
  16711. applyToShader(effect: Effect): void;
  16712. /**
  16713. * Returns a string to use to update the GPU particles update shader
  16714. * @returns a string containng the defines string
  16715. */
  16716. getEffectDefines(): string;
  16717. /**
  16718. * Returns the string "PointParticleEmitter"
  16719. * @returns a string containing the class name
  16720. */
  16721. getClassName(): string;
  16722. /**
  16723. * Serializes the particle system to a JSON object.
  16724. * @returns the JSON object
  16725. */
  16726. serialize(): any;
  16727. /**
  16728. * Parse properties from a JSON object
  16729. * @param serializationObject defines the JSON object
  16730. */
  16731. parse(serializationObject: any): void;
  16732. }
  16733. }
  16734. declare module BABYLON {
  16735. /**
  16736. * Particle emitter emitting particles from the inside of a sphere.
  16737. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16738. */
  16739. export class SphereParticleEmitter implements IParticleEmitterType {
  16740. /**
  16741. * The radius of the emission sphere.
  16742. */
  16743. radius: number;
  16744. /**
  16745. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16746. */
  16747. radiusRange: number;
  16748. /**
  16749. * How much to randomize the particle direction [0-1].
  16750. */
  16751. directionRandomizer: number;
  16752. /**
  16753. * Creates a new instance SphereParticleEmitter
  16754. * @param radius the radius of the emission sphere (1 by default)
  16755. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16756. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16757. */
  16758. constructor(
  16759. /**
  16760. * The radius of the emission sphere.
  16761. */
  16762. radius?: number,
  16763. /**
  16764. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16765. */
  16766. radiusRange?: number,
  16767. /**
  16768. * How much to randomize the particle direction [0-1].
  16769. */
  16770. directionRandomizer?: number);
  16771. /**
  16772. * Called by the particle System when the direction is computed for the created particle.
  16773. * @param worldMatrix is the world matrix of the particle system
  16774. * @param directionToUpdate is the direction vector to update with the result
  16775. * @param particle is the particle we are computed the direction for
  16776. * @param isLocal defines if the direction should be set in local space
  16777. */
  16778. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16779. /**
  16780. * Called by the particle System when the position is computed for the created particle.
  16781. * @param worldMatrix is the world matrix of the particle system
  16782. * @param positionToUpdate is the position vector to update with the result
  16783. * @param particle is the particle we are computed the position for
  16784. * @param isLocal defines if the position should be set in local space
  16785. */
  16786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16787. /**
  16788. * Clones the current emitter and returns a copy of it
  16789. * @returns the new emitter
  16790. */
  16791. clone(): SphereParticleEmitter;
  16792. /**
  16793. * Called by the GPUParticleSystem to setup the update shader
  16794. * @param effect defines the update shader
  16795. */
  16796. applyToShader(effect: Effect): void;
  16797. /**
  16798. * Returns a string to use to update the GPU particles update shader
  16799. * @returns a string containng the defines string
  16800. */
  16801. getEffectDefines(): string;
  16802. /**
  16803. * Returns the string "SphereParticleEmitter"
  16804. * @returns a string containing the class name
  16805. */
  16806. getClassName(): string;
  16807. /**
  16808. * Serializes the particle system to a JSON object.
  16809. * @returns the JSON object
  16810. */
  16811. serialize(): any;
  16812. /**
  16813. * Parse properties from a JSON object
  16814. * @param serializationObject defines the JSON object
  16815. */
  16816. parse(serializationObject: any): void;
  16817. }
  16818. /**
  16819. * Particle emitter emitting particles from the inside of a sphere.
  16820. * It emits the particles randomly between two vectors.
  16821. */
  16822. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16823. /**
  16824. * The min limit of the emission direction.
  16825. */
  16826. direction1: Vector3;
  16827. /**
  16828. * The max limit of the emission direction.
  16829. */
  16830. direction2: Vector3;
  16831. /**
  16832. * Creates a new instance SphereDirectedParticleEmitter
  16833. * @param radius the radius of the emission sphere (1 by default)
  16834. * @param direction1 the min limit of the emission direction (up vector by default)
  16835. * @param direction2 the max limit of the emission direction (up vector by default)
  16836. */
  16837. constructor(radius?: number,
  16838. /**
  16839. * The min limit of the emission direction.
  16840. */
  16841. direction1?: Vector3,
  16842. /**
  16843. * The max limit of the emission direction.
  16844. */
  16845. direction2?: Vector3);
  16846. /**
  16847. * Called by the particle System when the direction is computed for the created particle.
  16848. * @param worldMatrix is the world matrix of the particle system
  16849. * @param directionToUpdate is the direction vector to update with the result
  16850. * @param particle is the particle we are computed the direction for
  16851. */
  16852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16853. /**
  16854. * Clones the current emitter and returns a copy of it
  16855. * @returns the new emitter
  16856. */
  16857. clone(): SphereDirectedParticleEmitter;
  16858. /**
  16859. * Called by the GPUParticleSystem to setup the update shader
  16860. * @param effect defines the update shader
  16861. */
  16862. applyToShader(effect: Effect): void;
  16863. /**
  16864. * Returns a string to use to update the GPU particles update shader
  16865. * @returns a string containng the defines string
  16866. */
  16867. getEffectDefines(): string;
  16868. /**
  16869. * Returns the string "SphereDirectedParticleEmitter"
  16870. * @returns a string containing the class name
  16871. */
  16872. getClassName(): string;
  16873. /**
  16874. * Serializes the particle system to a JSON object.
  16875. * @returns the JSON object
  16876. */
  16877. serialize(): any;
  16878. /**
  16879. * Parse properties from a JSON object
  16880. * @param serializationObject defines the JSON object
  16881. */
  16882. parse(serializationObject: any): void;
  16883. }
  16884. }
  16885. declare module BABYLON {
  16886. /**
  16887. * Particle emitter emitting particles from a custom list of positions.
  16888. */
  16889. export class CustomParticleEmitter implements IParticleEmitterType {
  16890. /**
  16891. * Gets or sets the position generator that will create the inital position of each particle.
  16892. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16893. */
  16894. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16895. /**
  16896. * Gets or sets the destination generator that will create the final destination of each particle.
  16897. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16898. */
  16899. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16900. /**
  16901. * Creates a new instance CustomParticleEmitter
  16902. */
  16903. constructor();
  16904. /**
  16905. * Called by the particle System when the direction is computed for the created particle.
  16906. * @param worldMatrix is the world matrix of the particle system
  16907. * @param directionToUpdate is the direction vector to update with the result
  16908. * @param particle is the particle we are computed the direction for
  16909. * @param isLocal defines if the direction should be set in local space
  16910. */
  16911. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16912. /**
  16913. * Called by the particle System when the position is computed for the created particle.
  16914. * @param worldMatrix is the world matrix of the particle system
  16915. * @param positionToUpdate is the position vector to update with the result
  16916. * @param particle is the particle we are computed the position for
  16917. * @param isLocal defines if the position should be set in local space
  16918. */
  16919. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16920. /**
  16921. * Clones the current emitter and returns a copy of it
  16922. * @returns the new emitter
  16923. */
  16924. clone(): CustomParticleEmitter;
  16925. /**
  16926. * Called by the GPUParticleSystem to setup the update shader
  16927. * @param effect defines the update shader
  16928. */
  16929. applyToShader(effect: Effect): void;
  16930. /**
  16931. * Returns a string to use to update the GPU particles update shader
  16932. * @returns a string containng the defines string
  16933. */
  16934. getEffectDefines(): string;
  16935. /**
  16936. * Returns the string "PointParticleEmitter"
  16937. * @returns a string containing the class name
  16938. */
  16939. getClassName(): string;
  16940. /**
  16941. * Serializes the particle system to a JSON object.
  16942. * @returns the JSON object
  16943. */
  16944. serialize(): any;
  16945. /**
  16946. * Parse properties from a JSON object
  16947. * @param serializationObject defines the JSON object
  16948. */
  16949. parse(serializationObject: any): void;
  16950. }
  16951. }
  16952. declare module BABYLON {
  16953. /**
  16954. * Particle emitter emitting particles from the inside of a box.
  16955. * It emits the particles randomly between 2 given directions.
  16956. */
  16957. export class MeshParticleEmitter implements IParticleEmitterType {
  16958. private _indices;
  16959. private _positions;
  16960. private _normals;
  16961. private _storedNormal;
  16962. private _mesh;
  16963. /**
  16964. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16965. */
  16966. direction1: Vector3;
  16967. /**
  16968. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16969. */
  16970. direction2: Vector3;
  16971. /**
  16972. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16973. */
  16974. useMeshNormalsForDirection: boolean;
  16975. /** Defines the mesh to use as source */
  16976. get mesh(): Nullable<AbstractMesh>;
  16977. set mesh(value: Nullable<AbstractMesh>);
  16978. /**
  16979. * Creates a new instance MeshParticleEmitter
  16980. * @param mesh defines the mesh to use as source
  16981. */
  16982. constructor(mesh?: Nullable<AbstractMesh>);
  16983. /**
  16984. * Called by the particle System when the direction is computed for the created particle.
  16985. * @param worldMatrix is the world matrix of the particle system
  16986. * @param directionToUpdate is the direction vector to update with the result
  16987. * @param particle is the particle we are computed the direction for
  16988. * @param isLocal defines if the direction should be set in local space
  16989. */
  16990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16991. /**
  16992. * Called by the particle System when the position is computed for the created particle.
  16993. * @param worldMatrix is the world matrix of the particle system
  16994. * @param positionToUpdate is the position vector to update with the result
  16995. * @param particle is the particle we are computed the position for
  16996. * @param isLocal defines if the position should be set in local space
  16997. */
  16998. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16999. /**
  17000. * Clones the current emitter and returns a copy of it
  17001. * @returns the new emitter
  17002. */
  17003. clone(): MeshParticleEmitter;
  17004. /**
  17005. * Called by the GPUParticleSystem to setup the update shader
  17006. * @param effect defines the update shader
  17007. */
  17008. applyToShader(effect: Effect): void;
  17009. /**
  17010. * Returns a string to use to update the GPU particles update shader
  17011. * @returns a string containng the defines string
  17012. */
  17013. getEffectDefines(): string;
  17014. /**
  17015. * Returns the string "BoxParticleEmitter"
  17016. * @returns a string containing the class name
  17017. */
  17018. getClassName(): string;
  17019. /**
  17020. * Serializes the particle system to a JSON object.
  17021. * @returns the JSON object
  17022. */
  17023. serialize(): any;
  17024. /**
  17025. * Parse properties from a JSON object
  17026. * @param serializationObject defines the JSON object
  17027. * @param scene defines the hosting scene
  17028. */
  17029. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17030. }
  17031. }
  17032. declare module BABYLON {
  17033. /**
  17034. * Interface representing a particle system in Babylon.js.
  17035. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17036. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17037. */
  17038. export interface IParticleSystem {
  17039. /**
  17040. * List of animations used by the particle system.
  17041. */
  17042. animations: Animation[];
  17043. /**
  17044. * The id of the Particle system.
  17045. */
  17046. id: string;
  17047. /**
  17048. * The name of the Particle system.
  17049. */
  17050. name: string;
  17051. /**
  17052. * The emitter represents the Mesh or position we are attaching the particle system to.
  17053. */
  17054. emitter: Nullable<AbstractMesh | Vector3>;
  17055. /**
  17056. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17057. */
  17058. isBillboardBased: boolean;
  17059. /**
  17060. * The rendering group used by the Particle system to chose when to render.
  17061. */
  17062. renderingGroupId: number;
  17063. /**
  17064. * The layer mask we are rendering the particles through.
  17065. */
  17066. layerMask: number;
  17067. /**
  17068. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17069. */
  17070. updateSpeed: number;
  17071. /**
  17072. * The amount of time the particle system is running (depends of the overall update speed).
  17073. */
  17074. targetStopDuration: number;
  17075. /**
  17076. * The texture used to render each particle. (this can be a spritesheet)
  17077. */
  17078. particleTexture: Nullable<BaseTexture>;
  17079. /**
  17080. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17081. */
  17082. blendMode: number;
  17083. /**
  17084. * Minimum life time of emitting particles.
  17085. */
  17086. minLifeTime: number;
  17087. /**
  17088. * Maximum life time of emitting particles.
  17089. */
  17090. maxLifeTime: number;
  17091. /**
  17092. * Minimum Size of emitting particles.
  17093. */
  17094. minSize: number;
  17095. /**
  17096. * Maximum Size of emitting particles.
  17097. */
  17098. maxSize: number;
  17099. /**
  17100. * Minimum scale of emitting particles on X axis.
  17101. */
  17102. minScaleX: number;
  17103. /**
  17104. * Maximum scale of emitting particles on X axis.
  17105. */
  17106. maxScaleX: number;
  17107. /**
  17108. * Minimum scale of emitting particles on Y axis.
  17109. */
  17110. minScaleY: number;
  17111. /**
  17112. * Maximum scale of emitting particles on Y axis.
  17113. */
  17114. maxScaleY: number;
  17115. /**
  17116. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17117. */
  17118. color1: Color4;
  17119. /**
  17120. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17121. */
  17122. color2: Color4;
  17123. /**
  17124. * Color the particle will have at the end of its lifetime.
  17125. */
  17126. colorDead: Color4;
  17127. /**
  17128. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17129. */
  17130. emitRate: number;
  17131. /**
  17132. * You can use gravity if you want to give an orientation to your particles.
  17133. */
  17134. gravity: Vector3;
  17135. /**
  17136. * Minimum power of emitting particles.
  17137. */
  17138. minEmitPower: number;
  17139. /**
  17140. * Maximum power of emitting particles.
  17141. */
  17142. maxEmitPower: number;
  17143. /**
  17144. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17145. */
  17146. minAngularSpeed: number;
  17147. /**
  17148. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17149. */
  17150. maxAngularSpeed: number;
  17151. /**
  17152. * Gets or sets the minimal initial rotation in radians.
  17153. */
  17154. minInitialRotation: number;
  17155. /**
  17156. * Gets or sets the maximal initial rotation in radians.
  17157. */
  17158. maxInitialRotation: number;
  17159. /**
  17160. * The particle emitter type defines the emitter used by the particle system.
  17161. * It can be for example box, sphere, or cone...
  17162. */
  17163. particleEmitterType: Nullable<IParticleEmitterType>;
  17164. /**
  17165. * Defines the delay in milliseconds before starting the system (0 by default)
  17166. */
  17167. startDelay: number;
  17168. /**
  17169. * 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
  17170. */
  17171. preWarmCycles: number;
  17172. /**
  17173. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17174. */
  17175. preWarmStepOffset: number;
  17176. /**
  17177. * 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)
  17178. */
  17179. spriteCellChangeSpeed: number;
  17180. /**
  17181. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17182. */
  17183. startSpriteCellID: number;
  17184. /**
  17185. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17186. */
  17187. endSpriteCellID: number;
  17188. /**
  17189. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17190. */
  17191. spriteCellWidth: number;
  17192. /**
  17193. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17194. */
  17195. spriteCellHeight: number;
  17196. /**
  17197. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17198. */
  17199. spriteRandomStartCell: boolean;
  17200. /**
  17201. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17202. */
  17203. isAnimationSheetEnabled: boolean;
  17204. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17205. translationPivot: Vector2;
  17206. /**
  17207. * Gets or sets a texture used to add random noise to particle positions
  17208. */
  17209. noiseTexture: Nullable<BaseTexture>;
  17210. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17211. noiseStrength: Vector3;
  17212. /**
  17213. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17214. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17215. */
  17216. billboardMode: number;
  17217. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17218. limitVelocityDamping: number;
  17219. /**
  17220. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17221. */
  17222. beginAnimationOnStart: boolean;
  17223. /**
  17224. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17225. */
  17226. beginAnimationFrom: number;
  17227. /**
  17228. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17229. */
  17230. beginAnimationTo: number;
  17231. /**
  17232. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17233. */
  17234. beginAnimationLoop: boolean;
  17235. /**
  17236. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17237. */
  17238. disposeOnStop: boolean;
  17239. /**
  17240. * Specifies if the particles are updated in emitter local space or world space
  17241. */
  17242. isLocal: boolean;
  17243. /** Snippet ID if the particle system was created from the snippet server */
  17244. snippetId: string;
  17245. /** Gets or sets a matrix to use to compute projection */
  17246. defaultProjectionMatrix: Matrix;
  17247. /**
  17248. * Gets the maximum number of particles active at the same time.
  17249. * @returns The max number of active particles.
  17250. */
  17251. getCapacity(): number;
  17252. /**
  17253. * Gets the number of particles active at the same time.
  17254. * @returns The number of active particles.
  17255. */
  17256. getActiveCount(): number;
  17257. /**
  17258. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17259. * @returns True if it has been started, otherwise false.
  17260. */
  17261. isStarted(): boolean;
  17262. /**
  17263. * Animates the particle system for this frame.
  17264. */
  17265. animate(): void;
  17266. /**
  17267. * Renders the particle system in its current state.
  17268. * @returns the current number of particles
  17269. */
  17270. render(): number;
  17271. /**
  17272. * Dispose the particle system and frees its associated resources.
  17273. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17274. */
  17275. dispose(disposeTexture?: boolean): void;
  17276. /**
  17277. * An event triggered when the system is disposed
  17278. */
  17279. onDisposeObservable: Observable<IParticleSystem>;
  17280. /**
  17281. * An event triggered when the system is stopped
  17282. */
  17283. onStoppedObservable: Observable<IParticleSystem>;
  17284. /**
  17285. * Clones the particle system.
  17286. * @param name The name of the cloned object
  17287. * @param newEmitter The new emitter to use
  17288. * @returns the cloned particle system
  17289. */
  17290. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17291. /**
  17292. * Serializes the particle system to a JSON object
  17293. * @param serializeTexture defines if the texture must be serialized as well
  17294. * @returns the JSON object
  17295. */
  17296. serialize(serializeTexture: boolean): any;
  17297. /**
  17298. * Rebuild the particle system
  17299. */
  17300. rebuild(): void;
  17301. /** Force the system to rebuild all gradients that need to be resync */
  17302. forceRefreshGradients(): void;
  17303. /**
  17304. * Starts the particle system and begins to emit
  17305. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17306. */
  17307. start(delay?: number): void;
  17308. /**
  17309. * Stops the particle system.
  17310. */
  17311. stop(): void;
  17312. /**
  17313. * Remove all active particles
  17314. */
  17315. reset(): void;
  17316. /**
  17317. * Gets a boolean indicating that the system is stopping
  17318. * @returns true if the system is currently stopping
  17319. */
  17320. isStopping(): boolean;
  17321. /**
  17322. * Is this system ready to be used/rendered
  17323. * @return true if the system is ready
  17324. */
  17325. isReady(): boolean;
  17326. /**
  17327. * Returns the string "ParticleSystem"
  17328. * @returns a string containing the class name
  17329. */
  17330. getClassName(): string;
  17331. /**
  17332. * Gets the custom effect used to render the particles
  17333. * @param blendMode Blend mode for which the effect should be retrieved
  17334. * @returns The effect
  17335. */
  17336. getCustomEffect(blendMode: number): Nullable<Effect>;
  17337. /**
  17338. * Sets the custom effect used to render the particles
  17339. * @param effect The effect to set
  17340. * @param blendMode Blend mode for which the effect should be set
  17341. */
  17342. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17343. /**
  17344. * Fill the defines array according to the current settings of the particle system
  17345. * @param defines Array to be updated
  17346. * @param blendMode blend mode to take into account when updating the array
  17347. */
  17348. fillDefines(defines: Array<string>, blendMode: number): void;
  17349. /**
  17350. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17351. * @param uniforms Uniforms array to fill
  17352. * @param attributes Attributes array to fill
  17353. * @param samplers Samplers array to fill
  17354. */
  17355. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17356. /**
  17357. * Observable that will be called just before the particles are drawn
  17358. */
  17359. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17360. /**
  17361. * Gets the name of the particle vertex shader
  17362. */
  17363. vertexShaderName: string;
  17364. /**
  17365. * Adds a new color gradient
  17366. * @param gradient defines the gradient to use (between 0 and 1)
  17367. * @param color1 defines the color to affect to the specified gradient
  17368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17369. * @returns the current particle system
  17370. */
  17371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17372. /**
  17373. * Remove a specific color gradient
  17374. * @param gradient defines the gradient to remove
  17375. * @returns the current particle system
  17376. */
  17377. removeColorGradient(gradient: number): IParticleSystem;
  17378. /**
  17379. * Adds a new size gradient
  17380. * @param gradient defines the gradient to use (between 0 and 1)
  17381. * @param factor defines the size factor to affect to the specified gradient
  17382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17383. * @returns the current particle system
  17384. */
  17385. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17386. /**
  17387. * Remove a specific size gradient
  17388. * @param gradient defines the gradient to remove
  17389. * @returns the current particle system
  17390. */
  17391. removeSizeGradient(gradient: number): IParticleSystem;
  17392. /**
  17393. * Gets the current list of color gradients.
  17394. * You must use addColorGradient and removeColorGradient to udpate this list
  17395. * @returns the list of color gradients
  17396. */
  17397. getColorGradients(): Nullable<Array<ColorGradient>>;
  17398. /**
  17399. * Gets the current list of size gradients.
  17400. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17401. * @returns the list of size gradients
  17402. */
  17403. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17404. /**
  17405. * Gets the current list of angular speed gradients.
  17406. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17407. * @returns the list of angular speed gradients
  17408. */
  17409. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17410. /**
  17411. * Adds a new angular speed gradient
  17412. * @param gradient defines the gradient to use (between 0 and 1)
  17413. * @param factor defines the angular speed to affect to the specified gradient
  17414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17415. * @returns the current particle system
  17416. */
  17417. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17418. /**
  17419. * Remove a specific angular speed gradient
  17420. * @param gradient defines the gradient to remove
  17421. * @returns the current particle system
  17422. */
  17423. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17424. /**
  17425. * Gets the current list of velocity gradients.
  17426. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17427. * @returns the list of velocity gradients
  17428. */
  17429. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17430. /**
  17431. * Adds a new velocity gradient
  17432. * @param gradient defines the gradient to use (between 0 and 1)
  17433. * @param factor defines the velocity to affect to the specified gradient
  17434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17435. * @returns the current particle system
  17436. */
  17437. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17438. /**
  17439. * Remove a specific velocity gradient
  17440. * @param gradient defines the gradient to remove
  17441. * @returns the current particle system
  17442. */
  17443. removeVelocityGradient(gradient: number): IParticleSystem;
  17444. /**
  17445. * Gets the current list of limit velocity gradients.
  17446. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17447. * @returns the list of limit velocity gradients
  17448. */
  17449. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17450. /**
  17451. * Adds a new limit velocity gradient
  17452. * @param gradient defines the gradient to use (between 0 and 1)
  17453. * @param factor defines the limit velocity to affect to the specified gradient
  17454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17455. * @returns the current particle system
  17456. */
  17457. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17458. /**
  17459. * Remove a specific limit velocity gradient
  17460. * @param gradient defines the gradient to remove
  17461. * @returns the current particle system
  17462. */
  17463. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17464. /**
  17465. * Adds a new drag gradient
  17466. * @param gradient defines the gradient to use (between 0 and 1)
  17467. * @param factor defines the drag to affect to the specified gradient
  17468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17469. * @returns the current particle system
  17470. */
  17471. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17472. /**
  17473. * Remove a specific drag gradient
  17474. * @param gradient defines the gradient to remove
  17475. * @returns the current particle system
  17476. */
  17477. removeDragGradient(gradient: number): IParticleSystem;
  17478. /**
  17479. * Gets the current list of drag gradients.
  17480. * You must use addDragGradient and removeDragGradient to udpate this list
  17481. * @returns the list of drag gradients
  17482. */
  17483. getDragGradients(): Nullable<Array<FactorGradient>>;
  17484. /**
  17485. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17486. * @param gradient defines the gradient to use (between 0 and 1)
  17487. * @param factor defines the emit rate to affect to the specified gradient
  17488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17489. * @returns the current particle system
  17490. */
  17491. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17492. /**
  17493. * Remove a specific emit rate gradient
  17494. * @param gradient defines the gradient to remove
  17495. * @returns the current particle system
  17496. */
  17497. removeEmitRateGradient(gradient: number): IParticleSystem;
  17498. /**
  17499. * Gets the current list of emit rate gradients.
  17500. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17501. * @returns the list of emit rate gradients
  17502. */
  17503. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17504. /**
  17505. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param factor defines the start size to affect to the specified gradient
  17508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17509. * @returns the current particle system
  17510. */
  17511. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific start size gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeStartSizeGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Gets the current list of start size gradients.
  17520. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17521. * @returns the list of start size gradients
  17522. */
  17523. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17524. /**
  17525. * Adds a new life time gradient
  17526. * @param gradient defines the gradient to use (between 0 and 1)
  17527. * @param factor defines the life time factor to affect to the specified gradient
  17528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17529. * @returns the current particle system
  17530. */
  17531. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17532. /**
  17533. * Remove a specific life time gradient
  17534. * @param gradient defines the gradient to remove
  17535. * @returns the current particle system
  17536. */
  17537. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17538. /**
  17539. * Gets the current list of life time gradients.
  17540. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17541. * @returns the list of life time gradients
  17542. */
  17543. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17544. /**
  17545. * Gets the current list of color gradients.
  17546. * You must use addColorGradient and removeColorGradient to udpate this list
  17547. * @returns the list of color gradients
  17548. */
  17549. getColorGradients(): Nullable<Array<ColorGradient>>;
  17550. /**
  17551. * Adds a new ramp gradient used to remap particle colors
  17552. * @param gradient defines the gradient to use (between 0 and 1)
  17553. * @param color defines the color to affect to the specified gradient
  17554. * @returns the current particle system
  17555. */
  17556. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17557. /**
  17558. * Gets the current list of ramp gradients.
  17559. * You must use addRampGradient and removeRampGradient to udpate this list
  17560. * @returns the list of ramp gradients
  17561. */
  17562. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17563. /** Gets or sets a boolean indicating that ramp gradients must be used
  17564. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17565. */
  17566. useRampGradients: boolean;
  17567. /**
  17568. * Adds a new color remap gradient
  17569. * @param gradient defines the gradient to use (between 0 and 1)
  17570. * @param min defines the color remap minimal range
  17571. * @param max defines the color remap maximal range
  17572. * @returns the current particle system
  17573. */
  17574. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17575. /**
  17576. * Gets the current list of color remap gradients.
  17577. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17578. * @returns the list of color remap gradients
  17579. */
  17580. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17581. /**
  17582. * Adds a new alpha remap gradient
  17583. * @param gradient defines the gradient to use (between 0 and 1)
  17584. * @param min defines the alpha remap minimal range
  17585. * @param max defines the alpha remap maximal range
  17586. * @returns the current particle system
  17587. */
  17588. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17589. /**
  17590. * Gets the current list of alpha remap gradients.
  17591. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17592. * @returns the list of alpha remap gradients
  17593. */
  17594. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17595. /**
  17596. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17599. * @returns the emitter
  17600. */
  17601. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17602. /**
  17603. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17604. * @param radius The radius of the hemisphere to emit from
  17605. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17606. * @returns the emitter
  17607. */
  17608. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17609. /**
  17610. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17611. * @param radius The radius of the sphere to emit from
  17612. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17613. * @returns the emitter
  17614. */
  17615. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17616. /**
  17617. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17618. * @param radius The radius of the sphere to emit from
  17619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17621. * @returns the emitter
  17622. */
  17623. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17624. /**
  17625. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17626. * @param radius The radius of the emission cylinder
  17627. * @param height The height of the emission cylinder
  17628. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17629. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17630. * @returns the emitter
  17631. */
  17632. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17633. /**
  17634. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17635. * @param radius The radius of the cylinder to emit from
  17636. * @param height The height of the emission cylinder
  17637. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17640. * @returns the emitter
  17641. */
  17642. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17643. /**
  17644. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17645. * @param radius The radius of the cone to emit from
  17646. * @param angle The base angle of the cone
  17647. * @returns the emitter
  17648. */
  17649. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17650. /**
  17651. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17654. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17655. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17656. * @returns the emitter
  17657. */
  17658. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17659. /**
  17660. * Get hosting scene
  17661. * @returns the scene
  17662. */
  17663. getScene(): Nullable<Scene>;
  17664. }
  17665. }
  17666. declare module BABYLON {
  17667. /**
  17668. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17669. */
  17670. export class ColorSplitterBlock extends NodeMaterialBlock {
  17671. /**
  17672. * Create a new ColorSplitterBlock
  17673. * @param name defines the block name
  17674. */
  17675. constructor(name: string);
  17676. /**
  17677. * Gets the current class name
  17678. * @returns the class name
  17679. */
  17680. getClassName(): string;
  17681. /**
  17682. * Gets the rgba component (input)
  17683. */
  17684. get rgba(): NodeMaterialConnectionPoint;
  17685. /**
  17686. * Gets the rgb component (input)
  17687. */
  17688. get rgbIn(): NodeMaterialConnectionPoint;
  17689. /**
  17690. * Gets the rgb component (output)
  17691. */
  17692. get rgbOut(): NodeMaterialConnectionPoint;
  17693. /**
  17694. * Gets the r component (output)
  17695. */
  17696. get r(): NodeMaterialConnectionPoint;
  17697. /**
  17698. * Gets the g component (output)
  17699. */
  17700. get g(): NodeMaterialConnectionPoint;
  17701. /**
  17702. * Gets the b component (output)
  17703. */
  17704. get b(): NodeMaterialConnectionPoint;
  17705. /**
  17706. * Gets the a component (output)
  17707. */
  17708. get a(): NodeMaterialConnectionPoint;
  17709. protected _inputRename(name: string): string;
  17710. protected _outputRename(name: string): string;
  17711. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17712. }
  17713. }
  17714. declare module BABYLON {
  17715. /**
  17716. * Operations supported by the Trigonometry block
  17717. */
  17718. export enum TrigonometryBlockOperations {
  17719. /** Cos */
  17720. Cos = 0,
  17721. /** Sin */
  17722. Sin = 1,
  17723. /** Abs */
  17724. Abs = 2,
  17725. /** Exp */
  17726. Exp = 3,
  17727. /** Exp2 */
  17728. Exp2 = 4,
  17729. /** Round */
  17730. Round = 5,
  17731. /** Floor */
  17732. Floor = 6,
  17733. /** Ceiling */
  17734. Ceiling = 7,
  17735. /** Square root */
  17736. Sqrt = 8,
  17737. /** Log */
  17738. Log = 9,
  17739. /** Tangent */
  17740. Tan = 10,
  17741. /** Arc tangent */
  17742. ArcTan = 11,
  17743. /** Arc cosinus */
  17744. ArcCos = 12,
  17745. /** Arc sinus */
  17746. ArcSin = 13,
  17747. /** Fraction */
  17748. Fract = 14,
  17749. /** Sign */
  17750. Sign = 15,
  17751. /** To radians (from degrees) */
  17752. Radians = 16,
  17753. /** To degrees (from radians) */
  17754. Degrees = 17
  17755. }
  17756. /**
  17757. * Block used to apply trigonometry operation to floats
  17758. */
  17759. export class TrigonometryBlock extends NodeMaterialBlock {
  17760. /**
  17761. * Gets or sets the operation applied by the block
  17762. */
  17763. operation: TrigonometryBlockOperations;
  17764. /**
  17765. * Creates a new TrigonometryBlock
  17766. * @param name defines the block name
  17767. */
  17768. constructor(name: string);
  17769. /**
  17770. * Gets the current class name
  17771. * @returns the class name
  17772. */
  17773. getClassName(): string;
  17774. /**
  17775. * Gets the input component
  17776. */
  17777. get input(): NodeMaterialConnectionPoint;
  17778. /**
  17779. * Gets the output component
  17780. */
  17781. get output(): NodeMaterialConnectionPoint;
  17782. protected _buildBlock(state: NodeMaterialBuildState): this;
  17783. serialize(): any;
  17784. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17785. protected _dumpPropertiesCode(): string;
  17786. }
  17787. }
  17788. declare module BABYLON {
  17789. /**
  17790. * Interface used to configure the node material editor
  17791. */
  17792. export interface INodeMaterialEditorOptions {
  17793. /** Define the URl to load node editor script */
  17794. editorURL?: string;
  17795. }
  17796. /** @hidden */
  17797. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17798. NORMAL: boolean;
  17799. TANGENT: boolean;
  17800. UV1: boolean;
  17801. /** BONES */
  17802. NUM_BONE_INFLUENCERS: number;
  17803. BonesPerMesh: number;
  17804. BONETEXTURE: boolean;
  17805. /** MORPH TARGETS */
  17806. MORPHTARGETS: boolean;
  17807. MORPHTARGETS_NORMAL: boolean;
  17808. MORPHTARGETS_TANGENT: boolean;
  17809. MORPHTARGETS_UV: boolean;
  17810. NUM_MORPH_INFLUENCERS: number;
  17811. /** IMAGE PROCESSING */
  17812. IMAGEPROCESSING: boolean;
  17813. VIGNETTE: boolean;
  17814. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17815. VIGNETTEBLENDMODEOPAQUE: boolean;
  17816. TONEMAPPING: boolean;
  17817. TONEMAPPING_ACES: boolean;
  17818. CONTRAST: boolean;
  17819. EXPOSURE: boolean;
  17820. COLORCURVES: boolean;
  17821. COLORGRADING: boolean;
  17822. COLORGRADING3D: boolean;
  17823. SAMPLER3DGREENDEPTH: boolean;
  17824. SAMPLER3DBGRMAP: boolean;
  17825. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17826. /** MISC. */
  17827. BUMPDIRECTUV: number;
  17828. constructor();
  17829. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17830. }
  17831. /**
  17832. * Class used to configure NodeMaterial
  17833. */
  17834. export interface INodeMaterialOptions {
  17835. /**
  17836. * Defines if blocks should emit comments
  17837. */
  17838. emitComments: boolean;
  17839. }
  17840. /**
  17841. * Class used to create a node based material built by assembling shader blocks
  17842. */
  17843. export class NodeMaterial extends PushMaterial {
  17844. private static _BuildIdGenerator;
  17845. private _options;
  17846. private _vertexCompilationState;
  17847. private _fragmentCompilationState;
  17848. private _sharedData;
  17849. private _buildId;
  17850. private _buildWasSuccessful;
  17851. private _cachedWorldViewMatrix;
  17852. private _cachedWorldViewProjectionMatrix;
  17853. private _optimizers;
  17854. private _animationFrame;
  17855. /** Define the Url to load node editor script */
  17856. static EditorURL: string;
  17857. /** Define the Url to load snippets */
  17858. static SnippetUrl: string;
  17859. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17860. static IgnoreTexturesAtLoadTime: boolean;
  17861. private BJSNODEMATERIALEDITOR;
  17862. /** Get the inspector from bundle or global */
  17863. private _getGlobalNodeMaterialEditor;
  17864. /**
  17865. * Snippet ID if the material was created from the snippet server
  17866. */
  17867. snippetId: string;
  17868. /**
  17869. * Gets or sets data used by visual editor
  17870. * @see https://nme.babylonjs.com
  17871. */
  17872. editorData: any;
  17873. /**
  17874. * 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)
  17875. */
  17876. ignoreAlpha: boolean;
  17877. /**
  17878. * Defines the maximum number of lights that can be used in the material
  17879. */
  17880. maxSimultaneousLights: number;
  17881. /**
  17882. * Observable raised when the material is built
  17883. */
  17884. onBuildObservable: Observable<NodeMaterial>;
  17885. /**
  17886. * Gets or sets the root nodes of the material vertex shader
  17887. */
  17888. _vertexOutputNodes: NodeMaterialBlock[];
  17889. /**
  17890. * Gets or sets the root nodes of the material fragment (pixel) shader
  17891. */
  17892. _fragmentOutputNodes: NodeMaterialBlock[];
  17893. /** Gets or sets options to control the node material overall behavior */
  17894. get options(): INodeMaterialOptions;
  17895. set options(options: INodeMaterialOptions);
  17896. /**
  17897. * Default configuration related to image processing available in the standard Material.
  17898. */
  17899. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17900. /**
  17901. * Gets the image processing configuration used either in this material.
  17902. */
  17903. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17904. /**
  17905. * Sets the Default image processing configuration used either in the this material.
  17906. *
  17907. * If sets to null, the scene one is in use.
  17908. */
  17909. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17910. /**
  17911. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17912. */
  17913. attachedBlocks: NodeMaterialBlock[];
  17914. /**
  17915. * Specifies the mode of the node material
  17916. * @hidden
  17917. */
  17918. _mode: NodeMaterialModes;
  17919. /**
  17920. * Gets the mode property
  17921. */
  17922. get mode(): NodeMaterialModes;
  17923. /**
  17924. * A free comment about the material
  17925. */
  17926. comment: string;
  17927. /**
  17928. * Create a new node based material
  17929. * @param name defines the material name
  17930. * @param scene defines the hosting scene
  17931. * @param options defines creation option
  17932. */
  17933. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17934. /**
  17935. * Gets the current class name of the material e.g. "NodeMaterial"
  17936. * @returns the class name
  17937. */
  17938. getClassName(): string;
  17939. /**
  17940. * Keep track of the image processing observer to allow dispose and replace.
  17941. */
  17942. private _imageProcessingObserver;
  17943. /**
  17944. * Attaches a new image processing configuration to the Standard Material.
  17945. * @param configuration
  17946. */
  17947. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17948. /**
  17949. * Get a block by its name
  17950. * @param name defines the name of the block to retrieve
  17951. * @returns the required block or null if not found
  17952. */
  17953. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17954. /**
  17955. * Get a block by its name
  17956. * @param predicate defines the predicate used to find the good candidate
  17957. * @returns the required block or null if not found
  17958. */
  17959. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17960. /**
  17961. * Get an input block by its name
  17962. * @param predicate defines the predicate used to find the good candidate
  17963. * @returns the required input block or null if not found
  17964. */
  17965. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17966. /**
  17967. * Gets the list of input blocks attached to this material
  17968. * @returns an array of InputBlocks
  17969. */
  17970. getInputBlocks(): InputBlock[];
  17971. /**
  17972. * Adds a new optimizer to the list of optimizers
  17973. * @param optimizer defines the optimizers to add
  17974. * @returns the current material
  17975. */
  17976. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17977. /**
  17978. * Remove an optimizer from the list of optimizers
  17979. * @param optimizer defines the optimizers to remove
  17980. * @returns the current material
  17981. */
  17982. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17983. /**
  17984. * Add a new block to the list of output nodes
  17985. * @param node defines the node to add
  17986. * @returns the current material
  17987. */
  17988. addOutputNode(node: NodeMaterialBlock): this;
  17989. /**
  17990. * Remove a block from the list of root nodes
  17991. * @param node defines the node to remove
  17992. * @returns the current material
  17993. */
  17994. removeOutputNode(node: NodeMaterialBlock): this;
  17995. private _addVertexOutputNode;
  17996. private _removeVertexOutputNode;
  17997. private _addFragmentOutputNode;
  17998. private _removeFragmentOutputNode;
  17999. /**
  18000. * Specifies if the material will require alpha blending
  18001. * @returns a boolean specifying if alpha blending is needed
  18002. */
  18003. needAlphaBlending(): boolean;
  18004. /**
  18005. * Specifies if this material should be rendered in alpha test mode
  18006. * @returns a boolean specifying if an alpha test is needed.
  18007. */
  18008. needAlphaTesting(): boolean;
  18009. private _initializeBlock;
  18010. private _resetDualBlocks;
  18011. /**
  18012. * Remove a block from the current node material
  18013. * @param block defines the block to remove
  18014. */
  18015. removeBlock(block: NodeMaterialBlock): void;
  18016. /**
  18017. * Build the material and generates the inner effect
  18018. * @param verbose defines if the build should log activity
  18019. */
  18020. build(verbose?: boolean): void;
  18021. /**
  18022. * Runs an otpimization phase to try to improve the shader code
  18023. */
  18024. optimize(): void;
  18025. private _prepareDefinesForAttributes;
  18026. /**
  18027. * Create a post process from the material
  18028. * @param camera The camera to apply the render pass to.
  18029. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18031. * @param engine The engine which the post process will be applied. (default: current engine)
  18032. * @param reusable If the post process can be reused on the same frame. (default: false)
  18033. * @param textureType Type of textures used when performing the post process. (default: 0)
  18034. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18035. * @returns the post process created
  18036. */
  18037. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18038. /**
  18039. * Create the post process effect from the material
  18040. * @param postProcess The post process to create the effect for
  18041. */
  18042. createEffectForPostProcess(postProcess: PostProcess): void;
  18043. private _createEffectForPostProcess;
  18044. /**
  18045. * Create a new procedural texture based on this node material
  18046. * @param size defines the size of the texture
  18047. * @param scene defines the hosting scene
  18048. * @returns the new procedural texture attached to this node material
  18049. */
  18050. createProceduralTexture(size: number | {
  18051. width: number;
  18052. height: number;
  18053. layers?: number;
  18054. }, scene: Scene): Nullable<ProceduralTexture>;
  18055. private _createEffectForParticles;
  18056. private _checkInternals;
  18057. /**
  18058. * Create the effect to be used as the custom effect for a particle system
  18059. * @param particleSystem Particle system to create the effect for
  18060. * @param onCompiled defines a function to call when the effect creation is successful
  18061. * @param onError defines a function to call when the effect creation has failed
  18062. */
  18063. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18064. private _processDefines;
  18065. /**
  18066. * Get if the submesh is ready to be used and all its information available.
  18067. * Child classes can use it to update shaders
  18068. * @param mesh defines the mesh to check
  18069. * @param subMesh defines which submesh to check
  18070. * @param useInstances specifies that instances should be used
  18071. * @returns a boolean indicating that the submesh is ready or not
  18072. */
  18073. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18074. /**
  18075. * Get a string representing the shaders built by the current node graph
  18076. */
  18077. get compiledShaders(): string;
  18078. /**
  18079. * Binds the world matrix to the material
  18080. * @param world defines the world transformation matrix
  18081. */
  18082. bindOnlyWorldMatrix(world: Matrix): void;
  18083. /**
  18084. * Binds the submesh to this material by preparing the effect and shader to draw
  18085. * @param world defines the world transformation matrix
  18086. * @param mesh defines the mesh containing the submesh
  18087. * @param subMesh defines the submesh to bind the material to
  18088. */
  18089. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18090. /**
  18091. * Gets the active textures from the material
  18092. * @returns an array of textures
  18093. */
  18094. getActiveTextures(): BaseTexture[];
  18095. /**
  18096. * Gets the list of texture blocks
  18097. * @returns an array of texture blocks
  18098. */
  18099. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18100. /**
  18101. * Specifies if the material uses a texture
  18102. * @param texture defines the texture to check against the material
  18103. * @returns a boolean specifying if the material uses the texture
  18104. */
  18105. hasTexture(texture: BaseTexture): boolean;
  18106. /**
  18107. * Disposes the material
  18108. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18109. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18110. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18111. */
  18112. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18113. /** Creates the node editor window. */
  18114. private _createNodeEditor;
  18115. /**
  18116. * Launch the node material editor
  18117. * @param config Define the configuration of the editor
  18118. * @return a promise fulfilled when the node editor is visible
  18119. */
  18120. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18121. /**
  18122. * Clear the current material
  18123. */
  18124. clear(): void;
  18125. /**
  18126. * Clear the current material and set it to a default state
  18127. */
  18128. setToDefault(): void;
  18129. /**
  18130. * Clear the current material and set it to a default state for post process
  18131. */
  18132. setToDefaultPostProcess(): void;
  18133. /**
  18134. * Clear the current material and set it to a default state for procedural texture
  18135. */
  18136. setToDefaultProceduralTexture(): void;
  18137. /**
  18138. * Clear the current material and set it to a default state for particle
  18139. */
  18140. setToDefaultParticle(): void;
  18141. /**
  18142. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18143. * @param url defines the url to load from
  18144. * @returns a promise that will fullfil when the material is fully loaded
  18145. */
  18146. loadAsync(url: string): Promise<void>;
  18147. private _gatherBlocks;
  18148. /**
  18149. * Generate a string containing the code declaration required to create an equivalent of this material
  18150. * @returns a string
  18151. */
  18152. generateCode(): string;
  18153. /**
  18154. * Serializes this material in a JSON representation
  18155. * @returns the serialized material object
  18156. */
  18157. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18158. private _restoreConnections;
  18159. /**
  18160. * Clear the current graph and load a new one from a serialization object
  18161. * @param source defines the JSON representation of the material
  18162. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18163. * @param merge defines whether or not the source must be merged or replace the current content
  18164. */
  18165. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18166. /**
  18167. * Makes a duplicate of the current material.
  18168. * @param name - name to use for the new material.
  18169. */
  18170. clone(name: string): NodeMaterial;
  18171. /**
  18172. * Creates a node material from parsed material data
  18173. * @param source defines the JSON representation of the material
  18174. * @param scene defines the hosting scene
  18175. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18176. * @returns a new node material
  18177. */
  18178. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18179. /**
  18180. * Creates a node material from a snippet saved in a remote file
  18181. * @param name defines the name of the material to create
  18182. * @param url defines the url to load from
  18183. * @param scene defines the hosting scene
  18184. * @returns a promise that will resolve to the new node material
  18185. */
  18186. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18187. /**
  18188. * Creates a node material from a snippet saved by the node material editor
  18189. * @param snippetId defines the snippet to load
  18190. * @param scene defines the hosting scene
  18191. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18192. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18193. * @returns a promise that will resolve to the new node material
  18194. */
  18195. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18196. /**
  18197. * Creates a new node material set to default basic configuration
  18198. * @param name defines the name of the material
  18199. * @param scene defines the hosting scene
  18200. * @returns a new NodeMaterial
  18201. */
  18202. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18203. }
  18204. }
  18205. declare module BABYLON {
  18206. interface ThinEngine {
  18207. /**
  18208. * Unbind a list of render target textures from the webGL context
  18209. * This is used only when drawBuffer extension or webGL2 are active
  18210. * @param textures defines the render target textures to unbind
  18211. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18212. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18213. */
  18214. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18215. /**
  18216. * Create a multi render target texture
  18217. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18218. * @param size defines the size of the texture
  18219. * @param options defines the creation options
  18220. * @returns the cube texture as an InternalTexture
  18221. */
  18222. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18223. /**
  18224. * Update the sample count for a given multiple render target texture
  18225. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18226. * @param textures defines the textures to update
  18227. * @param samples defines the sample count to set
  18228. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18229. */
  18230. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18231. /**
  18232. * Select a subsets of attachments to draw to.
  18233. * @param attachments gl attachments
  18234. */
  18235. bindAttachments(attachments: number[]): void;
  18236. /**
  18237. * Creates a layout object to draw/clear on specific textures in a MRT
  18238. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18239. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18240. */
  18241. buildTextureLayout(textureStatus: boolean[]): number[];
  18242. /**
  18243. * Restores the webgl state to only draw on the main color attachment
  18244. */
  18245. restoreSingleAttachment(): void;
  18246. /**
  18247. * Clears a list of attachments
  18248. * @param attachments list of the attachments
  18249. * @param colorMain clear color for the main attachment (the first one)
  18250. * @param colorOthers clear color for the other attachments
  18251. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18252. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18253. */
  18254. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18255. }
  18256. }
  18257. declare module BABYLON {
  18258. /**
  18259. * Creation options of the multi render target texture.
  18260. */
  18261. export interface IMultiRenderTargetOptions {
  18262. /**
  18263. * Define if the texture needs to create mip maps after render.
  18264. */
  18265. generateMipMaps?: boolean;
  18266. /**
  18267. * Define the types of all the draw buffers we want to create
  18268. */
  18269. types?: number[];
  18270. /**
  18271. * Define the sampling modes of all the draw buffers we want to create
  18272. */
  18273. samplingModes?: number[];
  18274. /**
  18275. * Define if a depth buffer is required
  18276. */
  18277. generateDepthBuffer?: boolean;
  18278. /**
  18279. * Define if a stencil buffer is required
  18280. */
  18281. generateStencilBuffer?: boolean;
  18282. /**
  18283. * Define if a depth texture is required instead of a depth buffer
  18284. */
  18285. generateDepthTexture?: boolean;
  18286. /**
  18287. * Define the number of desired draw buffers
  18288. */
  18289. textureCount?: number;
  18290. /**
  18291. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18292. */
  18293. doNotChangeAspectRatio?: boolean;
  18294. /**
  18295. * Define the default type of the buffers we are creating
  18296. */
  18297. defaultType?: number;
  18298. }
  18299. /**
  18300. * A multi render target, like a render target provides the ability to render to a texture.
  18301. * Unlike the render target, it can render to several draw buffers in one draw.
  18302. * This is specially interesting in deferred rendering or for any effects requiring more than
  18303. * just one color from a single pass.
  18304. */
  18305. export class MultiRenderTarget extends RenderTargetTexture {
  18306. private _internalTextures;
  18307. private _textures;
  18308. private _multiRenderTargetOptions;
  18309. private _count;
  18310. /**
  18311. * Get if draw buffers are currently supported by the used hardware and browser.
  18312. */
  18313. get isSupported(): boolean;
  18314. /**
  18315. * Get the list of textures generated by the multi render target.
  18316. */
  18317. get textures(): Texture[];
  18318. /**
  18319. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18320. */
  18321. get count(): number;
  18322. /**
  18323. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18324. */
  18325. get depthTexture(): Texture;
  18326. /**
  18327. * Set the wrapping mode on U of all the textures we are rendering to.
  18328. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18329. */
  18330. set wrapU(wrap: number);
  18331. /**
  18332. * Set the wrapping mode on V of all the textures we are rendering to.
  18333. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18334. */
  18335. set wrapV(wrap: number);
  18336. /**
  18337. * Instantiate a new multi render target texture.
  18338. * A multi render target, like a render target provides the ability to render to a texture.
  18339. * Unlike the render target, it can render to several draw buffers in one draw.
  18340. * This is specially interesting in deferred rendering or for any effects requiring more than
  18341. * just one color from a single pass.
  18342. * @param name Define the name of the texture
  18343. * @param size Define the size of the buffers to render to
  18344. * @param count Define the number of target we are rendering into
  18345. * @param scene Define the scene the texture belongs to
  18346. * @param options Define the options used to create the multi render target
  18347. */
  18348. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18349. private _initTypes;
  18350. /** @hidden */
  18351. _rebuild(forceFullRebuild?: boolean): void;
  18352. private _createInternalTextures;
  18353. private _createTextures;
  18354. /**
  18355. * Replaces a texture within the MRT.
  18356. * @param texture The new texture to insert in the MRT
  18357. * @param index The index of the texture to replace
  18358. */
  18359. replaceTexture(texture: Texture, index: number): void;
  18360. /**
  18361. * Define the number of samples used if MSAA is enabled.
  18362. */
  18363. get samples(): number;
  18364. set samples(value: number);
  18365. /**
  18366. * Resize all the textures in the multi render target.
  18367. * Be careful as it will recreate all the data in the new texture.
  18368. * @param size Define the new size
  18369. */
  18370. resize(size: any): void;
  18371. /**
  18372. * Changes the number of render targets in this MRT
  18373. * Be careful as it will recreate all the data in the new texture.
  18374. * @param count new texture count
  18375. * @param options Specifies texture types and sampling modes for new textures
  18376. */
  18377. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18378. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18379. /**
  18380. * Dispose the render targets and their associated resources
  18381. */
  18382. dispose(): void;
  18383. /**
  18384. * Release all the underlying texture used as draw buffers.
  18385. */
  18386. releaseInternalTextures(): void;
  18387. }
  18388. }
  18389. declare module BABYLON {
  18390. /** @hidden */
  18391. export var imageProcessingPixelShader: {
  18392. name: string;
  18393. shader: string;
  18394. };
  18395. }
  18396. declare module BABYLON {
  18397. /**
  18398. * ImageProcessingPostProcess
  18399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18400. */
  18401. export class ImageProcessingPostProcess extends PostProcess {
  18402. /**
  18403. * Default configuration related to image processing available in the PBR Material.
  18404. */
  18405. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18406. /**
  18407. * Gets the image processing configuration used either in this material.
  18408. */
  18409. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18410. /**
  18411. * Sets the Default image processing configuration used either in the this material.
  18412. *
  18413. * If sets to null, the scene one is in use.
  18414. */
  18415. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18416. /**
  18417. * Keep track of the image processing observer to allow dispose and replace.
  18418. */
  18419. private _imageProcessingObserver;
  18420. /**
  18421. * Attaches a new image processing configuration to the PBR Material.
  18422. * @param configuration
  18423. */
  18424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18425. /**
  18426. * If the post process is supported.
  18427. */
  18428. get isSupported(): boolean;
  18429. /**
  18430. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18431. */
  18432. get colorCurves(): Nullable<ColorCurves>;
  18433. /**
  18434. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18435. */
  18436. set colorCurves(value: Nullable<ColorCurves>);
  18437. /**
  18438. * Gets wether the color curves effect is enabled.
  18439. */
  18440. get colorCurvesEnabled(): boolean;
  18441. /**
  18442. * Sets wether the color curves effect is enabled.
  18443. */
  18444. set colorCurvesEnabled(value: boolean);
  18445. /**
  18446. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18447. */
  18448. get colorGradingTexture(): Nullable<BaseTexture>;
  18449. /**
  18450. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18451. */
  18452. set colorGradingTexture(value: Nullable<BaseTexture>);
  18453. /**
  18454. * Gets wether the color grading effect is enabled.
  18455. */
  18456. get colorGradingEnabled(): boolean;
  18457. /**
  18458. * Gets wether the color grading effect is enabled.
  18459. */
  18460. set colorGradingEnabled(value: boolean);
  18461. /**
  18462. * Gets exposure used in the effect.
  18463. */
  18464. get exposure(): number;
  18465. /**
  18466. * Sets exposure used in the effect.
  18467. */
  18468. set exposure(value: number);
  18469. /**
  18470. * Gets wether tonemapping is enabled or not.
  18471. */
  18472. get toneMappingEnabled(): boolean;
  18473. /**
  18474. * Sets wether tonemapping is enabled or not
  18475. */
  18476. set toneMappingEnabled(value: boolean);
  18477. /**
  18478. * Gets the type of tone mapping effect.
  18479. */
  18480. get toneMappingType(): number;
  18481. /**
  18482. * Sets the type of tone mapping effect.
  18483. */
  18484. set toneMappingType(value: number);
  18485. /**
  18486. * Gets contrast used in the effect.
  18487. */
  18488. get contrast(): number;
  18489. /**
  18490. * Sets contrast used in the effect.
  18491. */
  18492. set contrast(value: number);
  18493. /**
  18494. * Gets Vignette stretch size.
  18495. */
  18496. get vignetteStretch(): number;
  18497. /**
  18498. * Sets Vignette stretch size.
  18499. */
  18500. set vignetteStretch(value: number);
  18501. /**
  18502. * Gets Vignette centre X Offset.
  18503. */
  18504. get vignetteCentreX(): number;
  18505. /**
  18506. * Sets Vignette centre X Offset.
  18507. */
  18508. set vignetteCentreX(value: number);
  18509. /**
  18510. * Gets Vignette centre Y Offset.
  18511. */
  18512. get vignetteCentreY(): number;
  18513. /**
  18514. * Sets Vignette centre Y Offset.
  18515. */
  18516. set vignetteCentreY(value: number);
  18517. /**
  18518. * Gets Vignette weight or intensity of the vignette effect.
  18519. */
  18520. get vignetteWeight(): number;
  18521. /**
  18522. * Sets Vignette weight or intensity of the vignette effect.
  18523. */
  18524. set vignetteWeight(value: number);
  18525. /**
  18526. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18527. * if vignetteEnabled is set to true.
  18528. */
  18529. get vignetteColor(): Color4;
  18530. /**
  18531. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18532. * if vignetteEnabled is set to true.
  18533. */
  18534. set vignetteColor(value: Color4);
  18535. /**
  18536. * Gets Camera field of view used by the Vignette effect.
  18537. */
  18538. get vignetteCameraFov(): number;
  18539. /**
  18540. * Sets Camera field of view used by the Vignette effect.
  18541. */
  18542. set vignetteCameraFov(value: number);
  18543. /**
  18544. * Gets the vignette blend mode allowing different kind of effect.
  18545. */
  18546. get vignetteBlendMode(): number;
  18547. /**
  18548. * Sets the vignette blend mode allowing different kind of effect.
  18549. */
  18550. set vignetteBlendMode(value: number);
  18551. /**
  18552. * Gets wether the vignette effect is enabled.
  18553. */
  18554. get vignetteEnabled(): boolean;
  18555. /**
  18556. * Sets wether the vignette effect is enabled.
  18557. */
  18558. set vignetteEnabled(value: boolean);
  18559. private _fromLinearSpace;
  18560. /**
  18561. * Gets wether the input of the processing is in Gamma or Linear Space.
  18562. */
  18563. get fromLinearSpace(): boolean;
  18564. /**
  18565. * Sets wether the input of the processing is in Gamma or Linear Space.
  18566. */
  18567. set fromLinearSpace(value: boolean);
  18568. /**
  18569. * Defines cache preventing GC.
  18570. */
  18571. private _defines;
  18572. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18573. /**
  18574. * "ImageProcessingPostProcess"
  18575. * @returns "ImageProcessingPostProcess"
  18576. */
  18577. getClassName(): string;
  18578. /**
  18579. * @hidden
  18580. */
  18581. _updateParameters(): void;
  18582. dispose(camera?: Camera): void;
  18583. }
  18584. }
  18585. declare module BABYLON {
  18586. /**
  18587. * Interface for defining prepass effects in the prepass post-process pipeline
  18588. */
  18589. export interface PrePassEffectConfiguration {
  18590. /**
  18591. * Name of the effect
  18592. */
  18593. name: string;
  18594. /**
  18595. * Post process to attach for this effect
  18596. */
  18597. postProcess?: PostProcess;
  18598. /**
  18599. * Textures required in the MRT
  18600. */
  18601. texturesRequired: number[];
  18602. /**
  18603. * Is the effect enabled
  18604. */
  18605. enabled: boolean;
  18606. /**
  18607. * Disposes the effect configuration
  18608. */
  18609. dispose?: () => void;
  18610. /**
  18611. * Creates the associated post process
  18612. */
  18613. createPostProcess?: () => PostProcess;
  18614. }
  18615. }
  18616. declare module BABYLON {
  18617. /**
  18618. * Options to be used when creating a FresnelParameters.
  18619. */
  18620. export type IFresnelParametersCreationOptions = {
  18621. /**
  18622. * Define the color used on edges (grazing angle)
  18623. */
  18624. leftColor?: Color3;
  18625. /**
  18626. * Define the color used on center
  18627. */
  18628. rightColor?: Color3;
  18629. /**
  18630. * Define bias applied to computed fresnel term
  18631. */
  18632. bias?: number;
  18633. /**
  18634. * Defined the power exponent applied to fresnel term
  18635. */
  18636. power?: number;
  18637. /**
  18638. * Define if the fresnel effect is enable or not.
  18639. */
  18640. isEnabled?: boolean;
  18641. };
  18642. /**
  18643. * Serialized format for FresnelParameters.
  18644. */
  18645. export type IFresnelParametersSerialized = {
  18646. /**
  18647. * Define the color used on edges (grazing angle) [as an array]
  18648. */
  18649. leftColor: number[];
  18650. /**
  18651. * Define the color used on center [as an array]
  18652. */
  18653. rightColor: number[];
  18654. /**
  18655. * Define bias applied to computed fresnel term
  18656. */
  18657. bias: number;
  18658. /**
  18659. * Defined the power exponent applied to fresnel term
  18660. */
  18661. power?: number;
  18662. /**
  18663. * Define if the fresnel effect is enable or not.
  18664. */
  18665. isEnabled: boolean;
  18666. };
  18667. /**
  18668. * This represents all the required information to add a fresnel effect on a material:
  18669. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18670. */
  18671. export class FresnelParameters {
  18672. private _isEnabled;
  18673. /**
  18674. * Define if the fresnel effect is enable or not.
  18675. */
  18676. get isEnabled(): boolean;
  18677. set isEnabled(value: boolean);
  18678. /**
  18679. * Define the color used on edges (grazing angle)
  18680. */
  18681. leftColor: Color3;
  18682. /**
  18683. * Define the color used on center
  18684. */
  18685. rightColor: Color3;
  18686. /**
  18687. * Define bias applied to computed fresnel term
  18688. */
  18689. bias: number;
  18690. /**
  18691. * Defined the power exponent applied to fresnel term
  18692. */
  18693. power: number;
  18694. /**
  18695. * Creates a new FresnelParameters object.
  18696. *
  18697. * @param options provide your own settings to optionally to override defaults
  18698. */
  18699. constructor(options?: IFresnelParametersCreationOptions);
  18700. /**
  18701. * Clones the current fresnel and its valuues
  18702. * @returns a clone fresnel configuration
  18703. */
  18704. clone(): FresnelParameters;
  18705. /**
  18706. * Determines equality between FresnelParameters objects
  18707. * @param otherFresnelParameters defines the second operand
  18708. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18709. */
  18710. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18711. /**
  18712. * Serializes the current fresnel parameters to a JSON representation.
  18713. * @return the JSON serialization
  18714. */
  18715. serialize(): IFresnelParametersSerialized;
  18716. /**
  18717. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18718. * @param parsedFresnelParameters Define the JSON representation
  18719. * @returns the parsed parameters
  18720. */
  18721. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18722. }
  18723. }
  18724. declare module BABYLON {
  18725. /**
  18726. * This groups all the flags used to control the materials channel.
  18727. */
  18728. export class MaterialFlags {
  18729. private static _DiffuseTextureEnabled;
  18730. /**
  18731. * Are diffuse textures enabled in the application.
  18732. */
  18733. static get DiffuseTextureEnabled(): boolean;
  18734. static set DiffuseTextureEnabled(value: boolean);
  18735. private static _DetailTextureEnabled;
  18736. /**
  18737. * Are detail textures enabled in the application.
  18738. */
  18739. static get DetailTextureEnabled(): boolean;
  18740. static set DetailTextureEnabled(value: boolean);
  18741. private static _AmbientTextureEnabled;
  18742. /**
  18743. * Are ambient textures enabled in the application.
  18744. */
  18745. static get AmbientTextureEnabled(): boolean;
  18746. static set AmbientTextureEnabled(value: boolean);
  18747. private static _OpacityTextureEnabled;
  18748. /**
  18749. * Are opacity textures enabled in the application.
  18750. */
  18751. static get OpacityTextureEnabled(): boolean;
  18752. static set OpacityTextureEnabled(value: boolean);
  18753. private static _ReflectionTextureEnabled;
  18754. /**
  18755. * Are reflection textures enabled in the application.
  18756. */
  18757. static get ReflectionTextureEnabled(): boolean;
  18758. static set ReflectionTextureEnabled(value: boolean);
  18759. private static _EmissiveTextureEnabled;
  18760. /**
  18761. * Are emissive textures enabled in the application.
  18762. */
  18763. static get EmissiveTextureEnabled(): boolean;
  18764. static set EmissiveTextureEnabled(value: boolean);
  18765. private static _SpecularTextureEnabled;
  18766. /**
  18767. * Are specular textures enabled in the application.
  18768. */
  18769. static get SpecularTextureEnabled(): boolean;
  18770. static set SpecularTextureEnabled(value: boolean);
  18771. private static _BumpTextureEnabled;
  18772. /**
  18773. * Are bump textures enabled in the application.
  18774. */
  18775. static get BumpTextureEnabled(): boolean;
  18776. static set BumpTextureEnabled(value: boolean);
  18777. private static _LightmapTextureEnabled;
  18778. /**
  18779. * Are lightmap textures enabled in the application.
  18780. */
  18781. static get LightmapTextureEnabled(): boolean;
  18782. static set LightmapTextureEnabled(value: boolean);
  18783. private static _RefractionTextureEnabled;
  18784. /**
  18785. * Are refraction textures enabled in the application.
  18786. */
  18787. static get RefractionTextureEnabled(): boolean;
  18788. static set RefractionTextureEnabled(value: boolean);
  18789. private static _ColorGradingTextureEnabled;
  18790. /**
  18791. * Are color grading textures enabled in the application.
  18792. */
  18793. static get ColorGradingTextureEnabled(): boolean;
  18794. static set ColorGradingTextureEnabled(value: boolean);
  18795. private static _FresnelEnabled;
  18796. /**
  18797. * Are fresnels enabled in the application.
  18798. */
  18799. static get FresnelEnabled(): boolean;
  18800. static set FresnelEnabled(value: boolean);
  18801. private static _ClearCoatTextureEnabled;
  18802. /**
  18803. * Are clear coat textures enabled in the application.
  18804. */
  18805. static get ClearCoatTextureEnabled(): boolean;
  18806. static set ClearCoatTextureEnabled(value: boolean);
  18807. private static _ClearCoatBumpTextureEnabled;
  18808. /**
  18809. * Are clear coat bump textures enabled in the application.
  18810. */
  18811. static get ClearCoatBumpTextureEnabled(): boolean;
  18812. static set ClearCoatBumpTextureEnabled(value: boolean);
  18813. private static _ClearCoatTintTextureEnabled;
  18814. /**
  18815. * Are clear coat tint textures enabled in the application.
  18816. */
  18817. static get ClearCoatTintTextureEnabled(): boolean;
  18818. static set ClearCoatTintTextureEnabled(value: boolean);
  18819. private static _SheenTextureEnabled;
  18820. /**
  18821. * Are sheen textures enabled in the application.
  18822. */
  18823. static get SheenTextureEnabled(): boolean;
  18824. static set SheenTextureEnabled(value: boolean);
  18825. private static _AnisotropicTextureEnabled;
  18826. /**
  18827. * Are anisotropic textures enabled in the application.
  18828. */
  18829. static get AnisotropicTextureEnabled(): boolean;
  18830. static set AnisotropicTextureEnabled(value: boolean);
  18831. private static _ThicknessTextureEnabled;
  18832. /**
  18833. * Are thickness textures enabled in the application.
  18834. */
  18835. static get ThicknessTextureEnabled(): boolean;
  18836. static set ThicknessTextureEnabled(value: boolean);
  18837. }
  18838. }
  18839. declare module BABYLON {
  18840. /** @hidden */
  18841. export var defaultFragmentDeclaration: {
  18842. name: string;
  18843. shader: string;
  18844. };
  18845. }
  18846. declare module BABYLON {
  18847. /** @hidden */
  18848. export var sceneUboDeclaration: {
  18849. name: string;
  18850. shader: string;
  18851. };
  18852. }
  18853. declare module BABYLON {
  18854. /** @hidden */
  18855. export var meshUboDeclaration: {
  18856. name: string;
  18857. shader: string;
  18858. };
  18859. }
  18860. declare module BABYLON {
  18861. /** @hidden */
  18862. export var defaultUboDeclaration: {
  18863. name: string;
  18864. shader: string;
  18865. };
  18866. }
  18867. declare module BABYLON {
  18868. /** @hidden */
  18869. export var prePassDeclaration: {
  18870. name: string;
  18871. shader: string;
  18872. };
  18873. }
  18874. declare module BABYLON {
  18875. /** @hidden */
  18876. export var lightFragmentDeclaration: {
  18877. name: string;
  18878. shader: string;
  18879. };
  18880. }
  18881. declare module BABYLON {
  18882. /** @hidden */
  18883. export var lightUboDeclaration: {
  18884. name: string;
  18885. shader: string;
  18886. };
  18887. }
  18888. declare module BABYLON {
  18889. /** @hidden */
  18890. export var lightsFragmentFunctions: {
  18891. name: string;
  18892. shader: string;
  18893. };
  18894. }
  18895. declare module BABYLON {
  18896. /** @hidden */
  18897. export var shadowsFragmentFunctions: {
  18898. name: string;
  18899. shader: string;
  18900. };
  18901. }
  18902. declare module BABYLON {
  18903. /** @hidden */
  18904. export var fresnelFunction: {
  18905. name: string;
  18906. shader: string;
  18907. };
  18908. }
  18909. declare module BABYLON {
  18910. /** @hidden */
  18911. export var bumpFragmentMainFunctions: {
  18912. name: string;
  18913. shader: string;
  18914. };
  18915. }
  18916. declare module BABYLON {
  18917. /** @hidden */
  18918. export var bumpFragmentFunctions: {
  18919. name: string;
  18920. shader: string;
  18921. };
  18922. }
  18923. declare module BABYLON {
  18924. /** @hidden */
  18925. export var logDepthDeclaration: {
  18926. name: string;
  18927. shader: string;
  18928. };
  18929. }
  18930. declare module BABYLON {
  18931. /** @hidden */
  18932. export var fogFragmentDeclaration: {
  18933. name: string;
  18934. shader: string;
  18935. };
  18936. }
  18937. declare module BABYLON {
  18938. /** @hidden */
  18939. export var bumpFragment: {
  18940. name: string;
  18941. shader: string;
  18942. };
  18943. }
  18944. declare module BABYLON {
  18945. /** @hidden */
  18946. export var depthPrePass: {
  18947. name: string;
  18948. shader: string;
  18949. };
  18950. }
  18951. declare module BABYLON {
  18952. /** @hidden */
  18953. export var lightFragment: {
  18954. name: string;
  18955. shader: string;
  18956. };
  18957. }
  18958. declare module BABYLON {
  18959. /** @hidden */
  18960. export var logDepthFragment: {
  18961. name: string;
  18962. shader: string;
  18963. };
  18964. }
  18965. declare module BABYLON {
  18966. /** @hidden */
  18967. export var fogFragment: {
  18968. name: string;
  18969. shader: string;
  18970. };
  18971. }
  18972. declare module BABYLON {
  18973. /** @hidden */
  18974. export var defaultPixelShader: {
  18975. name: string;
  18976. shader: string;
  18977. };
  18978. }
  18979. declare module BABYLON {
  18980. /** @hidden */
  18981. export var defaultVertexDeclaration: {
  18982. name: string;
  18983. shader: string;
  18984. };
  18985. }
  18986. declare module BABYLON {
  18987. /** @hidden */
  18988. export var bonesDeclaration: {
  18989. name: string;
  18990. shader: string;
  18991. };
  18992. }
  18993. declare module BABYLON {
  18994. /** @hidden */
  18995. export var prePassVertexDeclaration: {
  18996. name: string;
  18997. shader: string;
  18998. };
  18999. }
  19000. declare module BABYLON {
  19001. /** @hidden */
  19002. export var bumpVertexDeclaration: {
  19003. name: string;
  19004. shader: string;
  19005. };
  19006. }
  19007. declare module BABYLON {
  19008. /** @hidden */
  19009. export var fogVertexDeclaration: {
  19010. name: string;
  19011. shader: string;
  19012. };
  19013. }
  19014. declare module BABYLON {
  19015. /** @hidden */
  19016. export var lightVxFragmentDeclaration: {
  19017. name: string;
  19018. shader: string;
  19019. };
  19020. }
  19021. declare module BABYLON {
  19022. /** @hidden */
  19023. export var lightVxUboDeclaration: {
  19024. name: string;
  19025. shader: string;
  19026. };
  19027. }
  19028. declare module BABYLON {
  19029. /** @hidden */
  19030. export var morphTargetsVertexGlobalDeclaration: {
  19031. name: string;
  19032. shader: string;
  19033. };
  19034. }
  19035. declare module BABYLON {
  19036. /** @hidden */
  19037. export var morphTargetsVertexDeclaration: {
  19038. name: string;
  19039. shader: string;
  19040. };
  19041. }
  19042. declare module BABYLON {
  19043. /** @hidden */
  19044. export var morphTargetsVertex: {
  19045. name: string;
  19046. shader: string;
  19047. };
  19048. }
  19049. declare module BABYLON {
  19050. /** @hidden */
  19051. export var instancesVertex: {
  19052. name: string;
  19053. shader: string;
  19054. };
  19055. }
  19056. declare module BABYLON {
  19057. /** @hidden */
  19058. export var bonesVertex: {
  19059. name: string;
  19060. shader: string;
  19061. };
  19062. }
  19063. declare module BABYLON {
  19064. /** @hidden */
  19065. export var prePassVertex: {
  19066. name: string;
  19067. shader: string;
  19068. };
  19069. }
  19070. declare module BABYLON {
  19071. /** @hidden */
  19072. export var bumpVertex: {
  19073. name: string;
  19074. shader: string;
  19075. };
  19076. }
  19077. declare module BABYLON {
  19078. /** @hidden */
  19079. export var fogVertex: {
  19080. name: string;
  19081. shader: string;
  19082. };
  19083. }
  19084. declare module BABYLON {
  19085. /** @hidden */
  19086. export var shadowsVertex: {
  19087. name: string;
  19088. shader: string;
  19089. };
  19090. }
  19091. declare module BABYLON {
  19092. /** @hidden */
  19093. export var pointCloudVertex: {
  19094. name: string;
  19095. shader: string;
  19096. };
  19097. }
  19098. declare module BABYLON {
  19099. /** @hidden */
  19100. export var logDepthVertex: {
  19101. name: string;
  19102. shader: string;
  19103. };
  19104. }
  19105. declare module BABYLON {
  19106. /** @hidden */
  19107. export var defaultVertexShader: {
  19108. name: string;
  19109. shader: string;
  19110. };
  19111. }
  19112. declare module BABYLON {
  19113. /**
  19114. * @hidden
  19115. */
  19116. export interface IMaterialDetailMapDefines {
  19117. DETAIL: boolean;
  19118. DETAILDIRECTUV: number;
  19119. DETAIL_NORMALBLENDMETHOD: number;
  19120. /** @hidden */
  19121. _areTexturesDirty: boolean;
  19122. }
  19123. /**
  19124. * Define the code related to the detail map parameters of a material
  19125. *
  19126. * Inspired from:
  19127. * 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
  19128. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19129. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19130. */
  19131. export class DetailMapConfiguration {
  19132. private _texture;
  19133. /**
  19134. * The detail texture of the material.
  19135. */
  19136. texture: Nullable<BaseTexture>;
  19137. /**
  19138. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19139. * Bigger values mean stronger blending
  19140. */
  19141. diffuseBlendLevel: number;
  19142. /**
  19143. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19144. * Bigger values mean stronger blending. Only used with PBR materials
  19145. */
  19146. roughnessBlendLevel: number;
  19147. /**
  19148. * Defines how strong the bump effect from the detail map is
  19149. * Bigger values mean stronger effect
  19150. */
  19151. bumpLevel: number;
  19152. private _normalBlendMethod;
  19153. /**
  19154. * The method used to blend the bump and detail normals together
  19155. */
  19156. normalBlendMethod: number;
  19157. private _isEnabled;
  19158. /**
  19159. * Enable or disable the detail map on this material
  19160. */
  19161. isEnabled: boolean;
  19162. /** @hidden */
  19163. private _internalMarkAllSubMeshesAsTexturesDirty;
  19164. /** @hidden */
  19165. _markAllSubMeshesAsTexturesDirty(): void;
  19166. /**
  19167. * Instantiate a new detail map
  19168. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19169. */
  19170. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19171. /**
  19172. * Gets whether the submesh is ready to be used or not.
  19173. * @param defines the list of "defines" to update.
  19174. * @param scene defines the scene the material belongs to.
  19175. * @returns - boolean indicating that the submesh is ready or not.
  19176. */
  19177. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19178. /**
  19179. * Update the defines for detail map usage
  19180. * @param defines the list of "defines" to update.
  19181. * @param scene defines the scene the material belongs to.
  19182. */
  19183. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19184. /**
  19185. * Binds the material data.
  19186. * @param uniformBuffer defines the Uniform buffer to fill in.
  19187. * @param scene defines the scene the material belongs to.
  19188. * @param isFrozen defines whether the material is frozen or not.
  19189. */
  19190. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19191. /**
  19192. * Checks to see if a texture is used in the material.
  19193. * @param texture - Base texture to use.
  19194. * @returns - Boolean specifying if a texture is used in the material.
  19195. */
  19196. hasTexture(texture: BaseTexture): boolean;
  19197. /**
  19198. * Returns an array of the actively used textures.
  19199. * @param activeTextures Array of BaseTextures
  19200. */
  19201. getActiveTextures(activeTextures: BaseTexture[]): void;
  19202. /**
  19203. * Returns the animatable textures.
  19204. * @param animatables Array of animatable textures.
  19205. */
  19206. getAnimatables(animatables: IAnimatable[]): void;
  19207. /**
  19208. * Disposes the resources of the material.
  19209. * @param forceDisposeTextures - Forces the disposal of all textures.
  19210. */
  19211. dispose(forceDisposeTextures?: boolean): void;
  19212. /**
  19213. * Get the current class name useful for serialization or dynamic coding.
  19214. * @returns "DetailMap"
  19215. */
  19216. getClassName(): string;
  19217. /**
  19218. * Add the required uniforms to the current list.
  19219. * @param uniforms defines the current uniform list.
  19220. */
  19221. static AddUniforms(uniforms: string[]): void;
  19222. /**
  19223. * Add the required samplers to the current list.
  19224. * @param samplers defines the current sampler list.
  19225. */
  19226. static AddSamplers(samplers: string[]): void;
  19227. /**
  19228. * Add the required uniforms to the current buffer.
  19229. * @param uniformBuffer defines the current uniform buffer.
  19230. */
  19231. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19232. /**
  19233. * Makes a duplicate of the current instance into another one.
  19234. * @param detailMap define the instance where to copy the info
  19235. */
  19236. copyTo(detailMap: DetailMapConfiguration): void;
  19237. /**
  19238. * Serializes this detail map instance
  19239. * @returns - An object with the serialized instance.
  19240. */
  19241. serialize(): any;
  19242. /**
  19243. * Parses a detail map setting from a serialized object.
  19244. * @param source - Serialized object.
  19245. * @param scene Defines the scene we are parsing for
  19246. * @param rootUrl Defines the rootUrl to load from
  19247. */
  19248. parse(source: any, scene: Scene, rootUrl: string): void;
  19249. }
  19250. }
  19251. declare module BABYLON {
  19252. /** @hidden */
  19253. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19254. MAINUV1: boolean;
  19255. MAINUV2: boolean;
  19256. DIFFUSE: boolean;
  19257. DIFFUSEDIRECTUV: number;
  19258. DETAIL: boolean;
  19259. DETAILDIRECTUV: number;
  19260. DETAIL_NORMALBLENDMETHOD: number;
  19261. AMBIENT: boolean;
  19262. AMBIENTDIRECTUV: number;
  19263. OPACITY: boolean;
  19264. OPACITYDIRECTUV: number;
  19265. OPACITYRGB: boolean;
  19266. REFLECTION: boolean;
  19267. EMISSIVE: boolean;
  19268. EMISSIVEDIRECTUV: number;
  19269. SPECULAR: boolean;
  19270. SPECULARDIRECTUV: number;
  19271. BUMP: boolean;
  19272. BUMPDIRECTUV: number;
  19273. PARALLAX: boolean;
  19274. PARALLAXOCCLUSION: boolean;
  19275. SPECULAROVERALPHA: boolean;
  19276. CLIPPLANE: boolean;
  19277. CLIPPLANE2: boolean;
  19278. CLIPPLANE3: boolean;
  19279. CLIPPLANE4: boolean;
  19280. CLIPPLANE5: boolean;
  19281. CLIPPLANE6: boolean;
  19282. ALPHATEST: boolean;
  19283. DEPTHPREPASS: boolean;
  19284. ALPHAFROMDIFFUSE: boolean;
  19285. POINTSIZE: boolean;
  19286. FOG: boolean;
  19287. SPECULARTERM: boolean;
  19288. DIFFUSEFRESNEL: boolean;
  19289. OPACITYFRESNEL: boolean;
  19290. REFLECTIONFRESNEL: boolean;
  19291. REFRACTIONFRESNEL: boolean;
  19292. EMISSIVEFRESNEL: boolean;
  19293. FRESNEL: boolean;
  19294. NORMAL: boolean;
  19295. UV1: boolean;
  19296. UV2: boolean;
  19297. VERTEXCOLOR: boolean;
  19298. VERTEXALPHA: boolean;
  19299. NUM_BONE_INFLUENCERS: number;
  19300. BonesPerMesh: number;
  19301. BONETEXTURE: boolean;
  19302. BONES_VELOCITY_ENABLED: boolean;
  19303. INSTANCES: boolean;
  19304. THIN_INSTANCES: boolean;
  19305. GLOSSINESS: boolean;
  19306. ROUGHNESS: boolean;
  19307. EMISSIVEASILLUMINATION: boolean;
  19308. LINKEMISSIVEWITHDIFFUSE: boolean;
  19309. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19310. LIGHTMAP: boolean;
  19311. LIGHTMAPDIRECTUV: number;
  19312. OBJECTSPACE_NORMALMAP: boolean;
  19313. USELIGHTMAPASSHADOWMAP: boolean;
  19314. REFLECTIONMAP_3D: boolean;
  19315. REFLECTIONMAP_SPHERICAL: boolean;
  19316. REFLECTIONMAP_PLANAR: boolean;
  19317. REFLECTIONMAP_CUBIC: boolean;
  19318. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19319. REFLECTIONMAP_PROJECTION: boolean;
  19320. REFLECTIONMAP_SKYBOX: boolean;
  19321. REFLECTIONMAP_EXPLICIT: boolean;
  19322. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19323. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19324. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19325. INVERTCUBICMAP: boolean;
  19326. LOGARITHMICDEPTH: boolean;
  19327. REFRACTION: boolean;
  19328. REFRACTIONMAP_3D: boolean;
  19329. REFLECTIONOVERALPHA: boolean;
  19330. TWOSIDEDLIGHTING: boolean;
  19331. SHADOWFLOAT: boolean;
  19332. MORPHTARGETS: boolean;
  19333. MORPHTARGETS_NORMAL: boolean;
  19334. MORPHTARGETS_TANGENT: boolean;
  19335. MORPHTARGETS_UV: boolean;
  19336. NUM_MORPH_INFLUENCERS: number;
  19337. NONUNIFORMSCALING: boolean;
  19338. PREMULTIPLYALPHA: boolean;
  19339. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19340. ALPHABLEND: boolean;
  19341. PREPASS: boolean;
  19342. PREPASS_IRRADIANCE: boolean;
  19343. PREPASS_IRRADIANCE_INDEX: number;
  19344. PREPASS_ALBEDO: boolean;
  19345. PREPASS_ALBEDO_INDEX: number;
  19346. PREPASS_DEPTHNORMAL: boolean;
  19347. PREPASS_DEPTHNORMAL_INDEX: number;
  19348. PREPASS_POSITION: boolean;
  19349. PREPASS_POSITION_INDEX: number;
  19350. PREPASS_VELOCITY: boolean;
  19351. PREPASS_VELOCITY_INDEX: number;
  19352. PREPASS_REFLECTIVITY: boolean;
  19353. PREPASS_REFLECTIVITY_INDEX: number;
  19354. SCENE_MRT_COUNT: number;
  19355. RGBDLIGHTMAP: boolean;
  19356. RGBDREFLECTION: boolean;
  19357. RGBDREFRACTION: boolean;
  19358. IMAGEPROCESSING: boolean;
  19359. VIGNETTE: boolean;
  19360. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19361. VIGNETTEBLENDMODEOPAQUE: boolean;
  19362. TONEMAPPING: boolean;
  19363. TONEMAPPING_ACES: boolean;
  19364. CONTRAST: boolean;
  19365. COLORCURVES: boolean;
  19366. COLORGRADING: boolean;
  19367. COLORGRADING3D: boolean;
  19368. SAMPLER3DGREENDEPTH: boolean;
  19369. SAMPLER3DBGRMAP: boolean;
  19370. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19371. MULTIVIEW: boolean;
  19372. /**
  19373. * If the reflection texture on this material is in linear color space
  19374. * @hidden
  19375. */
  19376. IS_REFLECTION_LINEAR: boolean;
  19377. /**
  19378. * If the refraction texture on this material is in linear color space
  19379. * @hidden
  19380. */
  19381. IS_REFRACTION_LINEAR: boolean;
  19382. EXPOSURE: boolean;
  19383. constructor();
  19384. setReflectionMode(modeToEnable: string): void;
  19385. }
  19386. /**
  19387. * This is the default material used in Babylon. It is the best trade off between quality
  19388. * and performances.
  19389. * @see https://doc.babylonjs.com/babylon101/materials
  19390. */
  19391. export class StandardMaterial extends PushMaterial {
  19392. private _diffuseTexture;
  19393. /**
  19394. * The basic texture of the material as viewed under a light.
  19395. */
  19396. diffuseTexture: Nullable<BaseTexture>;
  19397. private _ambientTexture;
  19398. /**
  19399. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19400. */
  19401. ambientTexture: Nullable<BaseTexture>;
  19402. private _opacityTexture;
  19403. /**
  19404. * Define the transparency of the material from a texture.
  19405. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19406. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19407. */
  19408. opacityTexture: Nullable<BaseTexture>;
  19409. private _reflectionTexture;
  19410. /**
  19411. * Define the texture used to display the reflection.
  19412. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19413. */
  19414. reflectionTexture: Nullable<BaseTexture>;
  19415. private _emissiveTexture;
  19416. /**
  19417. * Define texture of the material as if self lit.
  19418. * This will be mixed in the final result even in the absence of light.
  19419. */
  19420. emissiveTexture: Nullable<BaseTexture>;
  19421. private _specularTexture;
  19422. /**
  19423. * Define how the color and intensity of the highlight given by the light in the material.
  19424. */
  19425. specularTexture: Nullable<BaseTexture>;
  19426. private _bumpTexture;
  19427. /**
  19428. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19429. * 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.
  19430. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19431. */
  19432. bumpTexture: Nullable<BaseTexture>;
  19433. private _lightmapTexture;
  19434. /**
  19435. * Complex lighting can be computationally expensive to compute at runtime.
  19436. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19437. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19438. */
  19439. lightmapTexture: Nullable<BaseTexture>;
  19440. private _refractionTexture;
  19441. /**
  19442. * Define the texture used to display the refraction.
  19443. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19444. */
  19445. refractionTexture: Nullable<BaseTexture>;
  19446. /**
  19447. * The color of the material lit by the environmental background lighting.
  19448. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19449. */
  19450. ambientColor: Color3;
  19451. /**
  19452. * The basic color of the material as viewed under a light.
  19453. */
  19454. diffuseColor: Color3;
  19455. /**
  19456. * Define how the color and intensity of the highlight given by the light in the material.
  19457. */
  19458. specularColor: Color3;
  19459. /**
  19460. * Define the color of the material as if self lit.
  19461. * This will be mixed in the final result even in the absence of light.
  19462. */
  19463. emissiveColor: Color3;
  19464. /**
  19465. * Defines how sharp are the highlights in the material.
  19466. * The bigger the value the sharper giving a more glossy feeling to the result.
  19467. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19468. */
  19469. specularPower: number;
  19470. private _useAlphaFromDiffuseTexture;
  19471. /**
  19472. * Does the transparency come from the diffuse texture alpha channel.
  19473. */
  19474. useAlphaFromDiffuseTexture: boolean;
  19475. private _useEmissiveAsIllumination;
  19476. /**
  19477. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19478. */
  19479. useEmissiveAsIllumination: boolean;
  19480. private _linkEmissiveWithDiffuse;
  19481. /**
  19482. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19483. * the emissive level when the final color is close to one.
  19484. */
  19485. linkEmissiveWithDiffuse: boolean;
  19486. private _useSpecularOverAlpha;
  19487. /**
  19488. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19489. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19490. */
  19491. useSpecularOverAlpha: boolean;
  19492. private _useReflectionOverAlpha;
  19493. /**
  19494. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19495. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19496. */
  19497. useReflectionOverAlpha: boolean;
  19498. private _disableLighting;
  19499. /**
  19500. * Does lights from the scene impacts this material.
  19501. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19502. */
  19503. disableLighting: boolean;
  19504. private _useObjectSpaceNormalMap;
  19505. /**
  19506. * Allows using an object space normal map (instead of tangent space).
  19507. */
  19508. useObjectSpaceNormalMap: boolean;
  19509. private _useParallax;
  19510. /**
  19511. * Is parallax enabled or not.
  19512. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19513. */
  19514. useParallax: boolean;
  19515. private _useParallaxOcclusion;
  19516. /**
  19517. * Is parallax occlusion enabled or not.
  19518. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19519. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19520. */
  19521. useParallaxOcclusion: boolean;
  19522. /**
  19523. * 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.
  19524. */
  19525. parallaxScaleBias: number;
  19526. private _roughness;
  19527. /**
  19528. * Helps to define how blurry the reflections should appears in the material.
  19529. */
  19530. roughness: number;
  19531. /**
  19532. * In case of refraction, define the value of the index of refraction.
  19533. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19534. */
  19535. indexOfRefraction: number;
  19536. /**
  19537. * Invert the refraction texture alongside the y axis.
  19538. * It can be useful with procedural textures or probe for instance.
  19539. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19540. */
  19541. invertRefractionY: boolean;
  19542. /**
  19543. * Defines the alpha limits in alpha test mode.
  19544. */
  19545. alphaCutOff: number;
  19546. private _useLightmapAsShadowmap;
  19547. /**
  19548. * In case of light mapping, define whether the map contains light or shadow informations.
  19549. */
  19550. useLightmapAsShadowmap: boolean;
  19551. private _diffuseFresnelParameters;
  19552. /**
  19553. * Define the diffuse fresnel parameters of the material.
  19554. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19555. */
  19556. diffuseFresnelParameters: FresnelParameters;
  19557. private _opacityFresnelParameters;
  19558. /**
  19559. * Define the opacity fresnel parameters of the material.
  19560. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19561. */
  19562. opacityFresnelParameters: FresnelParameters;
  19563. private _reflectionFresnelParameters;
  19564. /**
  19565. * Define the reflection fresnel parameters of the material.
  19566. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19567. */
  19568. reflectionFresnelParameters: FresnelParameters;
  19569. private _refractionFresnelParameters;
  19570. /**
  19571. * Define the refraction fresnel parameters of the material.
  19572. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19573. */
  19574. refractionFresnelParameters: FresnelParameters;
  19575. private _emissiveFresnelParameters;
  19576. /**
  19577. * Define the emissive fresnel parameters of the material.
  19578. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19579. */
  19580. emissiveFresnelParameters: FresnelParameters;
  19581. private _useReflectionFresnelFromSpecular;
  19582. /**
  19583. * If true automatically deducts the fresnels values from the material specularity.
  19584. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19585. */
  19586. useReflectionFresnelFromSpecular: boolean;
  19587. private _useGlossinessFromSpecularMapAlpha;
  19588. /**
  19589. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19590. */
  19591. useGlossinessFromSpecularMapAlpha: boolean;
  19592. private _maxSimultaneousLights;
  19593. /**
  19594. * Defines the maximum number of lights that can be used in the material
  19595. */
  19596. maxSimultaneousLights: number;
  19597. private _invertNormalMapX;
  19598. /**
  19599. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19600. */
  19601. invertNormalMapX: boolean;
  19602. private _invertNormalMapY;
  19603. /**
  19604. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19605. */
  19606. invertNormalMapY: boolean;
  19607. private _twoSidedLighting;
  19608. /**
  19609. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19610. */
  19611. twoSidedLighting: boolean;
  19612. /**
  19613. * Default configuration related to image processing available in the standard Material.
  19614. */
  19615. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19616. /**
  19617. * Gets the image processing configuration used either in this material.
  19618. */
  19619. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19620. /**
  19621. * Sets the Default image processing configuration used either in the this material.
  19622. *
  19623. * If sets to null, the scene one is in use.
  19624. */
  19625. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19626. /**
  19627. * Keep track of the image processing observer to allow dispose and replace.
  19628. */
  19629. private _imageProcessingObserver;
  19630. /**
  19631. * Attaches a new image processing configuration to the Standard Material.
  19632. * @param configuration
  19633. */
  19634. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19635. /**
  19636. * Defines additionnal PrePass parameters for the material.
  19637. */
  19638. readonly prePassConfiguration: PrePassConfiguration;
  19639. /**
  19640. * Gets wether the color curves effect is enabled.
  19641. */
  19642. get cameraColorCurvesEnabled(): boolean;
  19643. /**
  19644. * Sets wether the color curves effect is enabled.
  19645. */
  19646. set cameraColorCurvesEnabled(value: boolean);
  19647. /**
  19648. * Gets wether the color grading effect is enabled.
  19649. */
  19650. get cameraColorGradingEnabled(): boolean;
  19651. /**
  19652. * Gets wether the color grading effect is enabled.
  19653. */
  19654. set cameraColorGradingEnabled(value: boolean);
  19655. /**
  19656. * Gets wether tonemapping is enabled or not.
  19657. */
  19658. get cameraToneMappingEnabled(): boolean;
  19659. /**
  19660. * Sets wether tonemapping is enabled or not
  19661. */
  19662. set cameraToneMappingEnabled(value: boolean);
  19663. /**
  19664. * The camera exposure used on this material.
  19665. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19666. * This corresponds to a photographic exposure.
  19667. */
  19668. get cameraExposure(): number;
  19669. /**
  19670. * The camera exposure used on this material.
  19671. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19672. * This corresponds to a photographic exposure.
  19673. */
  19674. set cameraExposure(value: number);
  19675. /**
  19676. * Gets The camera contrast used on this material.
  19677. */
  19678. get cameraContrast(): number;
  19679. /**
  19680. * Sets The camera contrast used on this material.
  19681. */
  19682. set cameraContrast(value: number);
  19683. /**
  19684. * Gets the Color Grading 2D Lookup Texture.
  19685. */
  19686. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19687. /**
  19688. * Sets the Color Grading 2D Lookup Texture.
  19689. */
  19690. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19691. /**
  19692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19694. * 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;
  19695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19696. */
  19697. get cameraColorCurves(): Nullable<ColorCurves>;
  19698. /**
  19699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19701. * 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;
  19702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19703. */
  19704. set cameraColorCurves(value: Nullable<ColorCurves>);
  19705. /**
  19706. * Can this material render to several textures at once
  19707. */
  19708. get canRenderToMRT(): boolean;
  19709. /**
  19710. * Defines the detail map parameters for the material.
  19711. */
  19712. readonly detailMap: DetailMapConfiguration;
  19713. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19714. protected _worldViewProjectionMatrix: Matrix;
  19715. protected _globalAmbientColor: Color3;
  19716. protected _useLogarithmicDepth: boolean;
  19717. protected _rebuildInParallel: boolean;
  19718. /**
  19719. * Instantiates a new standard material.
  19720. * This is the default material used in Babylon. It is the best trade off between quality
  19721. * and performances.
  19722. * @see https://doc.babylonjs.com/babylon101/materials
  19723. * @param name Define the name of the material in the scene
  19724. * @param scene Define the scene the material belong to
  19725. */
  19726. constructor(name: string, scene: Scene);
  19727. /**
  19728. * Gets a boolean indicating that current material needs to register RTT
  19729. */
  19730. get hasRenderTargetTextures(): boolean;
  19731. /**
  19732. * Gets the current class name of the material e.g. "StandardMaterial"
  19733. * Mainly use in serialization.
  19734. * @returns the class name
  19735. */
  19736. getClassName(): string;
  19737. /**
  19738. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19739. * You can try switching to logarithmic depth.
  19740. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19741. */
  19742. get useLogarithmicDepth(): boolean;
  19743. set useLogarithmicDepth(value: boolean);
  19744. /**
  19745. * Specifies if the material will require alpha blending
  19746. * @returns a boolean specifying if alpha blending is needed
  19747. */
  19748. needAlphaBlending(): boolean;
  19749. /**
  19750. * Specifies if this material should be rendered in alpha test mode
  19751. * @returns a boolean specifying if an alpha test is needed.
  19752. */
  19753. needAlphaTesting(): boolean;
  19754. /**
  19755. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19756. */
  19757. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19758. /**
  19759. * Specifies whether or not there is a usable alpha channel for transparency.
  19760. */
  19761. protected _hasAlphaChannel(): boolean;
  19762. /**
  19763. * Get the texture used for alpha test purpose.
  19764. * @returns the diffuse texture in case of the standard material.
  19765. */
  19766. getAlphaTestTexture(): Nullable<BaseTexture>;
  19767. /**
  19768. * Get if the submesh is ready to be used and all its information available.
  19769. * Child classes can use it to update shaders
  19770. * @param mesh defines the mesh to check
  19771. * @param subMesh defines which submesh to check
  19772. * @param useInstances specifies that instances should be used
  19773. * @returns a boolean indicating that the submesh is ready or not
  19774. */
  19775. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19776. /**
  19777. * Builds the material UBO layouts.
  19778. * Used internally during the effect preparation.
  19779. */
  19780. buildUniformLayout(): void;
  19781. /**
  19782. * Unbinds the material from the mesh
  19783. */
  19784. unbind(): void;
  19785. /**
  19786. * Binds the submesh to this material by preparing the effect and shader to draw
  19787. * @param world defines the world transformation matrix
  19788. * @param mesh defines the mesh containing the submesh
  19789. * @param subMesh defines the submesh to bind the material to
  19790. */
  19791. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19792. /**
  19793. * Get the list of animatables in the material.
  19794. * @returns the list of animatables object used in the material
  19795. */
  19796. getAnimatables(): IAnimatable[];
  19797. /**
  19798. * Gets the active textures from the material
  19799. * @returns an array of textures
  19800. */
  19801. getActiveTextures(): BaseTexture[];
  19802. /**
  19803. * Specifies if the material uses a texture
  19804. * @param texture defines the texture to check against the material
  19805. * @returns a boolean specifying if the material uses the texture
  19806. */
  19807. hasTexture(texture: BaseTexture): boolean;
  19808. /**
  19809. * Disposes the material
  19810. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19811. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19812. */
  19813. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19814. /**
  19815. * Makes a duplicate of the material, and gives it a new name
  19816. * @param name defines the new name for the duplicated material
  19817. * @returns the cloned material
  19818. */
  19819. clone(name: string): StandardMaterial;
  19820. /**
  19821. * Serializes this material in a JSON representation
  19822. * @returns the serialized material object
  19823. */
  19824. serialize(): any;
  19825. /**
  19826. * Creates a standard material from parsed material data
  19827. * @param source defines the JSON representation of the material
  19828. * @param scene defines the hosting scene
  19829. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19830. * @returns a new standard material
  19831. */
  19832. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19833. /**
  19834. * Are diffuse textures enabled in the application.
  19835. */
  19836. static get DiffuseTextureEnabled(): boolean;
  19837. static set DiffuseTextureEnabled(value: boolean);
  19838. /**
  19839. * Are detail textures enabled in the application.
  19840. */
  19841. static get DetailTextureEnabled(): boolean;
  19842. static set DetailTextureEnabled(value: boolean);
  19843. /**
  19844. * Are ambient textures enabled in the application.
  19845. */
  19846. static get AmbientTextureEnabled(): boolean;
  19847. static set AmbientTextureEnabled(value: boolean);
  19848. /**
  19849. * Are opacity textures enabled in the application.
  19850. */
  19851. static get OpacityTextureEnabled(): boolean;
  19852. static set OpacityTextureEnabled(value: boolean);
  19853. /**
  19854. * Are reflection textures enabled in the application.
  19855. */
  19856. static get ReflectionTextureEnabled(): boolean;
  19857. static set ReflectionTextureEnabled(value: boolean);
  19858. /**
  19859. * Are emissive textures enabled in the application.
  19860. */
  19861. static get EmissiveTextureEnabled(): boolean;
  19862. static set EmissiveTextureEnabled(value: boolean);
  19863. /**
  19864. * Are specular textures enabled in the application.
  19865. */
  19866. static get SpecularTextureEnabled(): boolean;
  19867. static set SpecularTextureEnabled(value: boolean);
  19868. /**
  19869. * Are bump textures enabled in the application.
  19870. */
  19871. static get BumpTextureEnabled(): boolean;
  19872. static set BumpTextureEnabled(value: boolean);
  19873. /**
  19874. * Are lightmap textures enabled in the application.
  19875. */
  19876. static get LightmapTextureEnabled(): boolean;
  19877. static set LightmapTextureEnabled(value: boolean);
  19878. /**
  19879. * Are refraction textures enabled in the application.
  19880. */
  19881. static get RefractionTextureEnabled(): boolean;
  19882. static set RefractionTextureEnabled(value: boolean);
  19883. /**
  19884. * Are color grading textures enabled in the application.
  19885. */
  19886. static get ColorGradingTextureEnabled(): boolean;
  19887. static set ColorGradingTextureEnabled(value: boolean);
  19888. /**
  19889. * Are fresnels enabled in the application.
  19890. */
  19891. static get FresnelEnabled(): boolean;
  19892. static set FresnelEnabled(value: boolean);
  19893. }
  19894. }
  19895. declare module BABYLON {
  19896. /** @hidden */
  19897. export var rgbdDecodePixelShader: {
  19898. name: string;
  19899. shader: string;
  19900. };
  19901. }
  19902. declare module BABYLON {
  19903. /** @hidden */
  19904. export var passPixelShader: {
  19905. name: string;
  19906. shader: string;
  19907. };
  19908. }
  19909. declare module BABYLON {
  19910. /** @hidden */
  19911. export var passCubePixelShader: {
  19912. name: string;
  19913. shader: string;
  19914. };
  19915. }
  19916. declare module BABYLON {
  19917. /**
  19918. * PassPostProcess which produces an output the same as it's input
  19919. */
  19920. export class PassPostProcess extends PostProcess {
  19921. /**
  19922. * Gets a string identifying the name of the class
  19923. * @returns "PassPostProcess" string
  19924. */
  19925. getClassName(): string;
  19926. /**
  19927. * Creates the PassPostProcess
  19928. * @param name The name of the effect.
  19929. * @param options The required width/height ratio to downsize to before computing the render pass.
  19930. * @param camera The camera to apply the render pass to.
  19931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19932. * @param engine The engine which the post process will be applied. (default: current engine)
  19933. * @param reusable If the post process can be reused on the same frame. (default: false)
  19934. * @param textureType The type of texture to be used when performing the post processing.
  19935. * @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)
  19936. */
  19937. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19938. /** @hidden */
  19939. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  19940. }
  19941. /**
  19942. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  19943. */
  19944. export class PassCubePostProcess extends PostProcess {
  19945. private _face;
  19946. /**
  19947. * Gets or sets the cube face to display.
  19948. * * 0 is +X
  19949. * * 1 is -X
  19950. * * 2 is +Y
  19951. * * 3 is -Y
  19952. * * 4 is +Z
  19953. * * 5 is -Z
  19954. */
  19955. get face(): number;
  19956. set face(value: number);
  19957. /**
  19958. * Gets a string identifying the name of the class
  19959. * @returns "PassCubePostProcess" string
  19960. */
  19961. getClassName(): string;
  19962. /**
  19963. * Creates the PassCubePostProcess
  19964. * @param name The name of the effect.
  19965. * @param options The required width/height ratio to downsize to before computing the render pass.
  19966. * @param camera The camera to apply the render pass to.
  19967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19968. * @param engine The engine which the post process will be applied. (default: current engine)
  19969. * @param reusable If the post process can be reused on the same frame. (default: false)
  19970. * @param textureType The type of texture to be used when performing the post processing.
  19971. * @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)
  19972. */
  19973. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19974. /** @hidden */
  19975. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  19976. }
  19977. }
  19978. declare module BABYLON {
  19979. /**
  19980. * Class used to host texture specific utilities
  19981. */
  19982. export class TextureTools {
  19983. /**
  19984. * Uses the GPU to create a copy texture rescaled at a given size
  19985. * @param texture Texture to copy from
  19986. * @param width defines the desired width
  19987. * @param height defines the desired height
  19988. * @param useBilinearMode defines if bilinear mode has to be used
  19989. * @return the generated texture
  19990. */
  19991. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  19992. /**
  19993. * Apply a post process to a texture
  19994. * @param postProcessName name of the fragment post process
  19995. * @param internalTexture the texture to encode
  19996. * @param scene the scene hosting the texture
  19997. * @param type type of the output texture. If not provided, use the one from internalTexture
  19998. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  19999. * @param format format of the output texture. If not provided, use the one from internalTexture
  20000. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20001. */
  20002. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20003. }
  20004. }
  20005. declare module BABYLON {
  20006. /**
  20007. * Class used to host RGBD texture specific utilities
  20008. */
  20009. export class RGBDTextureTools {
  20010. /**
  20011. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20012. * @param texture the texture to expand.
  20013. */
  20014. static ExpandRGBDTexture(texture: Texture): void;
  20015. /**
  20016. * Encode the texture to RGBD if possible.
  20017. * @param internalTexture the texture to encode
  20018. * @param scene the scene hosting the texture
  20019. * @param outputTextureType type of the texture in which the encoding is performed
  20020. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20021. */
  20022. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20023. }
  20024. }
  20025. declare module BABYLON {
  20026. /**
  20027. * Class used to host texture specific utilities
  20028. */
  20029. export class BRDFTextureTools {
  20030. /**
  20031. * Prevents texture cache collision
  20032. */
  20033. private static _instanceNumber;
  20034. /**
  20035. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20036. * @param scene defines the hosting scene
  20037. * @returns the environment BRDF texture
  20038. */
  20039. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20040. private static _environmentBRDFBase64Texture;
  20041. }
  20042. }
  20043. declare module BABYLON {
  20044. /**
  20045. * @hidden
  20046. */
  20047. export interface IMaterialClearCoatDefines {
  20048. CLEARCOAT: boolean;
  20049. CLEARCOAT_DEFAULTIOR: boolean;
  20050. CLEARCOAT_TEXTURE: boolean;
  20051. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20052. CLEARCOAT_TEXTUREDIRECTUV: number;
  20053. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20054. CLEARCOAT_BUMP: boolean;
  20055. CLEARCOAT_BUMPDIRECTUV: number;
  20056. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20057. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20058. CLEARCOAT_REMAP_F0: boolean;
  20059. CLEARCOAT_TINT: boolean;
  20060. CLEARCOAT_TINT_TEXTURE: boolean;
  20061. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20062. /** @hidden */
  20063. _areTexturesDirty: boolean;
  20064. }
  20065. /**
  20066. * Define the code related to the clear coat parameters of the pbr material.
  20067. */
  20068. export class PBRClearCoatConfiguration {
  20069. /**
  20070. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20071. * The default fits with a polyurethane material.
  20072. * @hidden
  20073. */
  20074. static readonly _DefaultIndexOfRefraction: number;
  20075. private _isEnabled;
  20076. /**
  20077. * Defines if the clear coat is enabled in the material.
  20078. */
  20079. isEnabled: boolean;
  20080. /**
  20081. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20082. */
  20083. intensity: number;
  20084. /**
  20085. * Defines the clear coat layer roughness.
  20086. */
  20087. roughness: number;
  20088. private _indexOfRefraction;
  20089. /**
  20090. * Defines the index of refraction of the clear coat.
  20091. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20092. * The default fits with a polyurethane material.
  20093. * Changing the default value is more performance intensive.
  20094. */
  20095. indexOfRefraction: number;
  20096. private _texture;
  20097. /**
  20098. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20099. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20100. * if textureRoughness is not empty, else no texture roughness is used
  20101. */
  20102. texture: Nullable<BaseTexture>;
  20103. private _useRoughnessFromMainTexture;
  20104. /**
  20105. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20106. * If false, the green channel from textureRoughness is used for roughness
  20107. */
  20108. useRoughnessFromMainTexture: boolean;
  20109. private _textureRoughness;
  20110. /**
  20111. * Stores the clear coat roughness in a texture (green channel)
  20112. * Not used if useRoughnessFromMainTexture is true
  20113. */
  20114. textureRoughness: Nullable<BaseTexture>;
  20115. private _remapF0OnInterfaceChange;
  20116. /**
  20117. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20118. */
  20119. remapF0OnInterfaceChange: boolean;
  20120. private _bumpTexture;
  20121. /**
  20122. * Define the clear coat specific bump texture.
  20123. */
  20124. bumpTexture: Nullable<BaseTexture>;
  20125. private _isTintEnabled;
  20126. /**
  20127. * Defines if the clear coat tint is enabled in the material.
  20128. */
  20129. isTintEnabled: boolean;
  20130. /**
  20131. * Defines the clear coat tint of the material.
  20132. * This is only use if tint is enabled
  20133. */
  20134. tintColor: Color3;
  20135. /**
  20136. * Defines the distance at which the tint color should be found in the
  20137. * clear coat media.
  20138. * This is only use if tint is enabled
  20139. */
  20140. tintColorAtDistance: number;
  20141. /**
  20142. * Defines the clear coat layer thickness.
  20143. * This is only use if tint is enabled
  20144. */
  20145. tintThickness: number;
  20146. private _tintTexture;
  20147. /**
  20148. * Stores the clear tint values in a texture.
  20149. * rgb is tint
  20150. * a is a thickness factor
  20151. */
  20152. tintTexture: Nullable<BaseTexture>;
  20153. /** @hidden */
  20154. private _internalMarkAllSubMeshesAsTexturesDirty;
  20155. /** @hidden */
  20156. _markAllSubMeshesAsTexturesDirty(): void;
  20157. /**
  20158. * Instantiate a new istance of clear coat configuration.
  20159. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20160. */
  20161. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20162. /**
  20163. * Gets wehter the submesh is ready to be used or not.
  20164. * @param defines the list of "defines" to update.
  20165. * @param scene defines the scene the material belongs to.
  20166. * @param engine defines the engine the material belongs to.
  20167. * @param disableBumpMap defines wether the material disables bump or not.
  20168. * @returns - boolean indicating that the submesh is ready or not.
  20169. */
  20170. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20171. /**
  20172. * Checks to see if a texture is used in the material.
  20173. * @param defines the list of "defines" to update.
  20174. * @param scene defines the scene to the material belongs to.
  20175. */
  20176. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20177. /**
  20178. * Binds the material data.
  20179. * @param uniformBuffer defines the Uniform buffer to fill in.
  20180. * @param scene defines the scene the material belongs to.
  20181. * @param engine defines the engine the material belongs to.
  20182. * @param disableBumpMap defines wether the material disables bump or not.
  20183. * @param isFrozen defines wether the material is frozen or not.
  20184. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20185. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20186. * @param subMesh the submesh to bind data for
  20187. */
  20188. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20189. /**
  20190. * Checks to see if a texture is used in the material.
  20191. * @param texture - Base texture to use.
  20192. * @returns - Boolean specifying if a texture is used in the material.
  20193. */
  20194. hasTexture(texture: BaseTexture): boolean;
  20195. /**
  20196. * Returns an array of the actively used textures.
  20197. * @param activeTextures Array of BaseTextures
  20198. */
  20199. getActiveTextures(activeTextures: BaseTexture[]): void;
  20200. /**
  20201. * Returns the animatable textures.
  20202. * @param animatables Array of animatable textures.
  20203. */
  20204. getAnimatables(animatables: IAnimatable[]): void;
  20205. /**
  20206. * Disposes the resources of the material.
  20207. * @param forceDisposeTextures - Forces the disposal of all textures.
  20208. */
  20209. dispose(forceDisposeTextures?: boolean): void;
  20210. /**
  20211. * Get the current class name of the texture useful for serialization or dynamic coding.
  20212. * @returns "PBRClearCoatConfiguration"
  20213. */
  20214. getClassName(): string;
  20215. /**
  20216. * Add fallbacks to the effect fallbacks list.
  20217. * @param defines defines the Base texture to use.
  20218. * @param fallbacks defines the current fallback list.
  20219. * @param currentRank defines the current fallback rank.
  20220. * @returns the new fallback rank.
  20221. */
  20222. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20223. /**
  20224. * Add the required uniforms to the current list.
  20225. * @param uniforms defines the current uniform list.
  20226. */
  20227. static AddUniforms(uniforms: string[]): void;
  20228. /**
  20229. * Add the required samplers to the current list.
  20230. * @param samplers defines the current sampler list.
  20231. */
  20232. static AddSamplers(samplers: string[]): void;
  20233. /**
  20234. * Add the required uniforms to the current buffer.
  20235. * @param uniformBuffer defines the current uniform buffer.
  20236. */
  20237. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20238. /**
  20239. * Makes a duplicate of the current configuration into another one.
  20240. * @param clearCoatConfiguration define the config where to copy the info
  20241. */
  20242. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20243. /**
  20244. * Serializes this clear coat configuration.
  20245. * @returns - An object with the serialized config.
  20246. */
  20247. serialize(): any;
  20248. /**
  20249. * Parses a anisotropy Configuration from a serialized object.
  20250. * @param source - Serialized object.
  20251. * @param scene Defines the scene we are parsing for
  20252. * @param rootUrl Defines the rootUrl to load from
  20253. */
  20254. parse(source: any, scene: Scene, rootUrl: string): void;
  20255. }
  20256. }
  20257. declare module BABYLON {
  20258. /**
  20259. * @hidden
  20260. */
  20261. export interface IMaterialAnisotropicDefines {
  20262. ANISOTROPIC: boolean;
  20263. ANISOTROPIC_TEXTURE: boolean;
  20264. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20265. MAINUV1: boolean;
  20266. _areTexturesDirty: boolean;
  20267. _needUVs: boolean;
  20268. }
  20269. /**
  20270. * Define the code related to the anisotropic parameters of the pbr material.
  20271. */
  20272. export class PBRAnisotropicConfiguration {
  20273. private _isEnabled;
  20274. /**
  20275. * Defines if the anisotropy is enabled in the material.
  20276. */
  20277. isEnabled: boolean;
  20278. /**
  20279. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20280. */
  20281. intensity: number;
  20282. /**
  20283. * Defines if the effect is along the tangents, bitangents or in between.
  20284. * By default, the effect is "strectching" the highlights along the tangents.
  20285. */
  20286. direction: Vector2;
  20287. private _texture;
  20288. /**
  20289. * Stores the anisotropy values in a texture.
  20290. * rg is direction (like normal from -1 to 1)
  20291. * b is a intensity
  20292. */
  20293. texture: Nullable<BaseTexture>;
  20294. /** @hidden */
  20295. private _internalMarkAllSubMeshesAsTexturesDirty;
  20296. /** @hidden */
  20297. _markAllSubMeshesAsTexturesDirty(): void;
  20298. /**
  20299. * Instantiate a new istance of anisotropy configuration.
  20300. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20301. */
  20302. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20303. /**
  20304. * Specifies that the submesh is ready to be used.
  20305. * @param defines the list of "defines" to update.
  20306. * @param scene defines the scene the material belongs to.
  20307. * @returns - boolean indicating that the submesh is ready or not.
  20308. */
  20309. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20310. /**
  20311. * Checks to see if a texture is used in the material.
  20312. * @param defines the list of "defines" to update.
  20313. * @param mesh the mesh we are preparing the defines for.
  20314. * @param scene defines the scene the material belongs to.
  20315. */
  20316. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20317. /**
  20318. * Binds the material data.
  20319. * @param uniformBuffer defines the Uniform buffer to fill in.
  20320. * @param scene defines the scene the material belongs to.
  20321. * @param isFrozen defines wether the material is frozen or not.
  20322. */
  20323. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20324. /**
  20325. * Checks to see if a texture is used in the material.
  20326. * @param texture - Base texture to use.
  20327. * @returns - Boolean specifying if a texture is used in the material.
  20328. */
  20329. hasTexture(texture: BaseTexture): boolean;
  20330. /**
  20331. * Returns an array of the actively used textures.
  20332. * @param activeTextures Array of BaseTextures
  20333. */
  20334. getActiveTextures(activeTextures: BaseTexture[]): void;
  20335. /**
  20336. * Returns the animatable textures.
  20337. * @param animatables Array of animatable textures.
  20338. */
  20339. getAnimatables(animatables: IAnimatable[]): void;
  20340. /**
  20341. * Disposes the resources of the material.
  20342. * @param forceDisposeTextures - Forces the disposal of all textures.
  20343. */
  20344. dispose(forceDisposeTextures?: boolean): void;
  20345. /**
  20346. * Get the current class name of the texture useful for serialization or dynamic coding.
  20347. * @returns "PBRAnisotropicConfiguration"
  20348. */
  20349. getClassName(): string;
  20350. /**
  20351. * Add fallbacks to the effect fallbacks list.
  20352. * @param defines defines the Base texture to use.
  20353. * @param fallbacks defines the current fallback list.
  20354. * @param currentRank defines the current fallback rank.
  20355. * @returns the new fallback rank.
  20356. */
  20357. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20358. /**
  20359. * Add the required uniforms to the current list.
  20360. * @param uniforms defines the current uniform list.
  20361. */
  20362. static AddUniforms(uniforms: string[]): void;
  20363. /**
  20364. * Add the required uniforms to the current buffer.
  20365. * @param uniformBuffer defines the current uniform buffer.
  20366. */
  20367. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20368. /**
  20369. * Add the required samplers to the current list.
  20370. * @param samplers defines the current sampler list.
  20371. */
  20372. static AddSamplers(samplers: string[]): void;
  20373. /**
  20374. * Makes a duplicate of the current configuration into another one.
  20375. * @param anisotropicConfiguration define the config where to copy the info
  20376. */
  20377. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20378. /**
  20379. * Serializes this anisotropy configuration.
  20380. * @returns - An object with the serialized config.
  20381. */
  20382. serialize(): any;
  20383. /**
  20384. * Parses a anisotropy Configuration from a serialized object.
  20385. * @param source - Serialized object.
  20386. * @param scene Defines the scene we are parsing for
  20387. * @param rootUrl Defines the rootUrl to load from
  20388. */
  20389. parse(source: any, scene: Scene, rootUrl: string): void;
  20390. }
  20391. }
  20392. declare module BABYLON {
  20393. /**
  20394. * @hidden
  20395. */
  20396. export interface IMaterialBRDFDefines {
  20397. BRDF_V_HEIGHT_CORRELATED: boolean;
  20398. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20399. SPHERICAL_HARMONICS: boolean;
  20400. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20401. /** @hidden */
  20402. _areMiscDirty: boolean;
  20403. }
  20404. /**
  20405. * Define the code related to the BRDF parameters of the pbr material.
  20406. */
  20407. export class PBRBRDFConfiguration {
  20408. /**
  20409. * Default value used for the energy conservation.
  20410. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20411. */
  20412. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20413. /**
  20414. * Default value used for the Smith Visibility Height Correlated mode.
  20415. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20416. */
  20417. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20418. /**
  20419. * Default value used for the IBL diffuse part.
  20420. * This can help switching back to the polynomials mode globally which is a tiny bit
  20421. * less GPU intensive at the drawback of a lower quality.
  20422. */
  20423. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20424. /**
  20425. * Default value used for activating energy conservation for the specular workflow.
  20426. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20427. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20428. */
  20429. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20430. private _useEnergyConservation;
  20431. /**
  20432. * Defines if the material uses energy conservation.
  20433. */
  20434. useEnergyConservation: boolean;
  20435. private _useSmithVisibilityHeightCorrelated;
  20436. /**
  20437. * LEGACY Mode set to false
  20438. * Defines if the material uses height smith correlated visibility term.
  20439. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20440. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20441. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20442. * Not relying on height correlated will also disable energy conservation.
  20443. */
  20444. useSmithVisibilityHeightCorrelated: boolean;
  20445. private _useSphericalHarmonics;
  20446. /**
  20447. * LEGACY Mode set to false
  20448. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20449. * diffuse part of the IBL.
  20450. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20451. * to the ground truth.
  20452. */
  20453. useSphericalHarmonics: boolean;
  20454. private _useSpecularGlossinessInputEnergyConservation;
  20455. /**
  20456. * Defines if the material uses energy conservation, when the specular workflow is active.
  20457. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20458. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20459. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20460. */
  20461. useSpecularGlossinessInputEnergyConservation: boolean;
  20462. /** @hidden */
  20463. private _internalMarkAllSubMeshesAsMiscDirty;
  20464. /** @hidden */
  20465. _markAllSubMeshesAsMiscDirty(): void;
  20466. /**
  20467. * Instantiate a new istance of clear coat configuration.
  20468. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20469. */
  20470. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20471. /**
  20472. * Checks to see if a texture is used in the material.
  20473. * @param defines the list of "defines" to update.
  20474. */
  20475. prepareDefines(defines: IMaterialBRDFDefines): void;
  20476. /**
  20477. * Get the current class name of the texture useful for serialization or dynamic coding.
  20478. * @returns "PBRClearCoatConfiguration"
  20479. */
  20480. getClassName(): string;
  20481. /**
  20482. * Makes a duplicate of the current configuration into another one.
  20483. * @param brdfConfiguration define the config where to copy the info
  20484. */
  20485. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20486. /**
  20487. * Serializes this BRDF configuration.
  20488. * @returns - An object with the serialized config.
  20489. */
  20490. serialize(): any;
  20491. /**
  20492. * Parses a anisotropy Configuration from a serialized object.
  20493. * @param source - Serialized object.
  20494. * @param scene Defines the scene we are parsing for
  20495. * @param rootUrl Defines the rootUrl to load from
  20496. */
  20497. parse(source: any, scene: Scene, rootUrl: string): void;
  20498. }
  20499. }
  20500. declare module BABYLON {
  20501. /**
  20502. * @hidden
  20503. */
  20504. export interface IMaterialSheenDefines {
  20505. SHEEN: boolean;
  20506. SHEEN_TEXTURE: boolean;
  20507. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20508. SHEEN_TEXTUREDIRECTUV: number;
  20509. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20510. SHEEN_LINKWITHALBEDO: boolean;
  20511. SHEEN_ROUGHNESS: boolean;
  20512. SHEEN_ALBEDOSCALING: boolean;
  20513. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20514. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20515. /** @hidden */
  20516. _areTexturesDirty: boolean;
  20517. }
  20518. /**
  20519. * Define the code related to the Sheen parameters of the pbr material.
  20520. */
  20521. export class PBRSheenConfiguration {
  20522. private _isEnabled;
  20523. /**
  20524. * Defines if the material uses sheen.
  20525. */
  20526. isEnabled: boolean;
  20527. private _linkSheenWithAlbedo;
  20528. /**
  20529. * Defines if the sheen is linked to the sheen color.
  20530. */
  20531. linkSheenWithAlbedo: boolean;
  20532. /**
  20533. * Defines the sheen intensity.
  20534. */
  20535. intensity: number;
  20536. /**
  20537. * Defines the sheen color.
  20538. */
  20539. color: Color3;
  20540. private _texture;
  20541. /**
  20542. * Stores the sheen tint values in a texture.
  20543. * rgb is tint
  20544. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  20545. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20546. */
  20547. texture: Nullable<BaseTexture>;
  20548. private _useRoughnessFromMainTexture;
  20549. /**
  20550. * Indicates that the alpha channel of the texture property will be used for roughness.
  20551. * Has no effect if the roughness (and texture!) property is not defined
  20552. */
  20553. useRoughnessFromMainTexture: boolean;
  20554. private _roughness;
  20555. /**
  20556. * Defines the sheen roughness.
  20557. * It is not taken into account if linkSheenWithAlbedo is true.
  20558. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20559. */
  20560. roughness: Nullable<number>;
  20561. private _textureRoughness;
  20562. /**
  20563. * Stores the sheen roughness in a texture.
  20564. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20565. */
  20566. textureRoughness: Nullable<BaseTexture>;
  20567. private _albedoScaling;
  20568. /**
  20569. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20570. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20571. * making it easier to setup and tweak the effect
  20572. */
  20573. albedoScaling: boolean;
  20574. /** @hidden */
  20575. private _internalMarkAllSubMeshesAsTexturesDirty;
  20576. /** @hidden */
  20577. _markAllSubMeshesAsTexturesDirty(): void;
  20578. /**
  20579. * Instantiate a new istance of clear coat configuration.
  20580. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20581. */
  20582. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20583. /**
  20584. * Specifies that the submesh is ready to be used.
  20585. * @param defines the list of "defines" to update.
  20586. * @param scene defines the scene the material belongs to.
  20587. * @returns - boolean indicating that the submesh is ready or not.
  20588. */
  20589. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20590. /**
  20591. * Checks to see if a texture is used in the material.
  20592. * @param defines the list of "defines" to update.
  20593. * @param scene defines the scene the material belongs to.
  20594. */
  20595. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20596. /**
  20597. * Binds the material data.
  20598. * @param uniformBuffer defines the Uniform buffer to fill in.
  20599. * @param scene defines the scene the material belongs to.
  20600. * @param isFrozen defines wether the material is frozen or not.
  20601. * @param subMesh the submesh to bind data for
  20602. */
  20603. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20604. /**
  20605. * Checks to see if a texture is used in the material.
  20606. * @param texture - Base texture to use.
  20607. * @returns - Boolean specifying if a texture is used in the material.
  20608. */
  20609. hasTexture(texture: BaseTexture): boolean;
  20610. /**
  20611. * Returns an array of the actively used textures.
  20612. * @param activeTextures Array of BaseTextures
  20613. */
  20614. getActiveTextures(activeTextures: BaseTexture[]): void;
  20615. /**
  20616. * Returns the animatable textures.
  20617. * @param animatables Array of animatable textures.
  20618. */
  20619. getAnimatables(animatables: IAnimatable[]): void;
  20620. /**
  20621. * Disposes the resources of the material.
  20622. * @param forceDisposeTextures - Forces the disposal of all textures.
  20623. */
  20624. dispose(forceDisposeTextures?: boolean): void;
  20625. /**
  20626. * Get the current class name of the texture useful for serialization or dynamic coding.
  20627. * @returns "PBRSheenConfiguration"
  20628. */
  20629. getClassName(): string;
  20630. /**
  20631. * Add fallbacks to the effect fallbacks list.
  20632. * @param defines defines the Base texture to use.
  20633. * @param fallbacks defines the current fallback list.
  20634. * @param currentRank defines the current fallback rank.
  20635. * @returns the new fallback rank.
  20636. */
  20637. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20638. /**
  20639. * Add the required uniforms to the current list.
  20640. * @param uniforms defines the current uniform list.
  20641. */
  20642. static AddUniforms(uniforms: string[]): void;
  20643. /**
  20644. * Add the required uniforms to the current buffer.
  20645. * @param uniformBuffer defines the current uniform buffer.
  20646. */
  20647. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20648. /**
  20649. * Add the required samplers to the current list.
  20650. * @param samplers defines the current sampler list.
  20651. */
  20652. static AddSamplers(samplers: string[]): void;
  20653. /**
  20654. * Makes a duplicate of the current configuration into another one.
  20655. * @param sheenConfiguration define the config where to copy the info
  20656. */
  20657. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20658. /**
  20659. * Serializes this BRDF configuration.
  20660. * @returns - An object with the serialized config.
  20661. */
  20662. serialize(): any;
  20663. /**
  20664. * Parses a anisotropy Configuration from a serialized object.
  20665. * @param source - Serialized object.
  20666. * @param scene Defines the scene we are parsing for
  20667. * @param rootUrl Defines the rootUrl to load from
  20668. */
  20669. parse(source: any, scene: Scene, rootUrl: string): void;
  20670. }
  20671. }
  20672. declare module BABYLON {
  20673. /**
  20674. * @hidden
  20675. */
  20676. export interface IMaterialSubSurfaceDefines {
  20677. SUBSURFACE: boolean;
  20678. SS_REFRACTION: boolean;
  20679. SS_TRANSLUCENCY: boolean;
  20680. SS_SCATTERING: boolean;
  20681. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20682. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20683. SS_REFRACTIONMAP_3D: boolean;
  20684. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20685. SS_LODINREFRACTIONALPHA: boolean;
  20686. SS_GAMMAREFRACTION: boolean;
  20687. SS_RGBDREFRACTION: boolean;
  20688. SS_LINEARSPECULARREFRACTION: boolean;
  20689. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20690. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20691. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20692. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20693. /** @hidden */
  20694. _areTexturesDirty: boolean;
  20695. }
  20696. /**
  20697. * Define the code related to the sub surface parameters of the pbr material.
  20698. */
  20699. export class PBRSubSurfaceConfiguration {
  20700. private _isRefractionEnabled;
  20701. /**
  20702. * Defines if the refraction is enabled in the material.
  20703. */
  20704. isRefractionEnabled: boolean;
  20705. private _isTranslucencyEnabled;
  20706. /**
  20707. * Defines if the translucency is enabled in the material.
  20708. */
  20709. isTranslucencyEnabled: boolean;
  20710. private _isScatteringEnabled;
  20711. /**
  20712. * Defines if the sub surface scattering is enabled in the material.
  20713. */
  20714. isScatteringEnabled: boolean;
  20715. private _scatteringDiffusionProfileIndex;
  20716. /**
  20717. * Diffusion profile for subsurface scattering.
  20718. * Useful for better scattering in the skins or foliages.
  20719. */
  20720. get scatteringDiffusionProfile(): Nullable<Color3>;
  20721. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20722. /**
  20723. * Defines the refraction intensity of the material.
  20724. * The refraction when enabled replaces the Diffuse part of the material.
  20725. * The intensity helps transitionning between diffuse and refraction.
  20726. */
  20727. refractionIntensity: number;
  20728. /**
  20729. * Defines the translucency intensity of the material.
  20730. * When translucency has been enabled, this defines how much of the "translucency"
  20731. * is addded to the diffuse part of the material.
  20732. */
  20733. translucencyIntensity: number;
  20734. /**
  20735. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20736. */
  20737. useAlbedoToTintRefraction: boolean;
  20738. private _thicknessTexture;
  20739. /**
  20740. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20741. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20742. * 0 would mean minimumThickness
  20743. * 1 would mean maximumThickness
  20744. * The other channels might be use as a mask to vary the different effects intensity.
  20745. */
  20746. thicknessTexture: Nullable<BaseTexture>;
  20747. private _refractionTexture;
  20748. /**
  20749. * Defines the texture to use for refraction.
  20750. */
  20751. refractionTexture: Nullable<BaseTexture>;
  20752. private _indexOfRefraction;
  20753. /**
  20754. * Index of refraction of the material base layer.
  20755. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20756. *
  20757. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20758. *
  20759. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20760. */
  20761. indexOfRefraction: number;
  20762. private _volumeIndexOfRefraction;
  20763. /**
  20764. * Index of refraction of the material's volume.
  20765. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20766. *
  20767. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20768. * the volume will use the same IOR as the surface.
  20769. */
  20770. get volumeIndexOfRefraction(): number;
  20771. set volumeIndexOfRefraction(value: number);
  20772. private _invertRefractionY;
  20773. /**
  20774. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20775. */
  20776. invertRefractionY: boolean;
  20777. private _linkRefractionWithTransparency;
  20778. /**
  20779. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20780. * Materials half opaque for instance using refraction could benefit from this control.
  20781. */
  20782. linkRefractionWithTransparency: boolean;
  20783. /**
  20784. * Defines the minimum thickness stored in the thickness map.
  20785. * If no thickness map is defined, this value will be used to simulate thickness.
  20786. */
  20787. minimumThickness: number;
  20788. /**
  20789. * Defines the maximum thickness stored in the thickness map.
  20790. */
  20791. maximumThickness: number;
  20792. /**
  20793. * Defines the volume tint of the material.
  20794. * This is used for both translucency and scattering.
  20795. */
  20796. tintColor: Color3;
  20797. /**
  20798. * Defines the distance at which the tint color should be found in the media.
  20799. * This is used for refraction only.
  20800. */
  20801. tintColorAtDistance: number;
  20802. /**
  20803. * Defines how far each channel transmit through the media.
  20804. * It is defined as a color to simplify it selection.
  20805. */
  20806. diffusionDistance: Color3;
  20807. private _useMaskFromThicknessTexture;
  20808. /**
  20809. * Stores the intensity of the different subsurface effects in the thickness texture.
  20810. * * the green channel is the translucency intensity.
  20811. * * the blue channel is the scattering intensity.
  20812. * * the alpha channel is the refraction intensity.
  20813. */
  20814. useMaskFromThicknessTexture: boolean;
  20815. private _scene;
  20816. private _useMaskFromThicknessTextureGltf;
  20817. /**
  20818. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20819. * matches the channel-packing that is used by glTF.
  20820. * * the red channel is the transmission/translucency intensity.
  20821. * * the green channel is the thickness.
  20822. */
  20823. useMaskFromThicknessTextureGltf: boolean;
  20824. /** @hidden */
  20825. private _internalMarkAllSubMeshesAsTexturesDirty;
  20826. private _internalMarkScenePrePassDirty;
  20827. /** @hidden */
  20828. _markAllSubMeshesAsTexturesDirty(): void;
  20829. /** @hidden */
  20830. _markScenePrePassDirty(): void;
  20831. /**
  20832. * Instantiate a new istance of sub surface configuration.
  20833. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20834. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20835. * @param scene The scene
  20836. */
  20837. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20838. /**
  20839. * Gets wehter the submesh is ready to be used or not.
  20840. * @param defines the list of "defines" to update.
  20841. * @param scene defines the scene the material belongs to.
  20842. * @returns - boolean indicating that the submesh is ready or not.
  20843. */
  20844. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20845. /**
  20846. * Checks to see if a texture is used in the material.
  20847. * @param defines the list of "defines" to update.
  20848. * @param scene defines the scene to the material belongs to.
  20849. */
  20850. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20851. /**
  20852. * Binds the material data.
  20853. * @param uniformBuffer defines the Uniform buffer to fill in.
  20854. * @param scene defines the scene the material belongs to.
  20855. * @param engine defines the engine the material belongs to.
  20856. * @param isFrozen defines whether the material is frozen or not.
  20857. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20858. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20859. */
  20860. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20861. /**
  20862. * Unbinds the material from the mesh.
  20863. * @param activeEffect defines the effect that should be unbound from.
  20864. * @returns true if unbound, otherwise false
  20865. */
  20866. unbind(activeEffect: Effect): boolean;
  20867. /**
  20868. * Returns the texture used for refraction or null if none is used.
  20869. * @param scene defines the scene the material belongs to.
  20870. * @returns - Refraction texture if present. If no refraction texture and refraction
  20871. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20872. */
  20873. private _getRefractionTexture;
  20874. /**
  20875. * Returns true if alpha blending should be disabled.
  20876. */
  20877. get disableAlphaBlending(): boolean;
  20878. /**
  20879. * Fills the list of render target textures.
  20880. * @param renderTargets the list of render targets to update
  20881. */
  20882. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20883. /**
  20884. * Checks to see if a texture is used in the material.
  20885. * @param texture - Base texture to use.
  20886. * @returns - Boolean specifying if a texture is used in the material.
  20887. */
  20888. hasTexture(texture: BaseTexture): boolean;
  20889. /**
  20890. * Gets a boolean indicating that current material needs to register RTT
  20891. * @returns true if this uses a render target otherwise false.
  20892. */
  20893. hasRenderTargetTextures(): boolean;
  20894. /**
  20895. * Returns an array of the actively used textures.
  20896. * @param activeTextures Array of BaseTextures
  20897. */
  20898. getActiveTextures(activeTextures: BaseTexture[]): void;
  20899. /**
  20900. * Returns the animatable textures.
  20901. * @param animatables Array of animatable textures.
  20902. */
  20903. getAnimatables(animatables: IAnimatable[]): void;
  20904. /**
  20905. * Disposes the resources of the material.
  20906. * @param forceDisposeTextures - Forces the disposal of all textures.
  20907. */
  20908. dispose(forceDisposeTextures?: boolean): void;
  20909. /**
  20910. * Get the current class name of the texture useful for serialization or dynamic coding.
  20911. * @returns "PBRSubSurfaceConfiguration"
  20912. */
  20913. getClassName(): string;
  20914. /**
  20915. * Add fallbacks to the effect fallbacks list.
  20916. * @param defines defines the Base texture to use.
  20917. * @param fallbacks defines the current fallback list.
  20918. * @param currentRank defines the current fallback rank.
  20919. * @returns the new fallback rank.
  20920. */
  20921. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20922. /**
  20923. * Add the required uniforms to the current list.
  20924. * @param uniforms defines the current uniform list.
  20925. */
  20926. static AddUniforms(uniforms: string[]): void;
  20927. /**
  20928. * Add the required samplers to the current list.
  20929. * @param samplers defines the current sampler list.
  20930. */
  20931. static AddSamplers(samplers: string[]): void;
  20932. /**
  20933. * Add the required uniforms to the current buffer.
  20934. * @param uniformBuffer defines the current uniform buffer.
  20935. */
  20936. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20937. /**
  20938. * Makes a duplicate of the current configuration into another one.
  20939. * @param configuration define the config where to copy the info
  20940. */
  20941. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20942. /**
  20943. * Serializes this Sub Surface configuration.
  20944. * @returns - An object with the serialized config.
  20945. */
  20946. serialize(): any;
  20947. /**
  20948. * Parses a anisotropy Configuration from a serialized object.
  20949. * @param source - Serialized object.
  20950. * @param scene Defines the scene we are parsing for
  20951. * @param rootUrl Defines the rootUrl to load from
  20952. */
  20953. parse(source: any, scene: Scene, rootUrl: string): void;
  20954. }
  20955. }
  20956. declare module BABYLON {
  20957. /**
  20958. * Class representing spherical harmonics coefficients to the 3rd degree
  20959. */
  20960. export class SphericalHarmonics {
  20961. /**
  20962. * Defines whether or not the harmonics have been prescaled for rendering.
  20963. */
  20964. preScaled: boolean;
  20965. /**
  20966. * The l0,0 coefficients of the spherical harmonics
  20967. */
  20968. l00: Vector3;
  20969. /**
  20970. * The l1,-1 coefficients of the spherical harmonics
  20971. */
  20972. l1_1: Vector3;
  20973. /**
  20974. * The l1,0 coefficients of the spherical harmonics
  20975. */
  20976. l10: Vector3;
  20977. /**
  20978. * The l1,1 coefficients of the spherical harmonics
  20979. */
  20980. l11: Vector3;
  20981. /**
  20982. * The l2,-2 coefficients of the spherical harmonics
  20983. */
  20984. l2_2: Vector3;
  20985. /**
  20986. * The l2,-1 coefficients of the spherical harmonics
  20987. */
  20988. l2_1: Vector3;
  20989. /**
  20990. * The l2,0 coefficients of the spherical harmonics
  20991. */
  20992. l20: Vector3;
  20993. /**
  20994. * The l2,1 coefficients of the spherical harmonics
  20995. */
  20996. l21: Vector3;
  20997. /**
  20998. * The l2,2 coefficients of the spherical harmonics
  20999. */
  21000. l22: Vector3;
  21001. /**
  21002. * Adds a light to the spherical harmonics
  21003. * @param direction the direction of the light
  21004. * @param color the color of the light
  21005. * @param deltaSolidAngle the delta solid angle of the light
  21006. */
  21007. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21008. /**
  21009. * Scales the spherical harmonics by the given amount
  21010. * @param scale the amount to scale
  21011. */
  21012. scaleInPlace(scale: number): void;
  21013. /**
  21014. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21015. *
  21016. * ```
  21017. * E_lm = A_l * L_lm
  21018. * ```
  21019. *
  21020. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21021. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21022. * the scaling factors are given in equation 9.
  21023. */
  21024. convertIncidentRadianceToIrradiance(): void;
  21025. /**
  21026. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21027. *
  21028. * ```
  21029. * L = (1/pi) * E * rho
  21030. * ```
  21031. *
  21032. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21033. */
  21034. convertIrradianceToLambertianRadiance(): void;
  21035. /**
  21036. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21037. * required operations at run time.
  21038. *
  21039. * This is simply done by scaling back the SH with Ylm constants parameter.
  21040. * The trigonometric part being applied by the shader at run time.
  21041. */
  21042. preScaleForRendering(): void;
  21043. /**
  21044. * Constructs a spherical harmonics from an array.
  21045. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21046. * @returns the spherical harmonics
  21047. */
  21048. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21049. /**
  21050. * Gets the spherical harmonics from polynomial
  21051. * @param polynomial the spherical polynomial
  21052. * @returns the spherical harmonics
  21053. */
  21054. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21055. }
  21056. /**
  21057. * Class representing spherical polynomial coefficients to the 3rd degree
  21058. */
  21059. export class SphericalPolynomial {
  21060. private _harmonics;
  21061. /**
  21062. * The spherical harmonics used to create the polynomials.
  21063. */
  21064. get preScaledHarmonics(): SphericalHarmonics;
  21065. /**
  21066. * The x coefficients of the spherical polynomial
  21067. */
  21068. x: Vector3;
  21069. /**
  21070. * The y coefficients of the spherical polynomial
  21071. */
  21072. y: Vector3;
  21073. /**
  21074. * The z coefficients of the spherical polynomial
  21075. */
  21076. z: Vector3;
  21077. /**
  21078. * The xx coefficients of the spherical polynomial
  21079. */
  21080. xx: Vector3;
  21081. /**
  21082. * The yy coefficients of the spherical polynomial
  21083. */
  21084. yy: Vector3;
  21085. /**
  21086. * The zz coefficients of the spherical polynomial
  21087. */
  21088. zz: Vector3;
  21089. /**
  21090. * The xy coefficients of the spherical polynomial
  21091. */
  21092. xy: Vector3;
  21093. /**
  21094. * The yz coefficients of the spherical polynomial
  21095. */
  21096. yz: Vector3;
  21097. /**
  21098. * The zx coefficients of the spherical polynomial
  21099. */
  21100. zx: Vector3;
  21101. /**
  21102. * Adds an ambient color to the spherical polynomial
  21103. * @param color the color to add
  21104. */
  21105. addAmbient(color: Color3): void;
  21106. /**
  21107. * Scales the spherical polynomial by the given amount
  21108. * @param scale the amount to scale
  21109. */
  21110. scaleInPlace(scale: number): void;
  21111. /**
  21112. * Gets the spherical polynomial from harmonics
  21113. * @param harmonics the spherical harmonics
  21114. * @returns the spherical polynomial
  21115. */
  21116. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21117. /**
  21118. * Constructs a spherical polynomial from an array.
  21119. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21120. * @returns the spherical polynomial
  21121. */
  21122. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21123. }
  21124. }
  21125. declare module BABYLON {
  21126. /**
  21127. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21128. */
  21129. export interface CubeMapInfo {
  21130. /**
  21131. * The pixel array for the front face.
  21132. * This is stored in format, left to right, up to down format.
  21133. */
  21134. front: Nullable<ArrayBufferView>;
  21135. /**
  21136. * The pixel array for the back face.
  21137. * This is stored in format, left to right, up to down format.
  21138. */
  21139. back: Nullable<ArrayBufferView>;
  21140. /**
  21141. * The pixel array for the left face.
  21142. * This is stored in format, left to right, up to down format.
  21143. */
  21144. left: Nullable<ArrayBufferView>;
  21145. /**
  21146. * The pixel array for the right face.
  21147. * This is stored in format, left to right, up to down format.
  21148. */
  21149. right: Nullable<ArrayBufferView>;
  21150. /**
  21151. * The pixel array for the up face.
  21152. * This is stored in format, left to right, up to down format.
  21153. */
  21154. up: Nullable<ArrayBufferView>;
  21155. /**
  21156. * The pixel array for the down face.
  21157. * This is stored in format, left to right, up to down format.
  21158. */
  21159. down: Nullable<ArrayBufferView>;
  21160. /**
  21161. * The size of the cubemap stored.
  21162. *
  21163. * Each faces will be size * size pixels.
  21164. */
  21165. size: number;
  21166. /**
  21167. * The format of the texture.
  21168. *
  21169. * RGBA, RGB.
  21170. */
  21171. format: number;
  21172. /**
  21173. * The type of the texture data.
  21174. *
  21175. * UNSIGNED_INT, FLOAT.
  21176. */
  21177. type: number;
  21178. /**
  21179. * Specifies whether the texture is in gamma space.
  21180. */
  21181. gammaSpace: boolean;
  21182. }
  21183. /**
  21184. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21185. */
  21186. export class PanoramaToCubeMapTools {
  21187. private static FACE_LEFT;
  21188. private static FACE_RIGHT;
  21189. private static FACE_FRONT;
  21190. private static FACE_BACK;
  21191. private static FACE_DOWN;
  21192. private static FACE_UP;
  21193. /**
  21194. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21195. *
  21196. * @param float32Array The source data.
  21197. * @param inputWidth The width of the input panorama.
  21198. * @param inputHeight The height of the input panorama.
  21199. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21200. * @return The cubemap data
  21201. */
  21202. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21203. private static CreateCubemapTexture;
  21204. private static CalcProjectionSpherical;
  21205. }
  21206. }
  21207. declare module BABYLON {
  21208. /**
  21209. * Helper class dealing with the extraction of spherical polynomial dataArray
  21210. * from a cube map.
  21211. */
  21212. export class CubeMapToSphericalPolynomialTools {
  21213. private static FileFaces;
  21214. /**
  21215. * Converts a texture to the according Spherical Polynomial data.
  21216. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21217. *
  21218. * @param texture The texture to extract the information from.
  21219. * @return The Spherical Polynomial data.
  21220. */
  21221. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21222. /**
  21223. * Converts a cubemap to the according Spherical Polynomial data.
  21224. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21225. *
  21226. * @param cubeInfo The Cube map to extract the information from.
  21227. * @return The Spherical Polynomial data.
  21228. */
  21229. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21230. }
  21231. }
  21232. declare module BABYLON {
  21233. interface BaseTexture {
  21234. /**
  21235. * Get the polynomial representation of the texture data.
  21236. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21237. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21238. */
  21239. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21240. }
  21241. }
  21242. declare module BABYLON {
  21243. /** @hidden */
  21244. export var pbrFragmentDeclaration: {
  21245. name: string;
  21246. shader: string;
  21247. };
  21248. }
  21249. declare module BABYLON {
  21250. /** @hidden */
  21251. export var pbrUboDeclaration: {
  21252. name: string;
  21253. shader: string;
  21254. };
  21255. }
  21256. declare module BABYLON {
  21257. /** @hidden */
  21258. export var pbrFragmentExtraDeclaration: {
  21259. name: string;
  21260. shader: string;
  21261. };
  21262. }
  21263. declare module BABYLON {
  21264. /** @hidden */
  21265. export var pbrFragmentSamplersDeclaration: {
  21266. name: string;
  21267. shader: string;
  21268. };
  21269. }
  21270. declare module BABYLON {
  21271. /** @hidden */
  21272. export var subSurfaceScatteringFunctions: {
  21273. name: string;
  21274. shader: string;
  21275. };
  21276. }
  21277. declare module BABYLON {
  21278. /** @hidden */
  21279. export var importanceSampling: {
  21280. name: string;
  21281. shader: string;
  21282. };
  21283. }
  21284. declare module BABYLON {
  21285. /** @hidden */
  21286. export var pbrHelperFunctions: {
  21287. name: string;
  21288. shader: string;
  21289. };
  21290. }
  21291. declare module BABYLON {
  21292. /** @hidden */
  21293. export var harmonicsFunctions: {
  21294. name: string;
  21295. shader: string;
  21296. };
  21297. }
  21298. declare module BABYLON {
  21299. /** @hidden */
  21300. export var pbrDirectLightingSetupFunctions: {
  21301. name: string;
  21302. shader: string;
  21303. };
  21304. }
  21305. declare module BABYLON {
  21306. /** @hidden */
  21307. export var pbrDirectLightingFalloffFunctions: {
  21308. name: string;
  21309. shader: string;
  21310. };
  21311. }
  21312. declare module BABYLON {
  21313. /** @hidden */
  21314. export var pbrBRDFFunctions: {
  21315. name: string;
  21316. shader: string;
  21317. };
  21318. }
  21319. declare module BABYLON {
  21320. /** @hidden */
  21321. export var hdrFilteringFunctions: {
  21322. name: string;
  21323. shader: string;
  21324. };
  21325. }
  21326. declare module BABYLON {
  21327. /** @hidden */
  21328. export var pbrDirectLightingFunctions: {
  21329. name: string;
  21330. shader: string;
  21331. };
  21332. }
  21333. declare module BABYLON {
  21334. /** @hidden */
  21335. export var pbrIBLFunctions: {
  21336. name: string;
  21337. shader: string;
  21338. };
  21339. }
  21340. declare module BABYLON {
  21341. /** @hidden */
  21342. export var pbrBlockAlbedoOpacity: {
  21343. name: string;
  21344. shader: string;
  21345. };
  21346. }
  21347. declare module BABYLON {
  21348. /** @hidden */
  21349. export var pbrBlockReflectivity: {
  21350. name: string;
  21351. shader: string;
  21352. };
  21353. }
  21354. declare module BABYLON {
  21355. /** @hidden */
  21356. export var pbrBlockAmbientOcclusion: {
  21357. name: string;
  21358. shader: string;
  21359. };
  21360. }
  21361. declare module BABYLON {
  21362. /** @hidden */
  21363. export var pbrBlockAlphaFresnel: {
  21364. name: string;
  21365. shader: string;
  21366. };
  21367. }
  21368. declare module BABYLON {
  21369. /** @hidden */
  21370. export var pbrBlockAnisotropic: {
  21371. name: string;
  21372. shader: string;
  21373. };
  21374. }
  21375. declare module BABYLON {
  21376. /** @hidden */
  21377. export var pbrBlockReflection: {
  21378. name: string;
  21379. shader: string;
  21380. };
  21381. }
  21382. declare module BABYLON {
  21383. /** @hidden */
  21384. export var pbrBlockSheen: {
  21385. name: string;
  21386. shader: string;
  21387. };
  21388. }
  21389. declare module BABYLON {
  21390. /** @hidden */
  21391. export var pbrBlockClearcoat: {
  21392. name: string;
  21393. shader: string;
  21394. };
  21395. }
  21396. declare module BABYLON {
  21397. /** @hidden */
  21398. export var pbrBlockSubSurface: {
  21399. name: string;
  21400. shader: string;
  21401. };
  21402. }
  21403. declare module BABYLON {
  21404. /** @hidden */
  21405. export var pbrBlockNormalGeometric: {
  21406. name: string;
  21407. shader: string;
  21408. };
  21409. }
  21410. declare module BABYLON {
  21411. /** @hidden */
  21412. export var pbrBlockNormalFinal: {
  21413. name: string;
  21414. shader: string;
  21415. };
  21416. }
  21417. declare module BABYLON {
  21418. /** @hidden */
  21419. export var pbrBlockLightmapInit: {
  21420. name: string;
  21421. shader: string;
  21422. };
  21423. }
  21424. declare module BABYLON {
  21425. /** @hidden */
  21426. export var pbrBlockGeometryInfo: {
  21427. name: string;
  21428. shader: string;
  21429. };
  21430. }
  21431. declare module BABYLON {
  21432. /** @hidden */
  21433. export var pbrBlockReflectance0: {
  21434. name: string;
  21435. shader: string;
  21436. };
  21437. }
  21438. declare module BABYLON {
  21439. /** @hidden */
  21440. export var pbrBlockReflectance: {
  21441. name: string;
  21442. shader: string;
  21443. };
  21444. }
  21445. declare module BABYLON {
  21446. /** @hidden */
  21447. export var pbrBlockDirectLighting: {
  21448. name: string;
  21449. shader: string;
  21450. };
  21451. }
  21452. declare module BABYLON {
  21453. /** @hidden */
  21454. export var pbrBlockFinalLitComponents: {
  21455. name: string;
  21456. shader: string;
  21457. };
  21458. }
  21459. declare module BABYLON {
  21460. /** @hidden */
  21461. export var pbrBlockFinalUnlitComponents: {
  21462. name: string;
  21463. shader: string;
  21464. };
  21465. }
  21466. declare module BABYLON {
  21467. /** @hidden */
  21468. export var pbrBlockFinalColorComposition: {
  21469. name: string;
  21470. shader: string;
  21471. };
  21472. }
  21473. declare module BABYLON {
  21474. /** @hidden */
  21475. export var pbrBlockImageProcessing: {
  21476. name: string;
  21477. shader: string;
  21478. };
  21479. }
  21480. declare module BABYLON {
  21481. /** @hidden */
  21482. export var pbrDebug: {
  21483. name: string;
  21484. shader: string;
  21485. };
  21486. }
  21487. declare module BABYLON {
  21488. /** @hidden */
  21489. export var pbrPixelShader: {
  21490. name: string;
  21491. shader: string;
  21492. };
  21493. }
  21494. declare module BABYLON {
  21495. /** @hidden */
  21496. export var pbrVertexDeclaration: {
  21497. name: string;
  21498. shader: string;
  21499. };
  21500. }
  21501. declare module BABYLON {
  21502. /** @hidden */
  21503. export var pbrVertexShader: {
  21504. name: string;
  21505. shader: string;
  21506. };
  21507. }
  21508. declare module BABYLON {
  21509. /**
  21510. * Manages the defines for the PBR Material.
  21511. * @hidden
  21512. */
  21513. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21514. PBR: boolean;
  21515. NUM_SAMPLES: string;
  21516. REALTIME_FILTERING: boolean;
  21517. MAINUV1: boolean;
  21518. MAINUV2: boolean;
  21519. UV1: boolean;
  21520. UV2: boolean;
  21521. ALBEDO: boolean;
  21522. GAMMAALBEDO: boolean;
  21523. ALBEDODIRECTUV: number;
  21524. VERTEXCOLOR: boolean;
  21525. DETAIL: boolean;
  21526. DETAILDIRECTUV: number;
  21527. DETAIL_NORMALBLENDMETHOD: number;
  21528. AMBIENT: boolean;
  21529. AMBIENTDIRECTUV: number;
  21530. AMBIENTINGRAYSCALE: boolean;
  21531. OPACITY: boolean;
  21532. VERTEXALPHA: boolean;
  21533. OPACITYDIRECTUV: number;
  21534. OPACITYRGB: boolean;
  21535. ALPHATEST: boolean;
  21536. DEPTHPREPASS: boolean;
  21537. ALPHABLEND: boolean;
  21538. ALPHAFROMALBEDO: boolean;
  21539. ALPHATESTVALUE: string;
  21540. SPECULAROVERALPHA: boolean;
  21541. RADIANCEOVERALPHA: boolean;
  21542. ALPHAFRESNEL: boolean;
  21543. LINEARALPHAFRESNEL: boolean;
  21544. PREMULTIPLYALPHA: boolean;
  21545. EMISSIVE: boolean;
  21546. EMISSIVEDIRECTUV: number;
  21547. REFLECTIVITY: boolean;
  21548. REFLECTIVITYDIRECTUV: number;
  21549. SPECULARTERM: boolean;
  21550. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21551. MICROSURFACEAUTOMATIC: boolean;
  21552. LODBASEDMICROSFURACE: boolean;
  21553. MICROSURFACEMAP: boolean;
  21554. MICROSURFACEMAPDIRECTUV: number;
  21555. METALLICWORKFLOW: boolean;
  21556. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21557. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21558. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21559. AOSTOREINMETALMAPRED: boolean;
  21560. METALLIC_REFLECTANCE: boolean;
  21561. METALLIC_REFLECTANCEDIRECTUV: number;
  21562. ENVIRONMENTBRDF: boolean;
  21563. ENVIRONMENTBRDF_RGBD: boolean;
  21564. NORMAL: boolean;
  21565. TANGENT: boolean;
  21566. BUMP: boolean;
  21567. BUMPDIRECTUV: number;
  21568. OBJECTSPACE_NORMALMAP: boolean;
  21569. PARALLAX: boolean;
  21570. PARALLAXOCCLUSION: boolean;
  21571. NORMALXYSCALE: boolean;
  21572. LIGHTMAP: boolean;
  21573. LIGHTMAPDIRECTUV: number;
  21574. USELIGHTMAPASSHADOWMAP: boolean;
  21575. GAMMALIGHTMAP: boolean;
  21576. RGBDLIGHTMAP: boolean;
  21577. REFLECTION: boolean;
  21578. REFLECTIONMAP_3D: boolean;
  21579. REFLECTIONMAP_SPHERICAL: boolean;
  21580. REFLECTIONMAP_PLANAR: boolean;
  21581. REFLECTIONMAP_CUBIC: boolean;
  21582. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21583. REFLECTIONMAP_PROJECTION: boolean;
  21584. REFLECTIONMAP_SKYBOX: boolean;
  21585. REFLECTIONMAP_EXPLICIT: boolean;
  21586. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21587. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21588. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21589. INVERTCUBICMAP: boolean;
  21590. USESPHERICALFROMREFLECTIONMAP: boolean;
  21591. USEIRRADIANCEMAP: boolean;
  21592. SPHERICAL_HARMONICS: boolean;
  21593. USESPHERICALINVERTEX: boolean;
  21594. REFLECTIONMAP_OPPOSITEZ: boolean;
  21595. LODINREFLECTIONALPHA: boolean;
  21596. GAMMAREFLECTION: boolean;
  21597. RGBDREFLECTION: boolean;
  21598. LINEARSPECULARREFLECTION: boolean;
  21599. RADIANCEOCCLUSION: boolean;
  21600. HORIZONOCCLUSION: boolean;
  21601. INSTANCES: boolean;
  21602. THIN_INSTANCES: boolean;
  21603. PREPASS: boolean;
  21604. PREPASS_IRRADIANCE: boolean;
  21605. PREPASS_IRRADIANCE_INDEX: number;
  21606. PREPASS_ALBEDO: boolean;
  21607. PREPASS_ALBEDO_INDEX: number;
  21608. PREPASS_DEPTHNORMAL: boolean;
  21609. PREPASS_DEPTHNORMAL_INDEX: number;
  21610. PREPASS_POSITION: boolean;
  21611. PREPASS_POSITION_INDEX: number;
  21612. PREPASS_VELOCITY: boolean;
  21613. PREPASS_VELOCITY_INDEX: number;
  21614. PREPASS_REFLECTIVITY: boolean;
  21615. PREPASS_REFLECTIVITY_INDEX: number;
  21616. SCENE_MRT_COUNT: number;
  21617. NUM_BONE_INFLUENCERS: number;
  21618. BonesPerMesh: number;
  21619. BONETEXTURE: boolean;
  21620. BONES_VELOCITY_ENABLED: boolean;
  21621. NONUNIFORMSCALING: boolean;
  21622. MORPHTARGETS: boolean;
  21623. MORPHTARGETS_NORMAL: boolean;
  21624. MORPHTARGETS_TANGENT: boolean;
  21625. MORPHTARGETS_UV: boolean;
  21626. NUM_MORPH_INFLUENCERS: number;
  21627. IMAGEPROCESSING: boolean;
  21628. VIGNETTE: boolean;
  21629. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21630. VIGNETTEBLENDMODEOPAQUE: boolean;
  21631. TONEMAPPING: boolean;
  21632. TONEMAPPING_ACES: boolean;
  21633. CONTRAST: boolean;
  21634. COLORCURVES: boolean;
  21635. COLORGRADING: boolean;
  21636. COLORGRADING3D: boolean;
  21637. SAMPLER3DGREENDEPTH: boolean;
  21638. SAMPLER3DBGRMAP: boolean;
  21639. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21640. EXPOSURE: boolean;
  21641. MULTIVIEW: boolean;
  21642. USEPHYSICALLIGHTFALLOFF: boolean;
  21643. USEGLTFLIGHTFALLOFF: boolean;
  21644. TWOSIDEDLIGHTING: boolean;
  21645. SHADOWFLOAT: boolean;
  21646. CLIPPLANE: boolean;
  21647. CLIPPLANE2: boolean;
  21648. CLIPPLANE3: boolean;
  21649. CLIPPLANE4: boolean;
  21650. CLIPPLANE5: boolean;
  21651. CLIPPLANE6: boolean;
  21652. POINTSIZE: boolean;
  21653. FOG: boolean;
  21654. LOGARITHMICDEPTH: boolean;
  21655. FORCENORMALFORWARD: boolean;
  21656. SPECULARAA: boolean;
  21657. CLEARCOAT: boolean;
  21658. CLEARCOAT_DEFAULTIOR: boolean;
  21659. CLEARCOAT_TEXTURE: boolean;
  21660. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21661. CLEARCOAT_TEXTUREDIRECTUV: number;
  21662. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21663. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21664. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21665. CLEARCOAT_BUMP: boolean;
  21666. CLEARCOAT_BUMPDIRECTUV: number;
  21667. CLEARCOAT_REMAP_F0: boolean;
  21668. CLEARCOAT_TINT: boolean;
  21669. CLEARCOAT_TINT_TEXTURE: boolean;
  21670. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21671. ANISOTROPIC: boolean;
  21672. ANISOTROPIC_TEXTURE: boolean;
  21673. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21674. BRDF_V_HEIGHT_CORRELATED: boolean;
  21675. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21676. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21677. SHEEN: boolean;
  21678. SHEEN_TEXTURE: boolean;
  21679. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21680. SHEEN_TEXTUREDIRECTUV: number;
  21681. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21682. SHEEN_LINKWITHALBEDO: boolean;
  21683. SHEEN_ROUGHNESS: boolean;
  21684. SHEEN_ALBEDOSCALING: boolean;
  21685. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21686. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21687. SUBSURFACE: boolean;
  21688. SS_REFRACTION: boolean;
  21689. SS_TRANSLUCENCY: boolean;
  21690. SS_SCATTERING: boolean;
  21691. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21692. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21693. SS_REFRACTIONMAP_3D: boolean;
  21694. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21695. SS_LODINREFRACTIONALPHA: boolean;
  21696. SS_GAMMAREFRACTION: boolean;
  21697. SS_RGBDREFRACTION: boolean;
  21698. SS_LINEARSPECULARREFRACTION: boolean;
  21699. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21700. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21701. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21702. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21703. UNLIT: boolean;
  21704. DEBUGMODE: number;
  21705. /**
  21706. * Initializes the PBR Material defines.
  21707. */
  21708. constructor();
  21709. /**
  21710. * Resets the PBR Material defines.
  21711. */
  21712. reset(): void;
  21713. }
  21714. /**
  21715. * The Physically based material base class of BJS.
  21716. *
  21717. * This offers the main features of a standard PBR material.
  21718. * For more information, please refer to the documentation :
  21719. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21720. */
  21721. export abstract class PBRBaseMaterial extends PushMaterial {
  21722. /**
  21723. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21724. */
  21725. static readonly PBRMATERIAL_OPAQUE: number;
  21726. /**
  21727. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21728. */
  21729. static readonly PBRMATERIAL_ALPHATEST: number;
  21730. /**
  21731. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21732. */
  21733. static readonly PBRMATERIAL_ALPHABLEND: number;
  21734. /**
  21735. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21736. * They are also discarded below the alpha cutoff threshold to improve performances.
  21737. */
  21738. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21739. /**
  21740. * Defines the default value of how much AO map is occluding the analytical lights
  21741. * (point spot...).
  21742. */
  21743. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21744. /**
  21745. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21746. */
  21747. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21748. /**
  21749. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21750. * to enhance interoperability with other engines.
  21751. */
  21752. static readonly LIGHTFALLOFF_GLTF: number;
  21753. /**
  21754. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21755. * to enhance interoperability with other materials.
  21756. */
  21757. static readonly LIGHTFALLOFF_STANDARD: number;
  21758. /**
  21759. * Intensity of the direct lights e.g. the four lights available in your scene.
  21760. * This impacts both the direct diffuse and specular highlights.
  21761. */
  21762. protected _directIntensity: number;
  21763. /**
  21764. * Intensity of the emissive part of the material.
  21765. * This helps controlling the emissive effect without modifying the emissive color.
  21766. */
  21767. protected _emissiveIntensity: number;
  21768. /**
  21769. * Intensity of the environment e.g. how much the environment will light the object
  21770. * either through harmonics for rough material or through the refelction for shiny ones.
  21771. */
  21772. protected _environmentIntensity: number;
  21773. /**
  21774. * This is a special control allowing the reduction of the specular highlights coming from the
  21775. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21776. */
  21777. protected _specularIntensity: number;
  21778. /**
  21779. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21780. */
  21781. private _lightingInfos;
  21782. /**
  21783. * Debug Control allowing disabling the bump map on this material.
  21784. */
  21785. protected _disableBumpMap: boolean;
  21786. /**
  21787. * AKA Diffuse Texture in standard nomenclature.
  21788. */
  21789. protected _albedoTexture: Nullable<BaseTexture>;
  21790. /**
  21791. * AKA Occlusion Texture in other nomenclature.
  21792. */
  21793. protected _ambientTexture: Nullable<BaseTexture>;
  21794. /**
  21795. * AKA Occlusion Texture Intensity in other nomenclature.
  21796. */
  21797. protected _ambientTextureStrength: number;
  21798. /**
  21799. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21800. * 1 means it completely occludes it
  21801. * 0 mean it has no impact
  21802. */
  21803. protected _ambientTextureImpactOnAnalyticalLights: number;
  21804. /**
  21805. * Stores the alpha values in a texture.
  21806. */
  21807. protected _opacityTexture: Nullable<BaseTexture>;
  21808. /**
  21809. * Stores the reflection values in a texture.
  21810. */
  21811. protected _reflectionTexture: Nullable<BaseTexture>;
  21812. /**
  21813. * Stores the emissive values in a texture.
  21814. */
  21815. protected _emissiveTexture: Nullable<BaseTexture>;
  21816. /**
  21817. * AKA Specular texture in other nomenclature.
  21818. */
  21819. protected _reflectivityTexture: Nullable<BaseTexture>;
  21820. /**
  21821. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21822. */
  21823. protected _metallicTexture: Nullable<BaseTexture>;
  21824. /**
  21825. * Specifies the metallic scalar of the metallic/roughness workflow.
  21826. * Can also be used to scale the metalness values of the metallic texture.
  21827. */
  21828. protected _metallic: Nullable<number>;
  21829. /**
  21830. * Specifies the roughness scalar of the metallic/roughness workflow.
  21831. * Can also be used to scale the roughness values of the metallic texture.
  21832. */
  21833. protected _roughness: Nullable<number>;
  21834. /**
  21835. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21836. * By default the indexOfrefraction is used to compute F0;
  21837. *
  21838. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21839. *
  21840. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21841. * F90 = metallicReflectanceColor;
  21842. */
  21843. protected _metallicF0Factor: number;
  21844. /**
  21845. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21846. * By default the F90 is always 1;
  21847. *
  21848. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21849. *
  21850. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21851. * F90 = metallicReflectanceColor;
  21852. */
  21853. protected _metallicReflectanceColor: Color3;
  21854. /**
  21855. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21856. * This is multiply against the scalar values defined in the material.
  21857. */
  21858. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21859. /**
  21860. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21861. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21862. */
  21863. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21864. /**
  21865. * Stores surface normal data used to displace a mesh in a texture.
  21866. */
  21867. protected _bumpTexture: Nullable<BaseTexture>;
  21868. /**
  21869. * Stores the pre-calculated light information of a mesh in a texture.
  21870. */
  21871. protected _lightmapTexture: Nullable<BaseTexture>;
  21872. /**
  21873. * The color of a material in ambient lighting.
  21874. */
  21875. protected _ambientColor: Color3;
  21876. /**
  21877. * AKA Diffuse Color in other nomenclature.
  21878. */
  21879. protected _albedoColor: Color3;
  21880. /**
  21881. * AKA Specular Color in other nomenclature.
  21882. */
  21883. protected _reflectivityColor: Color3;
  21884. /**
  21885. * The color applied when light is reflected from a material.
  21886. */
  21887. protected _reflectionColor: Color3;
  21888. /**
  21889. * The color applied when light is emitted from a material.
  21890. */
  21891. protected _emissiveColor: Color3;
  21892. /**
  21893. * AKA Glossiness in other nomenclature.
  21894. */
  21895. protected _microSurface: number;
  21896. /**
  21897. * Specifies that the material will use the light map as a show map.
  21898. */
  21899. protected _useLightmapAsShadowmap: boolean;
  21900. /**
  21901. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21902. * makes the reflect vector face the model (under horizon).
  21903. */
  21904. protected _useHorizonOcclusion: boolean;
  21905. /**
  21906. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21907. * too much the area relying on ambient texture to define their ambient occlusion.
  21908. */
  21909. protected _useRadianceOcclusion: boolean;
  21910. /**
  21911. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21912. */
  21913. protected _useAlphaFromAlbedoTexture: boolean;
  21914. /**
  21915. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21916. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21917. */
  21918. protected _useSpecularOverAlpha: boolean;
  21919. /**
  21920. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21921. */
  21922. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21923. /**
  21924. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21925. */
  21926. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21927. /**
  21928. * Specifies if the metallic texture contains the roughness information in its green channel.
  21929. */
  21930. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21931. /**
  21932. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21933. */
  21934. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21935. /**
  21936. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21937. */
  21938. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21939. /**
  21940. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21941. */
  21942. protected _useAmbientInGrayScale: boolean;
  21943. /**
  21944. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21945. * The material will try to infer what glossiness each pixel should be.
  21946. */
  21947. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21948. /**
  21949. * Defines the falloff type used in this material.
  21950. * It by default is Physical.
  21951. */
  21952. protected _lightFalloff: number;
  21953. /**
  21954. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21955. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21956. */
  21957. protected _useRadianceOverAlpha: boolean;
  21958. /**
  21959. * Allows using an object space normal map (instead of tangent space).
  21960. */
  21961. protected _useObjectSpaceNormalMap: boolean;
  21962. /**
  21963. * Allows using the bump map in parallax mode.
  21964. */
  21965. protected _useParallax: boolean;
  21966. /**
  21967. * Allows using the bump map in parallax occlusion mode.
  21968. */
  21969. protected _useParallaxOcclusion: boolean;
  21970. /**
  21971. * Controls the scale bias of the parallax mode.
  21972. */
  21973. protected _parallaxScaleBias: number;
  21974. /**
  21975. * If sets to true, disables all the lights affecting the material.
  21976. */
  21977. protected _disableLighting: boolean;
  21978. /**
  21979. * Number of Simultaneous lights allowed on the material.
  21980. */
  21981. protected _maxSimultaneousLights: number;
  21982. /**
  21983. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21984. */
  21985. protected _invertNormalMapX: boolean;
  21986. /**
  21987. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21988. */
  21989. protected _invertNormalMapY: boolean;
  21990. /**
  21991. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21992. */
  21993. protected _twoSidedLighting: boolean;
  21994. /**
  21995. * Defines the alpha limits in alpha test mode.
  21996. */
  21997. protected _alphaCutOff: number;
  21998. /**
  21999. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22000. */
  22001. protected _forceAlphaTest: boolean;
  22002. /**
  22003. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22004. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22005. */
  22006. protected _useAlphaFresnel: boolean;
  22007. /**
  22008. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22009. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22010. */
  22011. protected _useLinearAlphaFresnel: boolean;
  22012. /**
  22013. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22014. * from cos thetav and roughness:
  22015. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22016. */
  22017. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22018. /**
  22019. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22020. */
  22021. protected _forceIrradianceInFragment: boolean;
  22022. private _realTimeFiltering;
  22023. /**
  22024. * Enables realtime filtering on the texture.
  22025. */
  22026. get realTimeFiltering(): boolean;
  22027. set realTimeFiltering(b: boolean);
  22028. private _realTimeFilteringQuality;
  22029. /**
  22030. * Quality switch for realtime filtering
  22031. */
  22032. get realTimeFilteringQuality(): number;
  22033. set realTimeFilteringQuality(n: number);
  22034. /**
  22035. * Can this material render to several textures at once
  22036. */
  22037. get canRenderToMRT(): boolean;
  22038. /**
  22039. * Force normal to face away from face.
  22040. */
  22041. protected _forceNormalForward: boolean;
  22042. /**
  22043. * Enables specular anti aliasing in the PBR shader.
  22044. * It will both interacts on the Geometry for analytical and IBL lighting.
  22045. * It also prefilter the roughness map based on the bump values.
  22046. */
  22047. protected _enableSpecularAntiAliasing: boolean;
  22048. /**
  22049. * Default configuration related to image processing available in the PBR Material.
  22050. */
  22051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22052. /**
  22053. * Keep track of the image processing observer to allow dispose and replace.
  22054. */
  22055. private _imageProcessingObserver;
  22056. /**
  22057. * Attaches a new image processing configuration to the PBR Material.
  22058. * @param configuration
  22059. */
  22060. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22061. /**
  22062. * Stores the available render targets.
  22063. */
  22064. private _renderTargets;
  22065. /**
  22066. * Sets the global ambient color for the material used in lighting calculations.
  22067. */
  22068. private _globalAmbientColor;
  22069. /**
  22070. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22071. */
  22072. private _useLogarithmicDepth;
  22073. /**
  22074. * If set to true, no lighting calculations will be applied.
  22075. */
  22076. private _unlit;
  22077. private _debugMode;
  22078. /**
  22079. * @hidden
  22080. * This is reserved for the inspector.
  22081. * Defines the material debug mode.
  22082. * It helps seeing only some components of the material while troubleshooting.
  22083. */
  22084. debugMode: number;
  22085. /**
  22086. * @hidden
  22087. * This is reserved for the inspector.
  22088. * Specify from where on screen the debug mode should start.
  22089. * The value goes from -1 (full screen) to 1 (not visible)
  22090. * It helps with side by side comparison against the final render
  22091. * This defaults to -1
  22092. */
  22093. private debugLimit;
  22094. /**
  22095. * @hidden
  22096. * This is reserved for the inspector.
  22097. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22098. * You can use the factor to better multiply the final value.
  22099. */
  22100. private debugFactor;
  22101. /**
  22102. * Defines the clear coat layer parameters for the material.
  22103. */
  22104. readonly clearCoat: PBRClearCoatConfiguration;
  22105. /**
  22106. * Defines the anisotropic parameters for the material.
  22107. */
  22108. readonly anisotropy: PBRAnisotropicConfiguration;
  22109. /**
  22110. * Defines the BRDF parameters for the material.
  22111. */
  22112. readonly brdf: PBRBRDFConfiguration;
  22113. /**
  22114. * Defines the Sheen parameters for the material.
  22115. */
  22116. readonly sheen: PBRSheenConfiguration;
  22117. /**
  22118. * Defines the SubSurface parameters for the material.
  22119. */
  22120. readonly subSurface: PBRSubSurfaceConfiguration;
  22121. /**
  22122. * Defines additionnal PrePass parameters for the material.
  22123. */
  22124. readonly prePassConfiguration: PrePassConfiguration;
  22125. /**
  22126. * Defines the detail map parameters for the material.
  22127. */
  22128. readonly detailMap: DetailMapConfiguration;
  22129. protected _rebuildInParallel: boolean;
  22130. /**
  22131. * Instantiates a new PBRMaterial instance.
  22132. *
  22133. * @param name The material name
  22134. * @param scene The scene the material will be use in.
  22135. */
  22136. constructor(name: string, scene: Scene);
  22137. /**
  22138. * Gets a boolean indicating that current material needs to register RTT
  22139. */
  22140. get hasRenderTargetTextures(): boolean;
  22141. /**
  22142. * Gets the name of the material class.
  22143. */
  22144. getClassName(): string;
  22145. /**
  22146. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22147. */
  22148. get useLogarithmicDepth(): boolean;
  22149. /**
  22150. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22151. */
  22152. set useLogarithmicDepth(value: boolean);
  22153. /**
  22154. * Returns true if alpha blending should be disabled.
  22155. */
  22156. protected get _disableAlphaBlending(): boolean;
  22157. /**
  22158. * Specifies whether or not this material should be rendered in alpha blend mode.
  22159. */
  22160. needAlphaBlending(): boolean;
  22161. /**
  22162. * Specifies whether or not this material should be rendered in alpha test mode.
  22163. */
  22164. needAlphaTesting(): boolean;
  22165. /**
  22166. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22167. */
  22168. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22169. /**
  22170. * Specifies whether or not there is a usable alpha channel for transparency.
  22171. */
  22172. protected _hasAlphaChannel(): boolean;
  22173. /**
  22174. * Gets the texture used for the alpha test.
  22175. */
  22176. getAlphaTestTexture(): Nullable<BaseTexture>;
  22177. /**
  22178. * Specifies that the submesh is ready to be used.
  22179. * @param mesh - BJS mesh.
  22180. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22181. * @param useInstances - Specifies that instances should be used.
  22182. * @returns - boolean indicating that the submesh is ready or not.
  22183. */
  22184. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22185. /**
  22186. * Specifies if the material uses metallic roughness workflow.
  22187. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22188. */
  22189. isMetallicWorkflow(): boolean;
  22190. private _prepareEffect;
  22191. private _prepareDefines;
  22192. /**
  22193. * Force shader compilation
  22194. */
  22195. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22196. /**
  22197. * Initializes the uniform buffer layout for the shader.
  22198. */
  22199. buildUniformLayout(): void;
  22200. /**
  22201. * Unbinds the material from the mesh
  22202. */
  22203. unbind(): void;
  22204. /**
  22205. * Binds the submesh data.
  22206. * @param world - The world matrix.
  22207. * @param mesh - The BJS mesh.
  22208. * @param subMesh - A submesh of the BJS mesh.
  22209. */
  22210. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22211. /**
  22212. * Returns the animatable textures.
  22213. * @returns - Array of animatable textures.
  22214. */
  22215. getAnimatables(): IAnimatable[];
  22216. /**
  22217. * Returns the texture used for reflections.
  22218. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22219. */
  22220. private _getReflectionTexture;
  22221. /**
  22222. * Returns an array of the actively used textures.
  22223. * @returns - Array of BaseTextures
  22224. */
  22225. getActiveTextures(): BaseTexture[];
  22226. /**
  22227. * Checks to see if a texture is used in the material.
  22228. * @param texture - Base texture to use.
  22229. * @returns - Boolean specifying if a texture is used in the material.
  22230. */
  22231. hasTexture(texture: BaseTexture): boolean;
  22232. /**
  22233. * Sets the required values to the prepass renderer.
  22234. * @param prePassRenderer defines the prepass renderer to setup
  22235. */
  22236. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22237. /**
  22238. * Disposes the resources of the material.
  22239. * @param forceDisposeEffect - Forces the disposal of effects.
  22240. * @param forceDisposeTextures - Forces the disposal of all textures.
  22241. */
  22242. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22243. }
  22244. }
  22245. declare module BABYLON {
  22246. /**
  22247. * The Physically based material of BJS.
  22248. *
  22249. * This offers the main features of a standard PBR material.
  22250. * For more information, please refer to the documentation :
  22251. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22252. */
  22253. export class PBRMaterial extends PBRBaseMaterial {
  22254. /**
  22255. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22256. */
  22257. static readonly PBRMATERIAL_OPAQUE: number;
  22258. /**
  22259. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22260. */
  22261. static readonly PBRMATERIAL_ALPHATEST: number;
  22262. /**
  22263. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22264. */
  22265. static readonly PBRMATERIAL_ALPHABLEND: number;
  22266. /**
  22267. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22268. * They are also discarded below the alpha cutoff threshold to improve performances.
  22269. */
  22270. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22271. /**
  22272. * Defines the default value of how much AO map is occluding the analytical lights
  22273. * (point spot...).
  22274. */
  22275. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22276. /**
  22277. * Intensity of the direct lights e.g. the four lights available in your scene.
  22278. * This impacts both the direct diffuse and specular highlights.
  22279. */
  22280. directIntensity: number;
  22281. /**
  22282. * Intensity of the emissive part of the material.
  22283. * This helps controlling the emissive effect without modifying the emissive color.
  22284. */
  22285. emissiveIntensity: number;
  22286. /**
  22287. * Intensity of the environment e.g. how much the environment will light the object
  22288. * either through harmonics for rough material or through the refelction for shiny ones.
  22289. */
  22290. environmentIntensity: number;
  22291. /**
  22292. * This is a special control allowing the reduction of the specular highlights coming from the
  22293. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22294. */
  22295. specularIntensity: number;
  22296. /**
  22297. * Debug Control allowing disabling the bump map on this material.
  22298. */
  22299. disableBumpMap: boolean;
  22300. /**
  22301. * AKA Diffuse Texture in standard nomenclature.
  22302. */
  22303. albedoTexture: BaseTexture;
  22304. /**
  22305. * AKA Occlusion Texture in other nomenclature.
  22306. */
  22307. ambientTexture: BaseTexture;
  22308. /**
  22309. * AKA Occlusion Texture Intensity in other nomenclature.
  22310. */
  22311. ambientTextureStrength: number;
  22312. /**
  22313. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22314. * 1 means it completely occludes it
  22315. * 0 mean it has no impact
  22316. */
  22317. ambientTextureImpactOnAnalyticalLights: number;
  22318. /**
  22319. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22320. */
  22321. opacityTexture: BaseTexture;
  22322. /**
  22323. * Stores the reflection values in a texture.
  22324. */
  22325. reflectionTexture: Nullable<BaseTexture>;
  22326. /**
  22327. * Stores the emissive values in a texture.
  22328. */
  22329. emissiveTexture: BaseTexture;
  22330. /**
  22331. * AKA Specular texture in other nomenclature.
  22332. */
  22333. reflectivityTexture: BaseTexture;
  22334. /**
  22335. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22336. */
  22337. metallicTexture: BaseTexture;
  22338. /**
  22339. * Specifies the metallic scalar of the metallic/roughness workflow.
  22340. * Can also be used to scale the metalness values of the metallic texture.
  22341. */
  22342. metallic: Nullable<number>;
  22343. /**
  22344. * Specifies the roughness scalar of the metallic/roughness workflow.
  22345. * Can also be used to scale the roughness values of the metallic texture.
  22346. */
  22347. roughness: Nullable<number>;
  22348. /**
  22349. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22350. * By default the indexOfrefraction is used to compute F0;
  22351. *
  22352. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22353. *
  22354. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22355. * F90 = metallicReflectanceColor;
  22356. */
  22357. metallicF0Factor: number;
  22358. /**
  22359. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22360. * By default the F90 is always 1;
  22361. *
  22362. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22363. *
  22364. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22365. * F90 = metallicReflectanceColor;
  22366. */
  22367. metallicReflectanceColor: Color3;
  22368. /**
  22369. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22370. * This is multiply against the scalar values defined in the material.
  22371. */
  22372. metallicReflectanceTexture: Nullable<BaseTexture>;
  22373. /**
  22374. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22375. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22376. */
  22377. microSurfaceTexture: BaseTexture;
  22378. /**
  22379. * Stores surface normal data used to displace a mesh in a texture.
  22380. */
  22381. bumpTexture: BaseTexture;
  22382. /**
  22383. * Stores the pre-calculated light information of a mesh in a texture.
  22384. */
  22385. lightmapTexture: BaseTexture;
  22386. /**
  22387. * Stores the refracted light information in a texture.
  22388. */
  22389. get refractionTexture(): Nullable<BaseTexture>;
  22390. set refractionTexture(value: Nullable<BaseTexture>);
  22391. /**
  22392. * The color of a material in ambient lighting.
  22393. */
  22394. ambientColor: Color3;
  22395. /**
  22396. * AKA Diffuse Color in other nomenclature.
  22397. */
  22398. albedoColor: Color3;
  22399. /**
  22400. * AKA Specular Color in other nomenclature.
  22401. */
  22402. reflectivityColor: Color3;
  22403. /**
  22404. * The color reflected from the material.
  22405. */
  22406. reflectionColor: Color3;
  22407. /**
  22408. * The color emitted from the material.
  22409. */
  22410. emissiveColor: Color3;
  22411. /**
  22412. * AKA Glossiness in other nomenclature.
  22413. */
  22414. microSurface: number;
  22415. /**
  22416. * Index of refraction of the material base layer.
  22417. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22418. *
  22419. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22420. *
  22421. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22422. */
  22423. get indexOfRefraction(): number;
  22424. set indexOfRefraction(value: number);
  22425. /**
  22426. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22427. */
  22428. get invertRefractionY(): boolean;
  22429. set invertRefractionY(value: boolean);
  22430. /**
  22431. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22432. * Materials half opaque for instance using refraction could benefit from this control.
  22433. */
  22434. get linkRefractionWithTransparency(): boolean;
  22435. set linkRefractionWithTransparency(value: boolean);
  22436. /**
  22437. * If true, the light map contains occlusion information instead of lighting info.
  22438. */
  22439. useLightmapAsShadowmap: boolean;
  22440. /**
  22441. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22442. */
  22443. useAlphaFromAlbedoTexture: boolean;
  22444. /**
  22445. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22446. */
  22447. forceAlphaTest: boolean;
  22448. /**
  22449. * Defines the alpha limits in alpha test mode.
  22450. */
  22451. alphaCutOff: number;
  22452. /**
  22453. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22454. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22455. */
  22456. useSpecularOverAlpha: boolean;
  22457. /**
  22458. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22459. */
  22460. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22461. /**
  22462. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22463. */
  22464. useRoughnessFromMetallicTextureAlpha: boolean;
  22465. /**
  22466. * Specifies if the metallic texture contains the roughness information in its green channel.
  22467. */
  22468. useRoughnessFromMetallicTextureGreen: boolean;
  22469. /**
  22470. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22471. */
  22472. useMetallnessFromMetallicTextureBlue: boolean;
  22473. /**
  22474. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22475. */
  22476. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22477. /**
  22478. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22479. */
  22480. useAmbientInGrayScale: boolean;
  22481. /**
  22482. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22483. * The material will try to infer what glossiness each pixel should be.
  22484. */
  22485. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22486. /**
  22487. * BJS is using an harcoded light falloff based on a manually sets up range.
  22488. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22489. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22490. */
  22491. get usePhysicalLightFalloff(): boolean;
  22492. /**
  22493. * BJS is using an harcoded light falloff based on a manually sets up range.
  22494. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22495. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22496. */
  22497. set usePhysicalLightFalloff(value: boolean);
  22498. /**
  22499. * In order to support the falloff compatibility with gltf, a special mode has been added
  22500. * to reproduce the gltf light falloff.
  22501. */
  22502. get useGLTFLightFalloff(): boolean;
  22503. /**
  22504. * In order to support the falloff compatibility with gltf, a special mode has been added
  22505. * to reproduce the gltf light falloff.
  22506. */
  22507. set useGLTFLightFalloff(value: boolean);
  22508. /**
  22509. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22510. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22511. */
  22512. useRadianceOverAlpha: boolean;
  22513. /**
  22514. * Allows using an object space normal map (instead of tangent space).
  22515. */
  22516. useObjectSpaceNormalMap: boolean;
  22517. /**
  22518. * Allows using the bump map in parallax mode.
  22519. */
  22520. useParallax: boolean;
  22521. /**
  22522. * Allows using the bump map in parallax occlusion mode.
  22523. */
  22524. useParallaxOcclusion: boolean;
  22525. /**
  22526. * Controls the scale bias of the parallax mode.
  22527. */
  22528. parallaxScaleBias: number;
  22529. /**
  22530. * If sets to true, disables all the lights affecting the material.
  22531. */
  22532. disableLighting: boolean;
  22533. /**
  22534. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22535. */
  22536. forceIrradianceInFragment: boolean;
  22537. /**
  22538. * Number of Simultaneous lights allowed on the material.
  22539. */
  22540. maxSimultaneousLights: number;
  22541. /**
  22542. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22543. */
  22544. invertNormalMapX: boolean;
  22545. /**
  22546. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22547. */
  22548. invertNormalMapY: boolean;
  22549. /**
  22550. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22551. */
  22552. twoSidedLighting: boolean;
  22553. /**
  22554. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22555. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22556. */
  22557. useAlphaFresnel: boolean;
  22558. /**
  22559. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22560. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22561. */
  22562. useLinearAlphaFresnel: boolean;
  22563. /**
  22564. * Let user defines the brdf lookup texture used for IBL.
  22565. * A default 8bit version is embedded but you could point at :
  22566. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22567. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22568. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22569. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22570. */
  22571. environmentBRDFTexture: Nullable<BaseTexture>;
  22572. /**
  22573. * Force normal to face away from face.
  22574. */
  22575. forceNormalForward: boolean;
  22576. /**
  22577. * Enables specular anti aliasing in the PBR shader.
  22578. * It will both interacts on the Geometry for analytical and IBL lighting.
  22579. * It also prefilter the roughness map based on the bump values.
  22580. */
  22581. enableSpecularAntiAliasing: boolean;
  22582. /**
  22583. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22584. * makes the reflect vector face the model (under horizon).
  22585. */
  22586. useHorizonOcclusion: boolean;
  22587. /**
  22588. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22589. * too much the area relying on ambient texture to define their ambient occlusion.
  22590. */
  22591. useRadianceOcclusion: boolean;
  22592. /**
  22593. * If set to true, no lighting calculations will be applied.
  22594. */
  22595. unlit: boolean;
  22596. /**
  22597. * Gets the image processing configuration used either in this material.
  22598. */
  22599. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22600. /**
  22601. * Sets the Default image processing configuration used either in the this material.
  22602. *
  22603. * If sets to null, the scene one is in use.
  22604. */
  22605. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22606. /**
  22607. * Gets wether the color curves effect is enabled.
  22608. */
  22609. get cameraColorCurvesEnabled(): boolean;
  22610. /**
  22611. * Sets wether the color curves effect is enabled.
  22612. */
  22613. set cameraColorCurvesEnabled(value: boolean);
  22614. /**
  22615. * Gets wether the color grading effect is enabled.
  22616. */
  22617. get cameraColorGradingEnabled(): boolean;
  22618. /**
  22619. * Gets wether the color grading effect is enabled.
  22620. */
  22621. set cameraColorGradingEnabled(value: boolean);
  22622. /**
  22623. * Gets wether tonemapping is enabled or not.
  22624. */
  22625. get cameraToneMappingEnabled(): boolean;
  22626. /**
  22627. * Sets wether tonemapping is enabled or not
  22628. */
  22629. set cameraToneMappingEnabled(value: boolean);
  22630. /**
  22631. * The camera exposure used on this material.
  22632. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22633. * This corresponds to a photographic exposure.
  22634. */
  22635. get cameraExposure(): number;
  22636. /**
  22637. * The camera exposure used on this material.
  22638. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22639. * This corresponds to a photographic exposure.
  22640. */
  22641. set cameraExposure(value: number);
  22642. /**
  22643. * Gets The camera contrast used on this material.
  22644. */
  22645. get cameraContrast(): number;
  22646. /**
  22647. * Sets The camera contrast used on this material.
  22648. */
  22649. set cameraContrast(value: number);
  22650. /**
  22651. * Gets the Color Grading 2D Lookup Texture.
  22652. */
  22653. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22654. /**
  22655. * Sets the Color Grading 2D Lookup Texture.
  22656. */
  22657. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22658. /**
  22659. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22660. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22661. * 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;
  22662. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22663. */
  22664. get cameraColorCurves(): Nullable<ColorCurves>;
  22665. /**
  22666. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22667. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22668. * 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;
  22669. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22670. */
  22671. set cameraColorCurves(value: Nullable<ColorCurves>);
  22672. /**
  22673. * Instantiates a new PBRMaterial instance.
  22674. *
  22675. * @param name The material name
  22676. * @param scene The scene the material will be use in.
  22677. */
  22678. constructor(name: string, scene: Scene);
  22679. /**
  22680. * Returns the name of this material class.
  22681. */
  22682. getClassName(): string;
  22683. /**
  22684. * Makes a duplicate of the current material.
  22685. * @param name - name to use for the new material.
  22686. */
  22687. clone(name: string): PBRMaterial;
  22688. /**
  22689. * Serializes this PBR Material.
  22690. * @returns - An object with the serialized material.
  22691. */
  22692. serialize(): any;
  22693. /**
  22694. * Parses a PBR Material from a serialized object.
  22695. * @param source - Serialized object.
  22696. * @param scene - BJS scene instance.
  22697. * @param rootUrl - url for the scene object
  22698. * @returns - PBRMaterial
  22699. */
  22700. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22701. }
  22702. }
  22703. declare module BABYLON {
  22704. /** @hidden */
  22705. export var mrtFragmentDeclaration: {
  22706. name: string;
  22707. shader: string;
  22708. };
  22709. }
  22710. declare module BABYLON {
  22711. /** @hidden */
  22712. export var geometryPixelShader: {
  22713. name: string;
  22714. shader: string;
  22715. };
  22716. }
  22717. declare module BABYLON {
  22718. /** @hidden */
  22719. export var instancesDeclaration: {
  22720. name: string;
  22721. shader: string;
  22722. };
  22723. }
  22724. declare module BABYLON {
  22725. /** @hidden */
  22726. export var geometryVertexShader: {
  22727. name: string;
  22728. shader: string;
  22729. };
  22730. }
  22731. declare module BABYLON {
  22732. /** @hidden */
  22733. interface ISavedTransformationMatrix {
  22734. world: Matrix;
  22735. viewProjection: Matrix;
  22736. }
  22737. /**
  22738. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22739. */
  22740. export class GeometryBufferRenderer {
  22741. /**
  22742. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22743. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22744. */
  22745. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22746. /**
  22747. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22748. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22749. */
  22750. static readonly POSITION_TEXTURE_TYPE: number;
  22751. /**
  22752. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22753. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22754. */
  22755. static readonly VELOCITY_TEXTURE_TYPE: number;
  22756. /**
  22757. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22758. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22759. */
  22760. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22761. /**
  22762. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22763. * in order to compute objects velocities when enableVelocity is set to "true"
  22764. * @hidden
  22765. */
  22766. _previousTransformationMatrices: {
  22767. [index: number]: ISavedTransformationMatrix;
  22768. };
  22769. /**
  22770. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22771. * in order to compute objects velocities when enableVelocity is set to "true"
  22772. * @hidden
  22773. */
  22774. _previousBonesTransformationMatrices: {
  22775. [index: number]: Float32Array;
  22776. };
  22777. /**
  22778. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22779. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22780. */
  22781. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22782. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22783. renderTransparentMeshes: boolean;
  22784. private _scene;
  22785. private _resizeObserver;
  22786. private _multiRenderTarget;
  22787. private _ratio;
  22788. private _enablePosition;
  22789. private _enableVelocity;
  22790. private _enableReflectivity;
  22791. private _positionIndex;
  22792. private _velocityIndex;
  22793. private _reflectivityIndex;
  22794. private _depthNormalIndex;
  22795. private _linkedWithPrePass;
  22796. private _prePassRenderer;
  22797. private _attachments;
  22798. protected _effect: Effect;
  22799. protected _cachedDefines: string;
  22800. /**
  22801. * @hidden
  22802. * Sets up internal structures to share outputs with PrePassRenderer
  22803. * This method should only be called by the PrePassRenderer itself
  22804. */
  22805. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22806. /**
  22807. * @hidden
  22808. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22809. * This method should only be called by the PrePassRenderer itself
  22810. */
  22811. _unlinkPrePassRenderer(): void;
  22812. /**
  22813. * @hidden
  22814. * Resets the geometry buffer layout
  22815. */
  22816. _resetLayout(): void;
  22817. /**
  22818. * @hidden
  22819. * Replaces a texture in the geometry buffer renderer
  22820. * Useful when linking textures of the prepass renderer
  22821. */
  22822. _forceTextureType(geometryBufferType: number, index: number): void;
  22823. /**
  22824. * @hidden
  22825. * Sets texture attachments
  22826. * Useful when linking textures of the prepass renderer
  22827. */
  22828. _setAttachments(attachments: number[]): void;
  22829. /**
  22830. * @hidden
  22831. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22832. * Useful when linking textures of the prepass renderer
  22833. */
  22834. _linkInternalTexture(internalTexture: InternalTexture): void;
  22835. /**
  22836. * Gets the render list (meshes to be rendered) used in the G buffer.
  22837. */
  22838. get renderList(): Nullable<AbstractMesh[]>;
  22839. /**
  22840. * Set the render list (meshes to be rendered) used in the G buffer.
  22841. */
  22842. set renderList(meshes: Nullable<AbstractMesh[]>);
  22843. /**
  22844. * Gets wether or not G buffer are supported by the running hardware.
  22845. * This requires draw buffer supports
  22846. */
  22847. get isSupported(): boolean;
  22848. /**
  22849. * Returns the index of the given texture type in the G-Buffer textures array
  22850. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22851. * @returns the index of the given texture type in the G-Buffer textures array
  22852. */
  22853. getTextureIndex(textureType: number): number;
  22854. /**
  22855. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22856. */
  22857. get enablePosition(): boolean;
  22858. /**
  22859. * Sets whether or not objects positions are enabled for the G buffer.
  22860. */
  22861. set enablePosition(enable: boolean);
  22862. /**
  22863. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22864. */
  22865. get enableVelocity(): boolean;
  22866. /**
  22867. * Sets wether or not objects velocities are enabled for the G buffer.
  22868. */
  22869. set enableVelocity(enable: boolean);
  22870. /**
  22871. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22872. */
  22873. get enableReflectivity(): boolean;
  22874. /**
  22875. * Sets wether or not objects roughness are enabled for the G buffer.
  22876. */
  22877. set enableReflectivity(enable: boolean);
  22878. /**
  22879. * Gets the scene associated with the buffer.
  22880. */
  22881. get scene(): Scene;
  22882. /**
  22883. * Gets the ratio used by the buffer during its creation.
  22884. * How big is the buffer related to the main canvas.
  22885. */
  22886. get ratio(): number;
  22887. /** @hidden */
  22888. static _SceneComponentInitialization: (scene: Scene) => void;
  22889. /**
  22890. * Creates a new G Buffer for the scene
  22891. * @param scene The scene the buffer belongs to
  22892. * @param ratio How big is the buffer related to the main canvas.
  22893. */
  22894. constructor(scene: Scene, ratio?: number);
  22895. /**
  22896. * Checks wether everything is ready to render a submesh to the G buffer.
  22897. * @param subMesh the submesh to check readiness for
  22898. * @param useInstances is the mesh drawn using instance or not
  22899. * @returns true if ready otherwise false
  22900. */
  22901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22902. /**
  22903. * Gets the current underlying G Buffer.
  22904. * @returns the buffer
  22905. */
  22906. getGBuffer(): MultiRenderTarget;
  22907. /**
  22908. * Gets the number of samples used to render the buffer (anti aliasing).
  22909. */
  22910. get samples(): number;
  22911. /**
  22912. * Sets the number of samples used to render the buffer (anti aliasing).
  22913. */
  22914. set samples(value: number);
  22915. /**
  22916. * Disposes the renderer and frees up associated resources.
  22917. */
  22918. dispose(): void;
  22919. private _assignRenderTargetIndices;
  22920. protected _createRenderTargets(): void;
  22921. private _copyBonesTransformationMatrices;
  22922. }
  22923. }
  22924. declare module BABYLON {
  22925. /**
  22926. * Renders a pre pass of the scene
  22927. * This means every mesh in the scene will be rendered to a render target texture
  22928. * And then this texture will be composited to the rendering canvas with post processes
  22929. * It is necessary for effects like subsurface scattering or deferred shading
  22930. */
  22931. export class PrePassRenderer {
  22932. /** @hidden */
  22933. static _SceneComponentInitialization: (scene: Scene) => void;
  22934. private _textureFormats;
  22935. /**
  22936. * To save performance, we can excluded skinned meshes from the prepass
  22937. */
  22938. excludedSkinnedMesh: AbstractMesh[];
  22939. /**
  22940. * Force material to be excluded from the prepass
  22941. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22942. * and you don't want a material to show in the effect.
  22943. */
  22944. excludedMaterials: Material[];
  22945. private _textureIndices;
  22946. private _scene;
  22947. private _engine;
  22948. private _isDirty;
  22949. /**
  22950. * Number of textures in the multi render target texture where the scene is directly rendered
  22951. */
  22952. mrtCount: number;
  22953. /**
  22954. * The render target where the scene is directly rendered
  22955. */
  22956. prePassRT: MultiRenderTarget;
  22957. private _multiRenderAttachments;
  22958. private _defaultAttachments;
  22959. private _postProcesses;
  22960. private readonly _clearColor;
  22961. /**
  22962. * Image processing post process for composition
  22963. */
  22964. imageProcessingPostProcess: ImageProcessingPostProcess;
  22965. /**
  22966. * Configuration for prepass effects
  22967. */
  22968. private _effectConfigurations;
  22969. private _mrtFormats;
  22970. private _mrtLayout;
  22971. private _enabled;
  22972. /**
  22973. * Indicates if the prepass is enabled
  22974. */
  22975. get enabled(): boolean;
  22976. /**
  22977. * How many samples are used for MSAA of the scene render target
  22978. */
  22979. get samples(): number;
  22980. set samples(n: number);
  22981. private _geometryBuffer;
  22982. private _useGeometryBufferFallback;
  22983. /**
  22984. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22985. */
  22986. get useGeometryBufferFallback(): boolean;
  22987. set useGeometryBufferFallback(value: boolean);
  22988. /**
  22989. * Set to true to disable gamma transform in PrePass.
  22990. * Can be useful in case you already proceed to gamma transform on a material level
  22991. * and your post processes don't need to be in linear color space.
  22992. */
  22993. disableGammaTransform: boolean;
  22994. /**
  22995. * Instanciates a prepass renderer
  22996. * @param scene The scene
  22997. */
  22998. constructor(scene: Scene);
  22999. private _initializeAttachments;
  23000. private _createCompositionEffect;
  23001. /**
  23002. * Indicates if rendering a prepass is supported
  23003. */
  23004. get isSupported(): boolean;
  23005. /**
  23006. * Sets the proper output textures to draw in the engine.
  23007. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23008. * @param subMesh Submesh on which the effect is applied
  23009. */
  23010. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23011. /**
  23012. * Restores attachments for single texture draw.
  23013. */
  23014. restoreAttachments(): void;
  23015. /**
  23016. * @hidden
  23017. */
  23018. _beforeCameraDraw(): void;
  23019. /**
  23020. * @hidden
  23021. */
  23022. _afterCameraDraw(): void;
  23023. private _checkRTSize;
  23024. private _bindFrameBuffer;
  23025. /**
  23026. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23027. */
  23028. clear(): void;
  23029. private _setState;
  23030. private _updateGeometryBufferLayout;
  23031. /**
  23032. * Adds an effect configuration to the prepass.
  23033. * If an effect has already been added, it won't add it twice and will return the configuration
  23034. * already present.
  23035. * @param cfg the effect configuration
  23036. * @return the effect configuration now used by the prepass
  23037. */
  23038. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23039. /**
  23040. * Returns the index of a texture in the multi render target texture array.
  23041. * @param type Texture type
  23042. * @return The index
  23043. */
  23044. getIndex(type: number): number;
  23045. private _enable;
  23046. private _disable;
  23047. private _resetLayout;
  23048. private _resetPostProcessChain;
  23049. private _bindPostProcessChain;
  23050. /**
  23051. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23052. */
  23053. markAsDirty(): void;
  23054. /**
  23055. * Enables a texture on the MultiRenderTarget for prepass
  23056. */
  23057. private _enableTextures;
  23058. private _update;
  23059. private _markAllMaterialsAsPrePassDirty;
  23060. /**
  23061. * Disposes the prepass renderer.
  23062. */
  23063. dispose(): void;
  23064. }
  23065. }
  23066. declare module BABYLON {
  23067. /**
  23068. * Size options for a post process
  23069. */
  23070. export type PostProcessOptions = {
  23071. width: number;
  23072. height: number;
  23073. };
  23074. /**
  23075. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23076. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23077. */
  23078. export class PostProcess {
  23079. /**
  23080. * Gets or sets the unique id of the post process
  23081. */
  23082. uniqueId: number;
  23083. /** Name of the PostProcess. */
  23084. name: string;
  23085. /**
  23086. * Width of the texture to apply the post process on
  23087. */
  23088. width: number;
  23089. /**
  23090. * Height of the texture to apply the post process on
  23091. */
  23092. height: number;
  23093. /**
  23094. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23095. */
  23096. nodeMaterialSource: Nullable<NodeMaterial>;
  23097. /**
  23098. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23099. * @hidden
  23100. */
  23101. _outputTexture: Nullable<InternalTexture>;
  23102. /**
  23103. * Sampling mode used by the shader
  23104. * See https://doc.babylonjs.com/classes/3.1/texture
  23105. */
  23106. renderTargetSamplingMode: number;
  23107. /**
  23108. * Clear color to use when screen clearing
  23109. */
  23110. clearColor: Color4;
  23111. /**
  23112. * If the buffer needs to be cleared before applying the post process. (default: true)
  23113. * Should be set to false if shader will overwrite all previous pixels.
  23114. */
  23115. autoClear: boolean;
  23116. /**
  23117. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23118. */
  23119. alphaMode: number;
  23120. /**
  23121. * Sets the setAlphaBlendConstants of the babylon engine
  23122. */
  23123. alphaConstants: Color4;
  23124. /**
  23125. * Animations to be used for the post processing
  23126. */
  23127. animations: Animation[];
  23128. /**
  23129. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23130. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23131. */
  23132. enablePixelPerfectMode: boolean;
  23133. /**
  23134. * Force the postprocess to be applied without taking in account viewport
  23135. */
  23136. forceFullscreenViewport: boolean;
  23137. /**
  23138. * List of inspectable custom properties (used by the Inspector)
  23139. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23140. */
  23141. inspectableCustomProperties: IInspectable[];
  23142. /**
  23143. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23144. *
  23145. * | Value | Type | Description |
  23146. * | ----- | ----------------------------------- | ----------- |
  23147. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23148. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23149. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23150. *
  23151. */
  23152. scaleMode: number;
  23153. /**
  23154. * Force textures to be a power of two (default: false)
  23155. */
  23156. alwaysForcePOT: boolean;
  23157. private _samples;
  23158. /**
  23159. * Number of sample textures (default: 1)
  23160. */
  23161. get samples(): number;
  23162. set samples(n: number);
  23163. /**
  23164. * Modify the scale of the post process to be the same as the viewport (default: false)
  23165. */
  23166. adaptScaleToCurrentViewport: boolean;
  23167. private _camera;
  23168. protected _scene: Scene;
  23169. private _engine;
  23170. private _options;
  23171. private _reusable;
  23172. private _textureType;
  23173. private _textureFormat;
  23174. /**
  23175. * Smart array of input and output textures for the post process.
  23176. * @hidden
  23177. */
  23178. _textures: SmartArray<InternalTexture>;
  23179. /**
  23180. * The index in _textures that corresponds to the output texture.
  23181. * @hidden
  23182. */
  23183. _currentRenderTextureInd: number;
  23184. private _effect;
  23185. private _samplers;
  23186. private _fragmentUrl;
  23187. private _vertexUrl;
  23188. private _parameters;
  23189. private _scaleRatio;
  23190. protected _indexParameters: any;
  23191. private _shareOutputWithPostProcess;
  23192. private _texelSize;
  23193. private _forcedOutputTexture;
  23194. /**
  23195. * Prepass configuration in case this post process needs a texture from prepass
  23196. * @hidden
  23197. */
  23198. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23199. /**
  23200. * Returns the fragment url or shader name used in the post process.
  23201. * @returns the fragment url or name in the shader store.
  23202. */
  23203. getEffectName(): string;
  23204. /**
  23205. * An event triggered when the postprocess is activated.
  23206. */
  23207. onActivateObservable: Observable<Camera>;
  23208. private _onActivateObserver;
  23209. /**
  23210. * A function that is added to the onActivateObservable
  23211. */
  23212. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23213. /**
  23214. * An event triggered when the postprocess changes its size.
  23215. */
  23216. onSizeChangedObservable: Observable<PostProcess>;
  23217. private _onSizeChangedObserver;
  23218. /**
  23219. * A function that is added to the onSizeChangedObservable
  23220. */
  23221. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23222. /**
  23223. * An event triggered when the postprocess applies its effect.
  23224. */
  23225. onApplyObservable: Observable<Effect>;
  23226. private _onApplyObserver;
  23227. /**
  23228. * A function that is added to the onApplyObservable
  23229. */
  23230. set onApply(callback: (effect: Effect) => void);
  23231. /**
  23232. * An event triggered before rendering the postprocess
  23233. */
  23234. onBeforeRenderObservable: Observable<Effect>;
  23235. private _onBeforeRenderObserver;
  23236. /**
  23237. * A function that is added to the onBeforeRenderObservable
  23238. */
  23239. set onBeforeRender(callback: (effect: Effect) => void);
  23240. /**
  23241. * An event triggered after rendering the postprocess
  23242. */
  23243. onAfterRenderObservable: Observable<Effect>;
  23244. private _onAfterRenderObserver;
  23245. /**
  23246. * A function that is added to the onAfterRenderObservable
  23247. */
  23248. set onAfterRender(callback: (efect: Effect) => void);
  23249. /**
  23250. * 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
  23251. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23252. */
  23253. get inputTexture(): InternalTexture;
  23254. set inputTexture(value: InternalTexture);
  23255. /**
  23256. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23257. * the only way to unset it is to use this function to restore its internal state
  23258. */
  23259. restoreDefaultInputTexture(): void;
  23260. /**
  23261. * Gets the camera which post process is applied to.
  23262. * @returns The camera the post process is applied to.
  23263. */
  23264. getCamera(): Camera;
  23265. /**
  23266. * Gets the texel size of the postprocess.
  23267. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23268. */
  23269. get texelSize(): Vector2;
  23270. /**
  23271. * Creates a new instance PostProcess
  23272. * @param name The name of the PostProcess.
  23273. * @param fragmentUrl The url of the fragment shader to be used.
  23274. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23275. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23276. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23277. * @param camera The camera to apply the render pass to.
  23278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23279. * @param engine The engine which the post process will be applied. (default: current engine)
  23280. * @param reusable If the post process can be reused on the same frame. (default: false)
  23281. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23282. * @param textureType Type of textures used when performing the post process. (default: 0)
  23283. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23284. * @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
  23285. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23286. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23287. */
  23288. 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);
  23289. /**
  23290. * Gets a string identifying the name of the class
  23291. * @returns "PostProcess" string
  23292. */
  23293. getClassName(): string;
  23294. /**
  23295. * Gets the engine which this post process belongs to.
  23296. * @returns The engine the post process was enabled with.
  23297. */
  23298. getEngine(): Engine;
  23299. /**
  23300. * The effect that is created when initializing the post process.
  23301. * @returns The created effect corresponding the the postprocess.
  23302. */
  23303. getEffect(): Effect;
  23304. /**
  23305. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23306. * @param postProcess The post process to share the output with.
  23307. * @returns This post process.
  23308. */
  23309. shareOutputWith(postProcess: PostProcess): PostProcess;
  23310. /**
  23311. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23312. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23313. */
  23314. useOwnOutput(): void;
  23315. /**
  23316. * Updates the effect with the current post process compile time values and recompiles the shader.
  23317. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23318. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23319. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23320. * @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
  23321. * @param onCompiled Called when the shader has been compiled.
  23322. * @param onError Called if there is an error when compiling a shader.
  23323. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23324. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23325. */
  23326. 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;
  23327. /**
  23328. * The post process is reusable if it can be used multiple times within one frame.
  23329. * @returns If the post process is reusable
  23330. */
  23331. isReusable(): boolean;
  23332. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23333. markTextureDirty(): void;
  23334. /**
  23335. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23336. * 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.
  23337. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23338. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23339. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23340. * @returns The target texture that was bound to be written to.
  23341. */
  23342. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23343. /**
  23344. * If the post process is supported.
  23345. */
  23346. get isSupported(): boolean;
  23347. /**
  23348. * The aspect ratio of the output texture.
  23349. */
  23350. get aspectRatio(): number;
  23351. /**
  23352. * Get a value indicating if the post-process is ready to be used
  23353. * @returns true if the post-process is ready (shader is compiled)
  23354. */
  23355. isReady(): boolean;
  23356. /**
  23357. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23358. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23359. */
  23360. apply(): Nullable<Effect>;
  23361. private _disposeTextures;
  23362. /**
  23363. * Sets the required values to the prepass renderer.
  23364. * @param prePassRenderer defines the prepass renderer to setup.
  23365. * @returns true if the pre pass is needed.
  23366. */
  23367. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23368. /**
  23369. * Disposes the post process.
  23370. * @param camera The camera to dispose the post process on.
  23371. */
  23372. dispose(camera?: Camera): void;
  23373. /**
  23374. * Serializes the particle system to a JSON object
  23375. * @returns the JSON object
  23376. */
  23377. serialize(): any;
  23378. /**
  23379. * Creates a material from parsed material data
  23380. * @param parsedPostProcess defines parsed post process data
  23381. * @param scene defines the hosting scene
  23382. * @param rootUrl defines the root URL to use to load textures
  23383. * @returns a new post process
  23384. */
  23385. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23386. }
  23387. }
  23388. declare module BABYLON {
  23389. /** @hidden */
  23390. export var kernelBlurVaryingDeclaration: {
  23391. name: string;
  23392. shader: string;
  23393. };
  23394. }
  23395. declare module BABYLON {
  23396. /** @hidden */
  23397. export var packingFunctions: {
  23398. name: string;
  23399. shader: string;
  23400. };
  23401. }
  23402. declare module BABYLON {
  23403. /** @hidden */
  23404. export var kernelBlurFragment: {
  23405. name: string;
  23406. shader: string;
  23407. };
  23408. }
  23409. declare module BABYLON {
  23410. /** @hidden */
  23411. export var kernelBlurFragment2: {
  23412. name: string;
  23413. shader: string;
  23414. };
  23415. }
  23416. declare module BABYLON {
  23417. /** @hidden */
  23418. export var kernelBlurPixelShader: {
  23419. name: string;
  23420. shader: string;
  23421. };
  23422. }
  23423. declare module BABYLON {
  23424. /** @hidden */
  23425. export var kernelBlurVertex: {
  23426. name: string;
  23427. shader: string;
  23428. };
  23429. }
  23430. declare module BABYLON {
  23431. /** @hidden */
  23432. export var kernelBlurVertexShader: {
  23433. name: string;
  23434. shader: string;
  23435. };
  23436. }
  23437. declare module BABYLON {
  23438. /**
  23439. * The Blur Post Process which blurs an image based on a kernel and direction.
  23440. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23441. */
  23442. export class BlurPostProcess extends PostProcess {
  23443. private blockCompilation;
  23444. protected _kernel: number;
  23445. protected _idealKernel: number;
  23446. protected _packedFloat: boolean;
  23447. private _staticDefines;
  23448. /** The direction in which to blur the image. */
  23449. direction: Vector2;
  23450. /**
  23451. * Sets the length in pixels of the blur sample region
  23452. */
  23453. set kernel(v: number);
  23454. /**
  23455. * Gets the length in pixels of the blur sample region
  23456. */
  23457. get kernel(): number;
  23458. /**
  23459. * Sets wether or not the blur needs to unpack/repack floats
  23460. */
  23461. set packedFloat(v: boolean);
  23462. /**
  23463. * Gets wether or not the blur is unpacking/repacking floats
  23464. */
  23465. get packedFloat(): boolean;
  23466. /**
  23467. * Gets a string identifying the name of the class
  23468. * @returns "BlurPostProcess" string
  23469. */
  23470. getClassName(): string;
  23471. /**
  23472. * Creates a new instance BlurPostProcess
  23473. * @param name The name of the effect.
  23474. * @param direction The direction in which to blur the image.
  23475. * @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.
  23476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23477. * @param camera The camera to apply the render pass to.
  23478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23479. * @param engine The engine which the post process will be applied. (default: current engine)
  23480. * @param reusable If the post process can be reused on the same frame. (default: false)
  23481. * @param textureType Type of textures used when performing the post process. (default: 0)
  23482. * @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)
  23483. */
  23484. 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);
  23485. /**
  23486. * Updates the effect with the current post process compile time values and recompiles the shader.
  23487. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23488. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23489. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23490. * @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
  23491. * @param onCompiled Called when the shader has been compiled.
  23492. * @param onError Called if there is an error when compiling a shader.
  23493. */
  23494. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23495. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23496. /**
  23497. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23498. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23499. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23500. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23501. * The gaps between physical kernels are compensated for in the weighting of the samples
  23502. * @param idealKernel Ideal blur kernel.
  23503. * @return Nearest best kernel.
  23504. */
  23505. protected _nearestBestKernel(idealKernel: number): number;
  23506. /**
  23507. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23508. * @param x The point on the Gaussian distribution to sample.
  23509. * @return the value of the Gaussian function at x.
  23510. */
  23511. protected _gaussianWeight(x: number): number;
  23512. /**
  23513. * Generates a string that can be used as a floating point number in GLSL.
  23514. * @param x Value to print.
  23515. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23516. * @return GLSL float string.
  23517. */
  23518. protected _glslFloat(x: number, decimalFigures?: number): string;
  23519. /** @hidden */
  23520. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23521. }
  23522. }
  23523. declare module BABYLON {
  23524. /**
  23525. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23526. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23527. * You can then easily use it as a reflectionTexture on a flat surface.
  23528. * In case the surface is not a plane, please consider relying on reflection probes.
  23529. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23530. */
  23531. export class MirrorTexture extends RenderTargetTexture {
  23532. private scene;
  23533. /**
  23534. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23535. * 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.
  23536. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23537. */
  23538. mirrorPlane: Plane;
  23539. /**
  23540. * Define the blur ratio used to blur the reflection if needed.
  23541. */
  23542. set blurRatio(value: number);
  23543. get blurRatio(): number;
  23544. /**
  23545. * Define the adaptive blur kernel used to blur the reflection if needed.
  23546. * This will autocompute the closest best match for the `blurKernel`
  23547. */
  23548. set adaptiveBlurKernel(value: number);
  23549. /**
  23550. * Define the blur kernel used to blur the reflection if needed.
  23551. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23552. */
  23553. set blurKernel(value: number);
  23554. /**
  23555. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23556. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23557. */
  23558. set blurKernelX(value: number);
  23559. get blurKernelX(): number;
  23560. /**
  23561. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23562. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23563. */
  23564. set blurKernelY(value: number);
  23565. get blurKernelY(): number;
  23566. private _autoComputeBlurKernel;
  23567. protected _onRatioRescale(): void;
  23568. private _updateGammaSpace;
  23569. private _imageProcessingConfigChangeObserver;
  23570. private _transformMatrix;
  23571. private _mirrorMatrix;
  23572. private _savedViewMatrix;
  23573. private _blurX;
  23574. private _blurY;
  23575. private _adaptiveBlurKernel;
  23576. private _blurKernelX;
  23577. private _blurKernelY;
  23578. private _blurRatio;
  23579. /**
  23580. * Instantiates a Mirror Texture.
  23581. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23582. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23583. * You can then easily use it as a reflectionTexture on a flat surface.
  23584. * In case the surface is not a plane, please consider relying on reflection probes.
  23585. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23586. * @param name
  23587. * @param size
  23588. * @param scene
  23589. * @param generateMipMaps
  23590. * @param type
  23591. * @param samplingMode
  23592. * @param generateDepthBuffer
  23593. */
  23594. constructor(name: string, size: number | {
  23595. width: number;
  23596. height: number;
  23597. } | {
  23598. ratio: number;
  23599. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23600. private _preparePostProcesses;
  23601. /**
  23602. * Clone the mirror texture.
  23603. * @returns the cloned texture
  23604. */
  23605. clone(): MirrorTexture;
  23606. /**
  23607. * Serialize the texture to a JSON representation you could use in Parse later on
  23608. * @returns the serialized JSON representation
  23609. */
  23610. serialize(): any;
  23611. /**
  23612. * Dispose the texture and release its associated resources.
  23613. */
  23614. dispose(): void;
  23615. }
  23616. }
  23617. declare module BABYLON {
  23618. /**
  23619. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23620. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23621. */
  23622. export class Texture extends BaseTexture {
  23623. /**
  23624. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23625. */
  23626. static SerializeBuffers: boolean;
  23627. /**
  23628. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23629. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23630. */
  23631. static ForceSerializeBuffers: boolean;
  23632. /** @hidden */
  23633. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23634. /** @hidden */
  23635. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23636. /** @hidden */
  23637. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23638. /** nearest is mag = nearest and min = nearest and mip = linear */
  23639. static readonly NEAREST_SAMPLINGMODE: number;
  23640. /** nearest is mag = nearest and min = nearest and mip = linear */
  23641. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23642. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23643. static readonly BILINEAR_SAMPLINGMODE: number;
  23644. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23645. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23646. /** Trilinear is mag = linear and min = linear and mip = linear */
  23647. static readonly TRILINEAR_SAMPLINGMODE: number;
  23648. /** Trilinear is mag = linear and min = linear and mip = linear */
  23649. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23650. /** mag = nearest and min = nearest and mip = nearest */
  23651. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23652. /** mag = nearest and min = linear and mip = nearest */
  23653. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23654. /** mag = nearest and min = linear and mip = linear */
  23655. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23656. /** mag = nearest and min = linear and mip = none */
  23657. static readonly NEAREST_LINEAR: number;
  23658. /** mag = nearest and min = nearest and mip = none */
  23659. static readonly NEAREST_NEAREST: number;
  23660. /** mag = linear and min = nearest and mip = nearest */
  23661. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23662. /** mag = linear and min = nearest and mip = linear */
  23663. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23664. /** mag = linear and min = linear and mip = none */
  23665. static readonly LINEAR_LINEAR: number;
  23666. /** mag = linear and min = nearest and mip = none */
  23667. static readonly LINEAR_NEAREST: number;
  23668. /** Explicit coordinates mode */
  23669. static readonly EXPLICIT_MODE: number;
  23670. /** Spherical coordinates mode */
  23671. static readonly SPHERICAL_MODE: number;
  23672. /** Planar coordinates mode */
  23673. static readonly PLANAR_MODE: number;
  23674. /** Cubic coordinates mode */
  23675. static readonly CUBIC_MODE: number;
  23676. /** Projection coordinates mode */
  23677. static readonly PROJECTION_MODE: number;
  23678. /** Inverse Cubic coordinates mode */
  23679. static readonly SKYBOX_MODE: number;
  23680. /** Inverse Cubic coordinates mode */
  23681. static readonly INVCUBIC_MODE: number;
  23682. /** Equirectangular coordinates mode */
  23683. static readonly EQUIRECTANGULAR_MODE: number;
  23684. /** Equirectangular Fixed coordinates mode */
  23685. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23686. /** Equirectangular Fixed Mirrored coordinates mode */
  23687. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23688. /** Texture is not repeating outside of 0..1 UVs */
  23689. static readonly CLAMP_ADDRESSMODE: number;
  23690. /** Texture is repeating outside of 0..1 UVs */
  23691. static readonly WRAP_ADDRESSMODE: number;
  23692. /** Texture is repeating and mirrored */
  23693. static readonly MIRROR_ADDRESSMODE: number;
  23694. /**
  23695. * 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
  23696. */
  23697. static UseSerializedUrlIfAny: boolean;
  23698. /**
  23699. * Define the url of the texture.
  23700. */
  23701. url: Nullable<string>;
  23702. /**
  23703. * Define an offset on the texture to offset the u coordinates of the UVs
  23704. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23705. */
  23706. uOffset: number;
  23707. /**
  23708. * Define an offset on the texture to offset the v coordinates of the UVs
  23709. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23710. */
  23711. vOffset: number;
  23712. /**
  23713. * Define an offset on the texture to scale the u coordinates of the UVs
  23714. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23715. */
  23716. uScale: number;
  23717. /**
  23718. * Define an offset on the texture to scale the v coordinates of the UVs
  23719. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23720. */
  23721. vScale: number;
  23722. /**
  23723. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23724. * @see https://doc.babylonjs.com/how_to/more_materials
  23725. */
  23726. uAng: number;
  23727. /**
  23728. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23729. * @see https://doc.babylonjs.com/how_to/more_materials
  23730. */
  23731. vAng: number;
  23732. /**
  23733. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23734. * @see https://doc.babylonjs.com/how_to/more_materials
  23735. */
  23736. wAng: number;
  23737. /**
  23738. * Defines the center of rotation (U)
  23739. */
  23740. uRotationCenter: number;
  23741. /**
  23742. * Defines the center of rotation (V)
  23743. */
  23744. vRotationCenter: number;
  23745. /**
  23746. * Defines the center of rotation (W)
  23747. */
  23748. wRotationCenter: number;
  23749. /**
  23750. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23751. */
  23752. homogeneousRotationInUVTransform: boolean;
  23753. /**
  23754. * Are mip maps generated for this texture or not.
  23755. */
  23756. get noMipmap(): boolean;
  23757. /**
  23758. * List of inspectable custom properties (used by the Inspector)
  23759. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23760. */
  23761. inspectableCustomProperties: Nullable<IInspectable[]>;
  23762. private _noMipmap;
  23763. /** @hidden */
  23764. _invertY: boolean;
  23765. private _rowGenerationMatrix;
  23766. private _cachedTextureMatrix;
  23767. private _projectionModeMatrix;
  23768. private _t0;
  23769. private _t1;
  23770. private _t2;
  23771. private _cachedUOffset;
  23772. private _cachedVOffset;
  23773. private _cachedUScale;
  23774. private _cachedVScale;
  23775. private _cachedUAng;
  23776. private _cachedVAng;
  23777. private _cachedWAng;
  23778. private _cachedProjectionMatrixId;
  23779. private _cachedURotationCenter;
  23780. private _cachedVRotationCenter;
  23781. private _cachedWRotationCenter;
  23782. private _cachedHomogeneousRotationInUVTransform;
  23783. private _cachedCoordinatesMode;
  23784. /** @hidden */
  23785. protected _initialSamplingMode: number;
  23786. /** @hidden */
  23787. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23788. private _deleteBuffer;
  23789. protected _format: Nullable<number>;
  23790. private _delayedOnLoad;
  23791. private _delayedOnError;
  23792. private _mimeType?;
  23793. private _loaderOptions?;
  23794. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23795. get mimeType(): string | undefined;
  23796. /**
  23797. * Observable triggered once the texture has been loaded.
  23798. */
  23799. onLoadObservable: Observable<Texture>;
  23800. protected _isBlocking: boolean;
  23801. /**
  23802. * Is the texture preventing material to render while loading.
  23803. * If false, a default texture will be used instead of the loading one during the preparation step.
  23804. */
  23805. set isBlocking(value: boolean);
  23806. get isBlocking(): boolean;
  23807. /**
  23808. * Get the current sampling mode associated with the texture.
  23809. */
  23810. get samplingMode(): number;
  23811. /**
  23812. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23813. */
  23814. get invertY(): boolean;
  23815. /**
  23816. * Instantiates a new texture.
  23817. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23818. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23819. * @param url defines the url of the picture to load as a texture
  23820. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23821. * @param noMipmap defines if the texture will require mip maps or not
  23822. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23823. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23824. * @param onLoad defines a callback triggered when the texture has been loaded
  23825. * @param onError defines a callback triggered when an error occurred during the loading session
  23826. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23827. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23828. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23829. * @param mimeType defines an optional mime type information
  23830. * @param loaderOptions options to be passed to the loader
  23831. */
  23832. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  23833. /**
  23834. * Update the url (and optional buffer) of this texture if url was null during construction.
  23835. * @param url the url of the texture
  23836. * @param buffer the buffer of the texture (defaults to null)
  23837. * @param onLoad callback called when the texture is loaded (defaults to null)
  23838. */
  23839. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23840. /**
  23841. * Finish the loading sequence of a texture flagged as delayed load.
  23842. * @hidden
  23843. */
  23844. delayLoad(): void;
  23845. private _prepareRowForTextureGeneration;
  23846. /**
  23847. * Checks if the texture has the same transform matrix than another texture
  23848. * @param texture texture to check against
  23849. * @returns true if the transforms are the same, else false
  23850. */
  23851. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23852. /**
  23853. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23854. * @returns the transform matrix of the texture.
  23855. */
  23856. getTextureMatrix(uBase?: number): Matrix;
  23857. /**
  23858. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23859. * @returns The reflection texture transform
  23860. */
  23861. getReflectionTextureMatrix(): Matrix;
  23862. /**
  23863. * Clones the texture.
  23864. * @returns the cloned texture
  23865. */
  23866. clone(): Texture;
  23867. /**
  23868. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23869. * @returns The JSON representation of the texture
  23870. */
  23871. serialize(): any;
  23872. /**
  23873. * Get the current class name of the texture useful for serialization or dynamic coding.
  23874. * @returns "Texture"
  23875. */
  23876. getClassName(): string;
  23877. /**
  23878. * Dispose the texture and release its associated resources.
  23879. */
  23880. dispose(): void;
  23881. /**
  23882. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23883. * @param parsedTexture Define the JSON representation of the texture
  23884. * @param scene Define the scene the parsed texture should be instantiated in
  23885. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23886. * @returns The parsed texture if successful
  23887. */
  23888. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23889. /**
  23890. * Creates a texture from its base 64 representation.
  23891. * @param data Define the base64 payload without the data: prefix
  23892. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23893. * @param scene Define the scene the texture should belong to
  23894. * @param noMipmap Forces the texture to not create mip map information if true
  23895. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23896. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23897. * @param onLoad define a callback triggered when the texture has been loaded
  23898. * @param onError define a callback triggered when an error occurred during the loading session
  23899. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23900. * @returns the created texture
  23901. */
  23902. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23903. /**
  23904. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23905. * @param data Define the base64 payload without the data: prefix
  23906. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23907. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23908. * @param scene Define the scene the texture should belong to
  23909. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23910. * @param noMipmap Forces the texture to not create mip map information if true
  23911. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23912. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23913. * @param onLoad define a callback triggered when the texture has been loaded
  23914. * @param onError define a callback triggered when an error occurred during the loading session
  23915. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23916. * @returns the created texture
  23917. */
  23918. 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;
  23919. }
  23920. }
  23921. declare module BABYLON {
  23922. /**
  23923. * ThinSprite Class used to represent a thin sprite
  23924. * This is the base class for sprites but can also directly be used with ThinEngine
  23925. * @see https://doc.babylonjs.com/babylon101/sprites
  23926. */
  23927. export class ThinSprite {
  23928. /** Gets or sets the cell index in the sprite sheet */
  23929. cellIndex: number;
  23930. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23931. cellRef: string;
  23932. /** Gets or sets the current world position */
  23933. position: IVector3Like;
  23934. /** Gets or sets the main color */
  23935. color: IColor4Like;
  23936. /** Gets or sets the width */
  23937. width: number;
  23938. /** Gets or sets the height */
  23939. height: number;
  23940. /** Gets or sets rotation angle */
  23941. angle: number;
  23942. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23943. invertU: boolean;
  23944. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23945. invertV: boolean;
  23946. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23947. isVisible: boolean;
  23948. /**
  23949. * Returns a boolean indicating if the animation is started
  23950. */
  23951. get animationStarted(): boolean;
  23952. /** Gets the initial key for the animation (setting it will restart the animation) */
  23953. get fromIndex(): number;
  23954. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23955. get toIndex(): number;
  23956. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23957. get loopAnimation(): boolean;
  23958. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23959. get delay(): number;
  23960. /** @hidden */
  23961. _xOffset: number;
  23962. /** @hidden */
  23963. _yOffset: number;
  23964. /** @hidden */
  23965. _xSize: number;
  23966. /** @hidden */
  23967. _ySize: number;
  23968. private _animationStarted;
  23969. protected _loopAnimation: boolean;
  23970. protected _fromIndex: number;
  23971. protected _toIndex: number;
  23972. protected _delay: number;
  23973. private _direction;
  23974. private _time;
  23975. private _onBaseAnimationEnd;
  23976. /**
  23977. * Creates a new Thin Sprite
  23978. */
  23979. constructor();
  23980. /**
  23981. * Starts an animation
  23982. * @param from defines the initial key
  23983. * @param to defines the end key
  23984. * @param loop defines if the animation must loop
  23985. * @param delay defines the start delay (in ms)
  23986. * @param onAnimationEnd defines a callback for when the animation ends
  23987. */
  23988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23989. /** Stops current animation (if any) */
  23990. stopAnimation(): void;
  23991. /** @hidden */
  23992. _animate(deltaTime: number): void;
  23993. }
  23994. }
  23995. declare module BABYLON {
  23996. /** @hidden */
  23997. export var imageProcessingCompatibility: {
  23998. name: string;
  23999. shader: string;
  24000. };
  24001. }
  24002. declare module BABYLON {
  24003. /** @hidden */
  24004. export var spritesPixelShader: {
  24005. name: string;
  24006. shader: string;
  24007. };
  24008. }
  24009. declare module BABYLON {
  24010. /** @hidden */
  24011. export var spritesVertexShader: {
  24012. name: string;
  24013. shader: string;
  24014. };
  24015. }
  24016. declare module BABYLON {
  24017. /**
  24018. * Class used to render sprites.
  24019. *
  24020. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24021. */
  24022. export class SpriteRenderer {
  24023. /**
  24024. * Defines the texture of the spritesheet
  24025. */
  24026. texture: Nullable<ThinTexture>;
  24027. /**
  24028. * Defines the default width of a cell in the spritesheet
  24029. */
  24030. cellWidth: number;
  24031. /**
  24032. * Defines the default height of a cell in the spritesheet
  24033. */
  24034. cellHeight: number;
  24035. /**
  24036. * Blend mode use to render the particle, it can be any of
  24037. * the static Constants.ALPHA_x properties provided in this class.
  24038. * Default value is Constants.ALPHA_COMBINE
  24039. */
  24040. blendMode: number;
  24041. /**
  24042. * Gets or sets a boolean indicating if alpha mode is automatically
  24043. * reset.
  24044. */
  24045. autoResetAlpha: boolean;
  24046. /**
  24047. * Disables writing to the depth buffer when rendering the sprites.
  24048. * It can be handy to disable depth writing when using textures without alpha channel
  24049. * and setting some specific blend modes.
  24050. */
  24051. disableDepthWrite: boolean;
  24052. /**
  24053. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24054. */
  24055. fogEnabled: boolean;
  24056. /**
  24057. * Gets the capacity of the manager
  24058. */
  24059. get capacity(): number;
  24060. private readonly _engine;
  24061. private readonly _useVAO;
  24062. private readonly _useInstancing;
  24063. private readonly _scene;
  24064. private readonly _capacity;
  24065. private readonly _epsilon;
  24066. private _vertexBufferSize;
  24067. private _vertexData;
  24068. private _buffer;
  24069. private _vertexBuffers;
  24070. private _spriteBuffer;
  24071. private _indexBuffer;
  24072. private _effectBase;
  24073. private _effectFog;
  24074. private _vertexArrayObject;
  24075. /**
  24076. * Creates a new sprite Renderer
  24077. * @param engine defines the engine the renderer works with
  24078. * @param capacity defines the maximum allowed number of sprites
  24079. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24080. * @param scene defines the hosting scene
  24081. */
  24082. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24083. /**
  24084. * Render all child sprites
  24085. * @param sprites defines the list of sprites to render
  24086. * @param deltaTime defines the time since last frame
  24087. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24088. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24089. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24090. */
  24091. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24092. private _appendSpriteVertex;
  24093. /**
  24094. * Release associated resources
  24095. */
  24096. dispose(): void;
  24097. }
  24098. }
  24099. declare module BABYLON {
  24100. /**
  24101. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24102. */
  24103. export interface ISpriteManager extends IDisposable {
  24104. /**
  24105. * Gets manager's name
  24106. */
  24107. name: string;
  24108. /**
  24109. * Restricts the camera to viewing objects with the same layerMask.
  24110. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24111. */
  24112. layerMask: number;
  24113. /**
  24114. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24115. */
  24116. isPickable: boolean;
  24117. /**
  24118. * Gets the hosting scene
  24119. */
  24120. scene: Scene;
  24121. /**
  24122. * Specifies the rendering group id for this mesh (0 by default)
  24123. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24124. */
  24125. renderingGroupId: number;
  24126. /**
  24127. * Defines the list of sprites managed by the manager.
  24128. */
  24129. sprites: Array<Sprite>;
  24130. /**
  24131. * Gets or sets the spritesheet texture
  24132. */
  24133. texture: Texture;
  24134. /** Defines the default width of a cell in the spritesheet */
  24135. cellWidth: number;
  24136. /** Defines the default height of a cell in the spritesheet */
  24137. cellHeight: number;
  24138. /**
  24139. * Tests the intersection of a sprite with a specific ray.
  24140. * @param ray The ray we are sending to test the collision
  24141. * @param camera The camera space we are sending rays in
  24142. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24143. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24144. * @returns picking info or null.
  24145. */
  24146. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24147. /**
  24148. * Intersects the sprites with a ray
  24149. * @param ray defines the ray to intersect with
  24150. * @param camera defines the current active camera
  24151. * @param predicate defines a predicate used to select candidate sprites
  24152. * @returns null if no hit or a PickingInfo array
  24153. */
  24154. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24155. /**
  24156. * Renders the list of sprites on screen.
  24157. */
  24158. render(): void;
  24159. }
  24160. /**
  24161. * Class used to manage multiple sprites on the same spritesheet
  24162. * @see https://doc.babylonjs.com/babylon101/sprites
  24163. */
  24164. export class SpriteManager implements ISpriteManager {
  24165. /** defines the manager's name */
  24166. name: string;
  24167. /** Define the Url to load snippets */
  24168. static SnippetUrl: string;
  24169. /** Snippet ID if the manager was created from the snippet server */
  24170. snippetId: string;
  24171. /** Gets the list of sprites */
  24172. sprites: Sprite[];
  24173. /** Gets or sets the rendering group id (0 by default) */
  24174. renderingGroupId: number;
  24175. /** Gets or sets camera layer mask */
  24176. layerMask: number;
  24177. /** Gets or sets a boolean indicating if the sprites are pickable */
  24178. isPickable: boolean;
  24179. /**
  24180. * An event triggered when the manager is disposed.
  24181. */
  24182. onDisposeObservable: Observable<SpriteManager>;
  24183. /**
  24184. * Callback called when the manager is disposed
  24185. */
  24186. set onDispose(callback: () => void);
  24187. /**
  24188. * Gets or sets the unique id of the sprite
  24189. */
  24190. uniqueId: number;
  24191. /**
  24192. * Gets the array of sprites
  24193. */
  24194. get children(): Sprite[];
  24195. /**
  24196. * Gets the hosting scene
  24197. */
  24198. get scene(): Scene;
  24199. /**
  24200. * Gets the capacity of the manager
  24201. */
  24202. get capacity(): number;
  24203. /**
  24204. * Gets or sets the spritesheet texture
  24205. */
  24206. get texture(): Texture;
  24207. set texture(value: Texture);
  24208. /** Defines the default width of a cell in the spritesheet */
  24209. get cellWidth(): number;
  24210. set cellWidth(value: number);
  24211. /** Defines the default height of a cell in the spritesheet */
  24212. get cellHeight(): number;
  24213. set cellHeight(value: number);
  24214. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24215. get fogEnabled(): boolean;
  24216. set fogEnabled(value: boolean);
  24217. /**
  24218. * Blend mode use to render the particle, it can be any of
  24219. * the static Constants.ALPHA_x properties provided in this class.
  24220. * Default value is Constants.ALPHA_COMBINE
  24221. */
  24222. get blendMode(): number;
  24223. set blendMode(blendMode: number);
  24224. /** Disables writing to the depth buffer when rendering the sprites.
  24225. * It can be handy to disable depth writing when using textures without alpha channel
  24226. * and setting some specific blend modes.
  24227. */
  24228. disableDepthWrite: boolean;
  24229. private _spriteRenderer;
  24230. /** Associative array from JSON sprite data file */
  24231. private _cellData;
  24232. /** Array of sprite names from JSON sprite data file */
  24233. private _spriteMap;
  24234. /** True when packed cell data from JSON file is ready*/
  24235. private _packedAndReady;
  24236. private _textureContent;
  24237. private _onDisposeObserver;
  24238. private _fromPacked;
  24239. private _scene;
  24240. /**
  24241. * Creates a new sprite manager
  24242. * @param name defines the manager's name
  24243. * @param imgUrl defines the sprite sheet url
  24244. * @param capacity defines the maximum allowed number of sprites
  24245. * @param cellSize defines the size of a sprite cell
  24246. * @param scene defines the hosting scene
  24247. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24248. * @param samplingMode defines the smapling mode to use with spritesheet
  24249. * @param fromPacked set to false; do not alter
  24250. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24251. */
  24252. constructor(
  24253. /** defines the manager's name */
  24254. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24255. /**
  24256. * Returns the string "SpriteManager"
  24257. * @returns "SpriteManager"
  24258. */
  24259. getClassName(): string;
  24260. private _makePacked;
  24261. private _checkTextureAlpha;
  24262. /**
  24263. * Intersects the sprites with a ray
  24264. * @param ray defines the ray to intersect with
  24265. * @param camera defines the current active camera
  24266. * @param predicate defines a predicate used to select candidate sprites
  24267. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24268. * @returns null if no hit or a PickingInfo
  24269. */
  24270. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24271. /**
  24272. * Intersects the sprites with a ray
  24273. * @param ray defines the ray to intersect with
  24274. * @param camera defines the current active camera
  24275. * @param predicate defines a predicate used to select candidate sprites
  24276. * @returns null if no hit or a PickingInfo array
  24277. */
  24278. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24279. /**
  24280. * Render all child sprites
  24281. */
  24282. render(): void;
  24283. private _customUpdate;
  24284. /**
  24285. * Release associated resources
  24286. */
  24287. dispose(): void;
  24288. /**
  24289. * Serializes the sprite manager to a JSON object
  24290. * @param serializeTexture defines if the texture must be serialized as well
  24291. * @returns the JSON object
  24292. */
  24293. serialize(serializeTexture?: boolean): any;
  24294. /**
  24295. * Parses a JSON object to create a new sprite manager.
  24296. * @param parsedManager The JSON object to parse
  24297. * @param scene The scene to create the sprite managerin
  24298. * @param rootUrl The root url to use to load external dependencies like texture
  24299. * @returns the new sprite manager
  24300. */
  24301. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24302. /**
  24303. * Creates a sprite manager from a snippet saved in a remote file
  24304. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24305. * @param url defines the url to load from
  24306. * @param scene defines the hosting scene
  24307. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24308. * @returns a promise that will resolve to the new sprite manager
  24309. */
  24310. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24311. /**
  24312. * Creates a sprite manager from a snippet saved by the sprite editor
  24313. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24314. * @param scene defines the hosting scene
  24315. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24316. * @returns a promise that will resolve to the new sprite manager
  24317. */
  24318. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24319. }
  24320. }
  24321. declare module BABYLON {
  24322. /**
  24323. * Class used to represent a sprite
  24324. * @see https://doc.babylonjs.com/babylon101/sprites
  24325. */
  24326. export class Sprite extends ThinSprite implements IAnimatable {
  24327. /** defines the name */
  24328. name: string;
  24329. /** Gets or sets the current world position */
  24330. position: Vector3;
  24331. /** Gets or sets the main color */
  24332. color: Color4;
  24333. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24334. disposeWhenFinishedAnimating: boolean;
  24335. /** Gets the list of attached animations */
  24336. animations: Nullable<Array<Animation>>;
  24337. /** Gets or sets a boolean indicating if the sprite can be picked */
  24338. isPickable: boolean;
  24339. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24340. useAlphaForPicking: boolean;
  24341. /**
  24342. * Gets or sets the associated action manager
  24343. */
  24344. actionManager: Nullable<ActionManager>;
  24345. /**
  24346. * An event triggered when the control has been disposed
  24347. */
  24348. onDisposeObservable: Observable<Sprite>;
  24349. private _manager;
  24350. private _onAnimationEnd;
  24351. /**
  24352. * Gets or sets the sprite size
  24353. */
  24354. get size(): number;
  24355. set size(value: number);
  24356. /**
  24357. * Gets or sets the unique id of the sprite
  24358. */
  24359. uniqueId: number;
  24360. /**
  24361. * Gets the manager of this sprite
  24362. */
  24363. get manager(): ISpriteManager;
  24364. /**
  24365. * Creates a new Sprite
  24366. * @param name defines the name
  24367. * @param manager defines the manager
  24368. */
  24369. constructor(
  24370. /** defines the name */
  24371. name: string, manager: ISpriteManager);
  24372. /**
  24373. * Returns the string "Sprite"
  24374. * @returns "Sprite"
  24375. */
  24376. getClassName(): string;
  24377. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24378. get fromIndex(): number;
  24379. set fromIndex(value: number);
  24380. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24381. get toIndex(): number;
  24382. set toIndex(value: number);
  24383. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24384. get loopAnimation(): boolean;
  24385. set loopAnimation(value: boolean);
  24386. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24387. get delay(): number;
  24388. set delay(value: number);
  24389. /**
  24390. * Starts an animation
  24391. * @param from defines the initial key
  24392. * @param to defines the end key
  24393. * @param loop defines if the animation must loop
  24394. * @param delay defines the start delay (in ms)
  24395. * @param onAnimationEnd defines a callback to call when animation ends
  24396. */
  24397. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24398. private _endAnimation;
  24399. /** Release associated resources */
  24400. dispose(): void;
  24401. /**
  24402. * Serializes the sprite to a JSON object
  24403. * @returns the JSON object
  24404. */
  24405. serialize(): any;
  24406. /**
  24407. * Parses a JSON object to create a new sprite
  24408. * @param parsedSprite The JSON object to parse
  24409. * @param manager defines the hosting manager
  24410. * @returns the new sprite
  24411. */
  24412. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24413. }
  24414. }
  24415. declare module BABYLON {
  24416. /**
  24417. * Information about the result of picking within a scene
  24418. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24419. */
  24420. export class PickingInfo {
  24421. /** @hidden */
  24422. _pickingUnavailable: boolean;
  24423. /**
  24424. * If the pick collided with an object
  24425. */
  24426. hit: boolean;
  24427. /**
  24428. * Distance away where the pick collided
  24429. */
  24430. distance: number;
  24431. /**
  24432. * The location of pick collision
  24433. */
  24434. pickedPoint: Nullable<Vector3>;
  24435. /**
  24436. * The mesh corresponding the the pick collision
  24437. */
  24438. pickedMesh: Nullable<AbstractMesh>;
  24439. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24440. bu: number;
  24441. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24442. bv: number;
  24443. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24444. faceId: number;
  24445. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24446. subMeshFaceId: number;
  24447. /** Id of the the submesh that was picked */
  24448. subMeshId: number;
  24449. /** If a sprite was picked, this will be the sprite the pick collided with */
  24450. pickedSprite: Nullable<Sprite>;
  24451. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24452. thinInstanceIndex: number;
  24453. /**
  24454. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24455. */
  24456. originMesh: Nullable<AbstractMesh>;
  24457. /**
  24458. * The ray that was used to perform the picking.
  24459. */
  24460. ray: Nullable<Ray>;
  24461. /**
  24462. * Gets the normal correspodning to the face the pick collided with
  24463. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24464. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24465. * @returns The normal correspodning to the face the pick collided with
  24466. */
  24467. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24468. /**
  24469. * Gets the texture coordinates of where the pick occured
  24470. * @returns the vector containing the coordnates of the texture
  24471. */
  24472. getTextureCoordinates(): Nullable<Vector2>;
  24473. }
  24474. }
  24475. declare module BABYLON {
  24476. /**
  24477. * Gather the list of pointer event types as constants.
  24478. */
  24479. export class PointerEventTypes {
  24480. /**
  24481. * 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.
  24482. */
  24483. static readonly POINTERDOWN: number;
  24484. /**
  24485. * The pointerup event is fired when a pointer is no longer active.
  24486. */
  24487. static readonly POINTERUP: number;
  24488. /**
  24489. * The pointermove event is fired when a pointer changes coordinates.
  24490. */
  24491. static readonly POINTERMOVE: number;
  24492. /**
  24493. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24494. */
  24495. static readonly POINTERWHEEL: number;
  24496. /**
  24497. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24498. */
  24499. static readonly POINTERPICK: number;
  24500. /**
  24501. * The pointertap event is fired when a the object has been touched and released without drag.
  24502. */
  24503. static readonly POINTERTAP: number;
  24504. /**
  24505. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24506. */
  24507. static readonly POINTERDOUBLETAP: number;
  24508. }
  24509. /**
  24510. * Base class of pointer info types.
  24511. */
  24512. export class PointerInfoBase {
  24513. /**
  24514. * Defines the type of event (PointerEventTypes)
  24515. */
  24516. type: number;
  24517. /**
  24518. * Defines the related dom event
  24519. */
  24520. event: PointerEvent | MouseWheelEvent;
  24521. /**
  24522. * Instantiates the base class of pointers info.
  24523. * @param type Defines the type of event (PointerEventTypes)
  24524. * @param event Defines the related dom event
  24525. */
  24526. constructor(
  24527. /**
  24528. * Defines the type of event (PointerEventTypes)
  24529. */
  24530. type: number,
  24531. /**
  24532. * Defines the related dom event
  24533. */
  24534. event: PointerEvent | MouseWheelEvent);
  24535. }
  24536. /**
  24537. * This class is used to store pointer related info for the onPrePointerObservable event.
  24538. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24539. */
  24540. export class PointerInfoPre extends PointerInfoBase {
  24541. /**
  24542. * Ray from a pointer if availible (eg. 6dof controller)
  24543. */
  24544. ray: Nullable<Ray>;
  24545. /**
  24546. * Defines the local position of the pointer on the canvas.
  24547. */
  24548. localPosition: Vector2;
  24549. /**
  24550. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24551. */
  24552. skipOnPointerObservable: boolean;
  24553. /**
  24554. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24555. * @param type Defines the type of event (PointerEventTypes)
  24556. * @param event Defines the related dom event
  24557. * @param localX Defines the local x coordinates of the pointer when the event occured
  24558. * @param localY Defines the local y coordinates of the pointer when the event occured
  24559. */
  24560. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24561. }
  24562. /**
  24563. * This type contains all the data related to a pointer event in Babylon.js.
  24564. * 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.
  24565. */
  24566. export class PointerInfo extends PointerInfoBase {
  24567. /**
  24568. * Defines the picking info associated to the info (if any)\
  24569. */
  24570. pickInfo: Nullable<PickingInfo>;
  24571. /**
  24572. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24573. * @param type Defines the type of event (PointerEventTypes)
  24574. * @param event Defines the related dom event
  24575. * @param pickInfo Defines the picking info associated to the info (if any)\
  24576. */
  24577. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24578. /**
  24579. * Defines the picking info associated to the info (if any)\
  24580. */
  24581. pickInfo: Nullable<PickingInfo>);
  24582. }
  24583. /**
  24584. * Data relating to a touch event on the screen.
  24585. */
  24586. export interface PointerTouch {
  24587. /**
  24588. * X coordinate of touch.
  24589. */
  24590. x: number;
  24591. /**
  24592. * Y coordinate of touch.
  24593. */
  24594. y: number;
  24595. /**
  24596. * Id of touch. Unique for each finger.
  24597. */
  24598. pointerId: number;
  24599. /**
  24600. * Event type passed from DOM.
  24601. */
  24602. type: any;
  24603. }
  24604. }
  24605. declare module BABYLON {
  24606. /**
  24607. * Manage the mouse inputs to control the movement of a free camera.
  24608. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24609. */
  24610. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24611. /**
  24612. * Define if touch is enabled in the mouse input
  24613. */
  24614. touchEnabled: boolean;
  24615. /**
  24616. * Defines the camera the input is attached to.
  24617. */
  24618. camera: FreeCamera;
  24619. /**
  24620. * Defines the buttons associated with the input to handle camera move.
  24621. */
  24622. buttons: number[];
  24623. /**
  24624. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24625. */
  24626. angularSensibility: number;
  24627. private _pointerInput;
  24628. private _onMouseMove;
  24629. private _observer;
  24630. private previousPosition;
  24631. /**
  24632. * Observable for when a pointer move event occurs containing the move offset
  24633. */
  24634. onPointerMovedObservable: Observable<{
  24635. offsetX: number;
  24636. offsetY: number;
  24637. }>;
  24638. /**
  24639. * @hidden
  24640. * If the camera should be rotated automatically based on pointer movement
  24641. */
  24642. _allowCameraRotation: boolean;
  24643. /**
  24644. * Manage the mouse inputs to control the movement of a free camera.
  24645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24646. * @param touchEnabled Defines if touch is enabled or not
  24647. */
  24648. constructor(
  24649. /**
  24650. * Define if touch is enabled in the mouse input
  24651. */
  24652. touchEnabled?: boolean);
  24653. /**
  24654. * Attach the input controls to a specific dom element to get the input from.
  24655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24656. */
  24657. attachControl(noPreventDefault?: boolean): void;
  24658. /**
  24659. * Called on JS contextmenu event.
  24660. * Override this method to provide functionality.
  24661. */
  24662. protected onContextMenu(evt: PointerEvent): void;
  24663. /**
  24664. * Detach the current controls from the specified dom element.
  24665. */
  24666. detachControl(): void;
  24667. /**
  24668. * Gets the class name of the current intput.
  24669. * @returns the class name
  24670. */
  24671. getClassName(): string;
  24672. /**
  24673. * Get the friendly name associated with the input class.
  24674. * @returns the input friendly name
  24675. */
  24676. getSimpleName(): string;
  24677. }
  24678. }
  24679. declare module BABYLON {
  24680. /**
  24681. * Base class for mouse wheel input..
  24682. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24683. * for example usage.
  24684. */
  24685. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24686. /**
  24687. * Defines the camera the input is attached to.
  24688. */
  24689. abstract camera: Camera;
  24690. /**
  24691. * How fast is the camera moves in relation to X axis mouseWheel events.
  24692. * Use negative value to reverse direction.
  24693. */
  24694. wheelPrecisionX: number;
  24695. /**
  24696. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24697. * Use negative value to reverse direction.
  24698. */
  24699. wheelPrecisionY: number;
  24700. /**
  24701. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24702. * Use negative value to reverse direction.
  24703. */
  24704. wheelPrecisionZ: number;
  24705. /**
  24706. * Observable for when a mouse wheel move event occurs.
  24707. */
  24708. onChangedObservable: Observable<{
  24709. wheelDeltaX: number;
  24710. wheelDeltaY: number;
  24711. wheelDeltaZ: number;
  24712. }>;
  24713. private _wheel;
  24714. private _observer;
  24715. /**
  24716. * Attach the input controls to a specific dom element to get the input from.
  24717. * @param noPreventDefault Defines whether event caught by the controls
  24718. * should call preventdefault().
  24719. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24720. */
  24721. attachControl(noPreventDefault?: boolean): void;
  24722. /**
  24723. * Detach the current controls from the specified dom element.
  24724. */
  24725. detachControl(): void;
  24726. /**
  24727. * Called for each rendered frame.
  24728. */
  24729. checkInputs(): void;
  24730. /**
  24731. * Gets the class name of the current intput.
  24732. * @returns the class name
  24733. */
  24734. getClassName(): string;
  24735. /**
  24736. * Get the friendly name associated with the input class.
  24737. * @returns the input friendly name
  24738. */
  24739. getSimpleName(): string;
  24740. /**
  24741. * Incremental value of multiple mouse wheel movements of the X axis.
  24742. * Should be zero-ed when read.
  24743. */
  24744. protected _wheelDeltaX: number;
  24745. /**
  24746. * Incremental value of multiple mouse wheel movements of the Y axis.
  24747. * Should be zero-ed when read.
  24748. */
  24749. protected _wheelDeltaY: number;
  24750. /**
  24751. * Incremental value of multiple mouse wheel movements of the Z axis.
  24752. * Should be zero-ed when read.
  24753. */
  24754. protected _wheelDeltaZ: number;
  24755. /**
  24756. * Firefox uses a different scheme to report scroll distances to other
  24757. * browsers. Rather than use complicated methods to calculate the exact
  24758. * multiple we need to apply, let's just cheat and use a constant.
  24759. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24760. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24761. */
  24762. private readonly _ffMultiplier;
  24763. /**
  24764. * Different event attributes for wheel data fall into a few set ranges.
  24765. * Some relevant but dated date here:
  24766. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24767. */
  24768. private readonly _normalize;
  24769. }
  24770. }
  24771. declare module BABYLON {
  24772. /**
  24773. * Manage the mouse wheel inputs to control a free camera.
  24774. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24775. */
  24776. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24777. /**
  24778. * Defines the camera the input is attached to.
  24779. */
  24780. camera: FreeCamera;
  24781. /**
  24782. * Gets the class name of the current input.
  24783. * @returns the class name
  24784. */
  24785. getClassName(): string;
  24786. /**
  24787. * Set which movement axis (relative to camera's orientation) the mouse
  24788. * wheel's X axis controls.
  24789. * @param axis The axis to be moved. Set null to clear.
  24790. */
  24791. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24792. /**
  24793. * Get the configured movement axis (relative to camera's orientation) the
  24794. * mouse wheel's X axis controls.
  24795. * @returns The configured axis or null if none.
  24796. */
  24797. get wheelXMoveRelative(): Nullable<Coordinate>;
  24798. /**
  24799. * Set which movement axis (relative to camera's orientation) the mouse
  24800. * wheel's Y axis controls.
  24801. * @param axis The axis to be moved. Set null to clear.
  24802. */
  24803. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24804. /**
  24805. * Get the configured movement axis (relative to camera's orientation) the
  24806. * mouse wheel's Y axis controls.
  24807. * @returns The configured axis or null if none.
  24808. */
  24809. get wheelYMoveRelative(): Nullable<Coordinate>;
  24810. /**
  24811. * Set which movement axis (relative to camera's orientation) the mouse
  24812. * wheel's Z axis controls.
  24813. * @param axis The axis to be moved. Set null to clear.
  24814. */
  24815. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24816. /**
  24817. * Get the configured movement axis (relative to camera's orientation) the
  24818. * mouse wheel's Z axis controls.
  24819. * @returns The configured axis or null if none.
  24820. */
  24821. get wheelZMoveRelative(): Nullable<Coordinate>;
  24822. /**
  24823. * Set which rotation axis (relative to camera's orientation) the mouse
  24824. * wheel's X axis controls.
  24825. * @param axis The axis to be moved. Set null to clear.
  24826. */
  24827. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24828. /**
  24829. * Get the configured rotation axis (relative to camera's orientation) the
  24830. * mouse wheel's X axis controls.
  24831. * @returns The configured axis or null if none.
  24832. */
  24833. get wheelXRotateRelative(): Nullable<Coordinate>;
  24834. /**
  24835. * Set which rotation axis (relative to camera's orientation) the mouse
  24836. * wheel's Y axis controls.
  24837. * @param axis The axis to be moved. Set null to clear.
  24838. */
  24839. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24840. /**
  24841. * Get the configured rotation axis (relative to camera's orientation) the
  24842. * mouse wheel's Y axis controls.
  24843. * @returns The configured axis or null if none.
  24844. */
  24845. get wheelYRotateRelative(): Nullable<Coordinate>;
  24846. /**
  24847. * Set which rotation axis (relative to camera's orientation) the mouse
  24848. * wheel's Z axis controls.
  24849. * @param axis The axis to be moved. Set null to clear.
  24850. */
  24851. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24852. /**
  24853. * Get the configured rotation axis (relative to camera's orientation) the
  24854. * mouse wheel's Z axis controls.
  24855. * @returns The configured axis or null if none.
  24856. */
  24857. get wheelZRotateRelative(): Nullable<Coordinate>;
  24858. /**
  24859. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24860. * controls.
  24861. * @param axis The axis to be moved. Set null to clear.
  24862. */
  24863. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24864. /**
  24865. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24866. * X axis controls.
  24867. * @returns The configured axis or null if none.
  24868. */
  24869. get wheelXMoveScene(): Nullable<Coordinate>;
  24870. /**
  24871. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24872. * controls.
  24873. * @param axis The axis to be moved. Set null to clear.
  24874. */
  24875. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24876. /**
  24877. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24878. * Y axis controls.
  24879. * @returns The configured axis or null if none.
  24880. */
  24881. get wheelYMoveScene(): Nullable<Coordinate>;
  24882. /**
  24883. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24884. * controls.
  24885. * @param axis The axis to be moved. Set null to clear.
  24886. */
  24887. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24888. /**
  24889. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24890. * Z axis controls.
  24891. * @returns The configured axis or null if none.
  24892. */
  24893. get wheelZMoveScene(): Nullable<Coordinate>;
  24894. /**
  24895. * Called for each rendered frame.
  24896. */
  24897. checkInputs(): void;
  24898. private _moveRelative;
  24899. private _rotateRelative;
  24900. private _moveScene;
  24901. /**
  24902. * These are set to the desired default behaviour.
  24903. */
  24904. private _wheelXAction;
  24905. private _wheelXActionCoordinate;
  24906. private _wheelYAction;
  24907. private _wheelYActionCoordinate;
  24908. private _wheelZAction;
  24909. private _wheelZActionCoordinate;
  24910. /**
  24911. * Update the camera according to any configured properties for the 3
  24912. * mouse-wheel axis.
  24913. */
  24914. private _updateCamera;
  24915. /**
  24916. * Update one property of the camera.
  24917. */
  24918. private _updateCameraProperty;
  24919. }
  24920. }
  24921. declare module BABYLON {
  24922. /**
  24923. * Manage the touch inputs to control the movement of a free camera.
  24924. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24925. */
  24926. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24927. /**
  24928. * Define if mouse events can be treated as touch events
  24929. */
  24930. allowMouse: boolean;
  24931. /**
  24932. * Defines the camera the input is attached to.
  24933. */
  24934. camera: FreeCamera;
  24935. /**
  24936. * Defines the touch sensibility for rotation.
  24937. * The higher the faster.
  24938. */
  24939. touchAngularSensibility: number;
  24940. /**
  24941. * Defines the touch sensibility for move.
  24942. * The higher the faster.
  24943. */
  24944. touchMoveSensibility: number;
  24945. private _offsetX;
  24946. private _offsetY;
  24947. private _pointerPressed;
  24948. private _pointerInput?;
  24949. private _observer;
  24950. private _onLostFocus;
  24951. /**
  24952. * Manage the touch inputs to control the movement of a free camera.
  24953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24954. * @param allowMouse Defines if mouse events can be treated as touch events
  24955. */
  24956. constructor(
  24957. /**
  24958. * Define if mouse events can be treated as touch events
  24959. */
  24960. allowMouse?: boolean);
  24961. /**
  24962. * Attach the input controls to a specific dom element to get the input from.
  24963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24964. */
  24965. attachControl(noPreventDefault?: boolean): void;
  24966. /**
  24967. * Detach the current controls from the specified dom element.
  24968. */
  24969. detachControl(): void;
  24970. /**
  24971. * Update the current camera state depending on the inputs that have been used this frame.
  24972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24973. */
  24974. checkInputs(): void;
  24975. /**
  24976. * Gets the class name of the current intput.
  24977. * @returns the class name
  24978. */
  24979. getClassName(): string;
  24980. /**
  24981. * Get the friendly name associated with the input class.
  24982. * @returns the input friendly name
  24983. */
  24984. getSimpleName(): string;
  24985. }
  24986. }
  24987. declare module BABYLON {
  24988. /**
  24989. * Default Inputs manager for the FreeCamera.
  24990. * It groups all the default supported inputs for ease of use.
  24991. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24992. */
  24993. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24994. /**
  24995. * @hidden
  24996. */
  24997. _mouseInput: Nullable<FreeCameraMouseInput>;
  24998. /**
  24999. * @hidden
  25000. */
  25001. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25002. /**
  25003. * Instantiates a new FreeCameraInputsManager.
  25004. * @param camera Defines the camera the inputs belong to
  25005. */
  25006. constructor(camera: FreeCamera);
  25007. /**
  25008. * Add keyboard input support to the input manager.
  25009. * @returns the current input manager
  25010. */
  25011. addKeyboard(): FreeCameraInputsManager;
  25012. /**
  25013. * Add mouse input support to the input manager.
  25014. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25015. * @returns the current input manager
  25016. */
  25017. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25018. /**
  25019. * Removes the mouse input support from the manager
  25020. * @returns the current input manager
  25021. */
  25022. removeMouse(): FreeCameraInputsManager;
  25023. /**
  25024. * Add mouse wheel input support to the input manager.
  25025. * @returns the current input manager
  25026. */
  25027. addMouseWheel(): FreeCameraInputsManager;
  25028. /**
  25029. * Removes the mouse wheel input support from the manager
  25030. * @returns the current input manager
  25031. */
  25032. removeMouseWheel(): FreeCameraInputsManager;
  25033. /**
  25034. * Add touch input support to the input manager.
  25035. * @returns the current input manager
  25036. */
  25037. addTouch(): FreeCameraInputsManager;
  25038. /**
  25039. * Remove all attached input methods from a camera
  25040. */
  25041. clear(): void;
  25042. }
  25043. }
  25044. declare module BABYLON {
  25045. /**
  25046. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25047. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25048. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25049. */
  25050. export class FreeCamera extends TargetCamera {
  25051. /**
  25052. * Define the collision ellipsoid of the camera.
  25053. * This is helpful to simulate a camera body like the player body around the camera
  25054. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25055. */
  25056. ellipsoid: Vector3;
  25057. /**
  25058. * Define an offset for the position of the ellipsoid around the camera.
  25059. * This can be helpful to determine the center of the body near the gravity center of the body
  25060. * instead of its head.
  25061. */
  25062. ellipsoidOffset: Vector3;
  25063. /**
  25064. * Enable or disable collisions of the camera with the rest of the scene objects.
  25065. */
  25066. checkCollisions: boolean;
  25067. /**
  25068. * Enable or disable gravity on the camera.
  25069. */
  25070. applyGravity: boolean;
  25071. /**
  25072. * Define the input manager associated to the camera.
  25073. */
  25074. inputs: FreeCameraInputsManager;
  25075. /**
  25076. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25077. * Higher values reduce sensitivity.
  25078. */
  25079. get angularSensibility(): number;
  25080. /**
  25081. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25082. * Higher values reduce sensitivity.
  25083. */
  25084. set angularSensibility(value: number);
  25085. /**
  25086. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25087. */
  25088. get keysUp(): number[];
  25089. set keysUp(value: number[]);
  25090. /**
  25091. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25092. */
  25093. get keysUpward(): number[];
  25094. set keysUpward(value: number[]);
  25095. /**
  25096. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25097. */
  25098. get keysDown(): number[];
  25099. set keysDown(value: number[]);
  25100. /**
  25101. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25102. */
  25103. get keysDownward(): number[];
  25104. set keysDownward(value: number[]);
  25105. /**
  25106. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25107. */
  25108. get keysLeft(): number[];
  25109. set keysLeft(value: number[]);
  25110. /**
  25111. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25112. */
  25113. get keysRight(): number[];
  25114. set keysRight(value: number[]);
  25115. /**
  25116. * Event raised when the camera collide with a mesh in the scene.
  25117. */
  25118. onCollide: (collidedMesh: AbstractMesh) => void;
  25119. private _collider;
  25120. private _needMoveForGravity;
  25121. private _oldPosition;
  25122. private _diffPosition;
  25123. private _newPosition;
  25124. /** @hidden */
  25125. _localDirection: Vector3;
  25126. /** @hidden */
  25127. _transformedDirection: Vector3;
  25128. /**
  25129. * Instantiates a Free Camera.
  25130. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25131. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25132. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25133. * @param name Define the name of the camera in the scene
  25134. * @param position Define the start position of the camera in the scene
  25135. * @param scene Define the scene the camera belongs to
  25136. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25137. */
  25138. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25139. /**
  25140. * Attach the input controls to a specific dom element to get the input from.
  25141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25142. */
  25143. attachControl(noPreventDefault?: boolean): void;
  25144. /**
  25145. * Attach the input controls to a specific dom element to get the input from.
  25146. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25148. * BACK COMPAT SIGNATURE ONLY.
  25149. */
  25150. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25151. /**
  25152. * Detach the current controls from the specified dom element.
  25153. */
  25154. detachControl(): void;
  25155. /**
  25156. * Detach the current controls from the specified dom element.
  25157. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25158. */
  25159. detachControl(ignored: any): void;
  25160. private _collisionMask;
  25161. /**
  25162. * Define a collision mask to limit the list of object the camera can collide with
  25163. */
  25164. get collisionMask(): number;
  25165. set collisionMask(mask: number);
  25166. /** @hidden */
  25167. _collideWithWorld(displacement: Vector3): void;
  25168. private _onCollisionPositionChange;
  25169. /** @hidden */
  25170. _checkInputs(): void;
  25171. /** @hidden */
  25172. _decideIfNeedsToMove(): boolean;
  25173. /** @hidden */
  25174. _updatePosition(): void;
  25175. /**
  25176. * Destroy the camera and release the current resources hold by it.
  25177. */
  25178. dispose(): void;
  25179. /**
  25180. * Gets the current object class name.
  25181. * @return the class name
  25182. */
  25183. getClassName(): string;
  25184. }
  25185. }
  25186. declare module BABYLON {
  25187. /**
  25188. * Represents a gamepad control stick position
  25189. */
  25190. export class StickValues {
  25191. /**
  25192. * The x component of the control stick
  25193. */
  25194. x: number;
  25195. /**
  25196. * The y component of the control stick
  25197. */
  25198. y: number;
  25199. /**
  25200. * Initializes the gamepad x and y control stick values
  25201. * @param x The x component of the gamepad control stick value
  25202. * @param y The y component of the gamepad control stick value
  25203. */
  25204. constructor(
  25205. /**
  25206. * The x component of the control stick
  25207. */
  25208. x: number,
  25209. /**
  25210. * The y component of the control stick
  25211. */
  25212. y: number);
  25213. }
  25214. /**
  25215. * An interface which manages callbacks for gamepad button changes
  25216. */
  25217. export interface GamepadButtonChanges {
  25218. /**
  25219. * Called when a gamepad has been changed
  25220. */
  25221. changed: boolean;
  25222. /**
  25223. * Called when a gamepad press event has been triggered
  25224. */
  25225. pressChanged: boolean;
  25226. /**
  25227. * Called when a touch event has been triggered
  25228. */
  25229. touchChanged: boolean;
  25230. /**
  25231. * Called when a value has changed
  25232. */
  25233. valueChanged: boolean;
  25234. }
  25235. /**
  25236. * Represents a gamepad
  25237. */
  25238. export class Gamepad {
  25239. /**
  25240. * The id of the gamepad
  25241. */
  25242. id: string;
  25243. /**
  25244. * The index of the gamepad
  25245. */
  25246. index: number;
  25247. /**
  25248. * The browser gamepad
  25249. */
  25250. browserGamepad: any;
  25251. /**
  25252. * Specifies what type of gamepad this represents
  25253. */
  25254. type: number;
  25255. private _leftStick;
  25256. private _rightStick;
  25257. /** @hidden */
  25258. _isConnected: boolean;
  25259. private _leftStickAxisX;
  25260. private _leftStickAxisY;
  25261. private _rightStickAxisX;
  25262. private _rightStickAxisY;
  25263. /**
  25264. * Triggered when the left control stick has been changed
  25265. */
  25266. private _onleftstickchanged;
  25267. /**
  25268. * Triggered when the right control stick has been changed
  25269. */
  25270. private _onrightstickchanged;
  25271. /**
  25272. * Represents a gamepad controller
  25273. */
  25274. static GAMEPAD: number;
  25275. /**
  25276. * Represents a generic controller
  25277. */
  25278. static GENERIC: number;
  25279. /**
  25280. * Represents an XBox controller
  25281. */
  25282. static XBOX: number;
  25283. /**
  25284. * Represents a pose-enabled controller
  25285. */
  25286. static POSE_ENABLED: number;
  25287. /**
  25288. * Represents an Dual Shock controller
  25289. */
  25290. static DUALSHOCK: number;
  25291. /**
  25292. * Specifies whether the left control stick should be Y-inverted
  25293. */
  25294. protected _invertLeftStickY: boolean;
  25295. /**
  25296. * Specifies if the gamepad has been connected
  25297. */
  25298. get isConnected(): boolean;
  25299. /**
  25300. * Initializes the gamepad
  25301. * @param id The id of the gamepad
  25302. * @param index The index of the gamepad
  25303. * @param browserGamepad The browser gamepad
  25304. * @param leftStickX The x component of the left joystick
  25305. * @param leftStickY The y component of the left joystick
  25306. * @param rightStickX The x component of the right joystick
  25307. * @param rightStickY The y component of the right joystick
  25308. */
  25309. constructor(
  25310. /**
  25311. * The id of the gamepad
  25312. */
  25313. id: string,
  25314. /**
  25315. * The index of the gamepad
  25316. */
  25317. index: number,
  25318. /**
  25319. * The browser gamepad
  25320. */
  25321. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25322. /**
  25323. * Callback triggered when the left joystick has changed
  25324. * @param callback
  25325. */
  25326. onleftstickchanged(callback: (values: StickValues) => void): void;
  25327. /**
  25328. * Callback triggered when the right joystick has changed
  25329. * @param callback
  25330. */
  25331. onrightstickchanged(callback: (values: StickValues) => void): void;
  25332. /**
  25333. * Gets the left joystick
  25334. */
  25335. get leftStick(): StickValues;
  25336. /**
  25337. * Sets the left joystick values
  25338. */
  25339. set leftStick(newValues: StickValues);
  25340. /**
  25341. * Gets the right joystick
  25342. */
  25343. get rightStick(): StickValues;
  25344. /**
  25345. * Sets the right joystick value
  25346. */
  25347. set rightStick(newValues: StickValues);
  25348. /**
  25349. * Updates the gamepad joystick positions
  25350. */
  25351. update(): void;
  25352. /**
  25353. * Disposes the gamepad
  25354. */
  25355. dispose(): void;
  25356. }
  25357. /**
  25358. * Represents a generic gamepad
  25359. */
  25360. export class GenericPad extends Gamepad {
  25361. private _buttons;
  25362. private _onbuttondown;
  25363. private _onbuttonup;
  25364. /**
  25365. * Observable triggered when a button has been pressed
  25366. */
  25367. onButtonDownObservable: Observable<number>;
  25368. /**
  25369. * Observable triggered when a button has been released
  25370. */
  25371. onButtonUpObservable: Observable<number>;
  25372. /**
  25373. * Callback triggered when a button has been pressed
  25374. * @param callback Called when a button has been pressed
  25375. */
  25376. onbuttondown(callback: (buttonPressed: number) => void): void;
  25377. /**
  25378. * Callback triggered when a button has been released
  25379. * @param callback Called when a button has been released
  25380. */
  25381. onbuttonup(callback: (buttonReleased: number) => void): void;
  25382. /**
  25383. * Initializes the generic gamepad
  25384. * @param id The id of the generic gamepad
  25385. * @param index The index of the generic gamepad
  25386. * @param browserGamepad The browser gamepad
  25387. */
  25388. constructor(id: string, index: number, browserGamepad: any);
  25389. private _setButtonValue;
  25390. /**
  25391. * Updates the generic gamepad
  25392. */
  25393. update(): void;
  25394. /**
  25395. * Disposes the generic gamepad
  25396. */
  25397. dispose(): void;
  25398. }
  25399. }
  25400. declare module BABYLON {
  25401. /**
  25402. * Defines a runtime animation
  25403. */
  25404. export class RuntimeAnimation {
  25405. private _events;
  25406. /**
  25407. * The current frame of the runtime animation
  25408. */
  25409. private _currentFrame;
  25410. /**
  25411. * The animation used by the runtime animation
  25412. */
  25413. private _animation;
  25414. /**
  25415. * The target of the runtime animation
  25416. */
  25417. private _target;
  25418. /**
  25419. * The initiating animatable
  25420. */
  25421. private _host;
  25422. /**
  25423. * The original value of the runtime animation
  25424. */
  25425. private _originalValue;
  25426. /**
  25427. * The original blend value of the runtime animation
  25428. */
  25429. private _originalBlendValue;
  25430. /**
  25431. * The offsets cache of the runtime animation
  25432. */
  25433. private _offsetsCache;
  25434. /**
  25435. * The high limits cache of the runtime animation
  25436. */
  25437. private _highLimitsCache;
  25438. /**
  25439. * Specifies if the runtime animation has been stopped
  25440. */
  25441. private _stopped;
  25442. /**
  25443. * The blending factor of the runtime animation
  25444. */
  25445. private _blendingFactor;
  25446. /**
  25447. * The BabylonJS scene
  25448. */
  25449. private _scene;
  25450. /**
  25451. * The current value of the runtime animation
  25452. */
  25453. private _currentValue;
  25454. /** @hidden */
  25455. _animationState: _IAnimationState;
  25456. /**
  25457. * The active target of the runtime animation
  25458. */
  25459. private _activeTargets;
  25460. private _currentActiveTarget;
  25461. private _directTarget;
  25462. /**
  25463. * The target path of the runtime animation
  25464. */
  25465. private _targetPath;
  25466. /**
  25467. * The weight of the runtime animation
  25468. */
  25469. private _weight;
  25470. /**
  25471. * The ratio offset of the runtime animation
  25472. */
  25473. private _ratioOffset;
  25474. /**
  25475. * The previous delay of the runtime animation
  25476. */
  25477. private _previousDelay;
  25478. /**
  25479. * The previous ratio of the runtime animation
  25480. */
  25481. private _previousRatio;
  25482. private _enableBlending;
  25483. private _keys;
  25484. private _minFrame;
  25485. private _maxFrame;
  25486. private _minValue;
  25487. private _maxValue;
  25488. private _targetIsArray;
  25489. /**
  25490. * Gets the current frame of the runtime animation
  25491. */
  25492. get currentFrame(): number;
  25493. /**
  25494. * Gets the weight of the runtime animation
  25495. */
  25496. get weight(): number;
  25497. /**
  25498. * Gets the current value of the runtime animation
  25499. */
  25500. get currentValue(): any;
  25501. /**
  25502. * Gets the target path of the runtime animation
  25503. */
  25504. get targetPath(): string;
  25505. /**
  25506. * Gets the actual target of the runtime animation
  25507. */
  25508. get target(): any;
  25509. /**
  25510. * Gets the additive state of the runtime animation
  25511. */
  25512. get isAdditive(): boolean;
  25513. /** @hidden */
  25514. _onLoop: () => void;
  25515. /**
  25516. * Create a new RuntimeAnimation object
  25517. * @param target defines the target of the animation
  25518. * @param animation defines the source animation object
  25519. * @param scene defines the hosting scene
  25520. * @param host defines the initiating Animatable
  25521. */
  25522. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25523. private _preparePath;
  25524. /**
  25525. * Gets the animation from the runtime animation
  25526. */
  25527. get animation(): Animation;
  25528. /**
  25529. * Resets the runtime animation to the beginning
  25530. * @param restoreOriginal defines whether to restore the target property to the original value
  25531. */
  25532. reset(restoreOriginal?: boolean): void;
  25533. /**
  25534. * Specifies if the runtime animation is stopped
  25535. * @returns Boolean specifying if the runtime animation is stopped
  25536. */
  25537. isStopped(): boolean;
  25538. /**
  25539. * Disposes of the runtime animation
  25540. */
  25541. dispose(): void;
  25542. /**
  25543. * Apply the interpolated value to the target
  25544. * @param currentValue defines the value computed by the animation
  25545. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25546. */
  25547. setValue(currentValue: any, weight: number): void;
  25548. private _getOriginalValues;
  25549. private _setValue;
  25550. /**
  25551. * Gets the loop pmode of the runtime animation
  25552. * @returns Loop Mode
  25553. */
  25554. private _getCorrectLoopMode;
  25555. /**
  25556. * Move the current animation to a given frame
  25557. * @param frame defines the frame to move to
  25558. */
  25559. goToFrame(frame: number): void;
  25560. /**
  25561. * @hidden Internal use only
  25562. */
  25563. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25564. /**
  25565. * Execute the current animation
  25566. * @param delay defines the delay to add to the current frame
  25567. * @param from defines the lower bound of the animation range
  25568. * @param to defines the upper bound of the animation range
  25569. * @param loop defines if the current animation must loop
  25570. * @param speedRatio defines the current speed ratio
  25571. * @param weight defines the weight of the animation (default is -1 so no weight)
  25572. * @param onLoop optional callback called when animation loops
  25573. * @returns a boolean indicating if the animation is running
  25574. */
  25575. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25576. }
  25577. }
  25578. declare module BABYLON {
  25579. /**
  25580. * Class used to store an actual running animation
  25581. */
  25582. export class Animatable {
  25583. /** defines the target object */
  25584. target: any;
  25585. /** defines the starting frame number (default is 0) */
  25586. fromFrame: number;
  25587. /** defines the ending frame number (default is 100) */
  25588. toFrame: number;
  25589. /** defines if the animation must loop (default is false) */
  25590. loopAnimation: boolean;
  25591. /** defines a callback to call when animation ends if it is not looping */
  25592. onAnimationEnd?: (() => void) | null | undefined;
  25593. /** defines a callback to call when animation loops */
  25594. onAnimationLoop?: (() => void) | null | undefined;
  25595. /** defines whether the animation should be evaluated additively */
  25596. isAdditive: boolean;
  25597. private _localDelayOffset;
  25598. private _pausedDelay;
  25599. private _runtimeAnimations;
  25600. private _paused;
  25601. private _scene;
  25602. private _speedRatio;
  25603. private _weight;
  25604. private _syncRoot;
  25605. /**
  25606. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25607. * This will only apply for non looping animation (default is true)
  25608. */
  25609. disposeOnEnd: boolean;
  25610. /**
  25611. * Gets a boolean indicating if the animation has started
  25612. */
  25613. animationStarted: boolean;
  25614. /**
  25615. * Observer raised when the animation ends
  25616. */
  25617. onAnimationEndObservable: Observable<Animatable>;
  25618. /**
  25619. * Observer raised when the animation loops
  25620. */
  25621. onAnimationLoopObservable: Observable<Animatable>;
  25622. /**
  25623. * Gets the root Animatable used to synchronize and normalize animations
  25624. */
  25625. get syncRoot(): Nullable<Animatable>;
  25626. /**
  25627. * Gets the current frame of the first RuntimeAnimation
  25628. * Used to synchronize Animatables
  25629. */
  25630. get masterFrame(): number;
  25631. /**
  25632. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25633. */
  25634. get weight(): number;
  25635. set weight(value: number);
  25636. /**
  25637. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25638. */
  25639. get speedRatio(): number;
  25640. set speedRatio(value: number);
  25641. /**
  25642. * Creates a new Animatable
  25643. * @param scene defines the hosting scene
  25644. * @param target defines the target object
  25645. * @param fromFrame defines the starting frame number (default is 0)
  25646. * @param toFrame defines the ending frame number (default is 100)
  25647. * @param loopAnimation defines if the animation must loop (default is false)
  25648. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25649. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25650. * @param animations defines a group of animation to add to the new Animatable
  25651. * @param onAnimationLoop defines a callback to call when animation loops
  25652. * @param isAdditive defines whether the animation should be evaluated additively
  25653. */
  25654. constructor(scene: Scene,
  25655. /** defines the target object */
  25656. target: any,
  25657. /** defines the starting frame number (default is 0) */
  25658. fromFrame?: number,
  25659. /** defines the ending frame number (default is 100) */
  25660. toFrame?: number,
  25661. /** defines if the animation must loop (default is false) */
  25662. loopAnimation?: boolean, speedRatio?: number,
  25663. /** defines a callback to call when animation ends if it is not looping */
  25664. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25665. /** defines a callback to call when animation loops */
  25666. onAnimationLoop?: (() => void) | null | undefined,
  25667. /** defines whether the animation should be evaluated additively */
  25668. isAdditive?: boolean);
  25669. /**
  25670. * Synchronize and normalize current Animatable with a source Animatable
  25671. * This is useful when using animation weights and when animations are not of the same length
  25672. * @param root defines the root Animatable to synchronize with
  25673. * @returns the current Animatable
  25674. */
  25675. syncWith(root: Animatable): Animatable;
  25676. /**
  25677. * Gets the list of runtime animations
  25678. * @returns an array of RuntimeAnimation
  25679. */
  25680. getAnimations(): RuntimeAnimation[];
  25681. /**
  25682. * Adds more animations to the current animatable
  25683. * @param target defines the target of the animations
  25684. * @param animations defines the new animations to add
  25685. */
  25686. appendAnimations(target: any, animations: Animation[]): void;
  25687. /**
  25688. * Gets the source animation for a specific property
  25689. * @param property defines the propertyu to look for
  25690. * @returns null or the source animation for the given property
  25691. */
  25692. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25693. /**
  25694. * Gets the runtime animation for a specific property
  25695. * @param property defines the propertyu to look for
  25696. * @returns null or the runtime animation for the given property
  25697. */
  25698. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25699. /**
  25700. * Resets the animatable to its original state
  25701. */
  25702. reset(): void;
  25703. /**
  25704. * Allows the animatable to blend with current running animations
  25705. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25706. * @param blendingSpeed defines the blending speed to use
  25707. */
  25708. enableBlending(blendingSpeed: number): void;
  25709. /**
  25710. * Disable animation blending
  25711. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25712. */
  25713. disableBlending(): void;
  25714. /**
  25715. * Jump directly to a given frame
  25716. * @param frame defines the frame to jump to
  25717. */
  25718. goToFrame(frame: number): void;
  25719. /**
  25720. * Pause the animation
  25721. */
  25722. pause(): void;
  25723. /**
  25724. * Restart the animation
  25725. */
  25726. restart(): void;
  25727. private _raiseOnAnimationEnd;
  25728. /**
  25729. * Stop and delete the current animation
  25730. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25731. * @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)
  25732. */
  25733. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25734. /**
  25735. * Wait asynchronously for the animation to end
  25736. * @returns a promise which will be fullfilled when the animation ends
  25737. */
  25738. waitAsync(): Promise<Animatable>;
  25739. /** @hidden */
  25740. _animate(delay: number): boolean;
  25741. }
  25742. interface Scene {
  25743. /** @hidden */
  25744. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25745. /** @hidden */
  25746. _processLateAnimationBindingsForMatrices(holder: {
  25747. totalWeight: number;
  25748. totalAdditiveWeight: number;
  25749. animations: RuntimeAnimation[];
  25750. additiveAnimations: RuntimeAnimation[];
  25751. originalValue: Matrix;
  25752. }): any;
  25753. /** @hidden */
  25754. _processLateAnimationBindingsForQuaternions(holder: {
  25755. totalWeight: number;
  25756. totalAdditiveWeight: number;
  25757. animations: RuntimeAnimation[];
  25758. additiveAnimations: RuntimeAnimation[];
  25759. originalValue: Quaternion;
  25760. }, refQuaternion: Quaternion): Quaternion;
  25761. /** @hidden */
  25762. _processLateAnimationBindings(): void;
  25763. /**
  25764. * Will start the animation sequence of a given target
  25765. * @param target defines the target
  25766. * @param from defines from which frame should animation start
  25767. * @param to defines until which frame should animation run.
  25768. * @param weight defines the weight to apply to the animation (1.0 by default)
  25769. * @param loop defines if the animation loops
  25770. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25771. * @param onAnimationEnd defines the function to be executed when the animation ends
  25772. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25773. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25774. * @param onAnimationLoop defines the callback to call when an animation loops
  25775. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25776. * @returns the animatable object created for this animation
  25777. */
  25778. 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;
  25779. /**
  25780. * Will start the animation sequence of a given target
  25781. * @param target defines the target
  25782. * @param from defines from which frame should animation start
  25783. * @param to defines until which frame should animation run.
  25784. * @param loop defines if the animation loops
  25785. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25786. * @param onAnimationEnd defines the function to be executed when the animation ends
  25787. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25788. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25789. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25790. * @param onAnimationLoop defines the callback to call when an animation loops
  25791. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25792. * @returns the animatable object created for this animation
  25793. */
  25794. 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;
  25795. /**
  25796. * Will start the animation sequence of a given target and its hierarchy
  25797. * @param target defines the target
  25798. * @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.
  25799. * @param from defines from which frame should animation start
  25800. * @param to defines until which frame should animation run.
  25801. * @param loop defines if the animation loops
  25802. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25803. * @param onAnimationEnd defines the function to be executed when the animation ends
  25804. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25805. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25806. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25807. * @param onAnimationLoop defines the callback to call when an animation loops
  25808. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25809. * @returns the list of created animatables
  25810. */
  25811. 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[];
  25812. /**
  25813. * Begin a new animation on a given node
  25814. * @param target defines the target where the animation will take place
  25815. * @param animations defines the list of animations to start
  25816. * @param from defines the initial value
  25817. * @param to defines the final value
  25818. * @param loop defines if you want animation to loop (off by default)
  25819. * @param speedRatio defines the speed ratio to apply to all animations
  25820. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25821. * @param onAnimationLoop defines the callback to call when an animation loops
  25822. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25823. * @returns the list of created animatables
  25824. */
  25825. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25826. /**
  25827. * Begin a new animation on a given node and its hierarchy
  25828. * @param target defines the root node where the animation will take place
  25829. * @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.
  25830. * @param animations defines the list of animations to start
  25831. * @param from defines the initial value
  25832. * @param to defines the final value
  25833. * @param loop defines if you want animation to loop (off by default)
  25834. * @param speedRatio defines the speed ratio to apply to all animations
  25835. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25836. * @param onAnimationLoop defines the callback to call when an animation loops
  25837. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25838. * @returns the list of animatables created for all nodes
  25839. */
  25840. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25841. /**
  25842. * Gets the animatable associated with a specific target
  25843. * @param target defines the target of the animatable
  25844. * @returns the required animatable if found
  25845. */
  25846. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25847. /**
  25848. * Gets all animatables associated with a given target
  25849. * @param target defines the target to look animatables for
  25850. * @returns an array of Animatables
  25851. */
  25852. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25853. /**
  25854. * Stops and removes all animations that have been applied to the scene
  25855. */
  25856. stopAllAnimations(): void;
  25857. /**
  25858. * Gets the current delta time used by animation engine
  25859. */
  25860. deltaTime: number;
  25861. }
  25862. interface Bone {
  25863. /**
  25864. * Copy an animation range from another bone
  25865. * @param source defines the source bone
  25866. * @param rangeName defines the range name to copy
  25867. * @param frameOffset defines the frame offset
  25868. * @param rescaleAsRequired defines if rescaling must be applied if required
  25869. * @param skelDimensionsRatio defines the scaling ratio
  25870. * @returns true if operation was successful
  25871. */
  25872. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25873. }
  25874. }
  25875. declare module BABYLON {
  25876. /**
  25877. * Class used to override all child animations of a given target
  25878. */
  25879. export class AnimationPropertiesOverride {
  25880. /**
  25881. * Gets or sets a value indicating if animation blending must be used
  25882. */
  25883. enableBlending: boolean;
  25884. /**
  25885. * Gets or sets the blending speed to use when enableBlending is true
  25886. */
  25887. blendingSpeed: number;
  25888. /**
  25889. * Gets or sets the default loop mode to use
  25890. */
  25891. loopMode: number;
  25892. }
  25893. }
  25894. declare module BABYLON {
  25895. /**
  25896. * Class used to handle skinning animations
  25897. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25898. */
  25899. export class Skeleton implements IAnimatable {
  25900. /** defines the skeleton name */
  25901. name: string;
  25902. /** defines the skeleton Id */
  25903. id: string;
  25904. /**
  25905. * Defines the list of child bones
  25906. */
  25907. bones: Bone[];
  25908. /**
  25909. * Defines an estimate of the dimension of the skeleton at rest
  25910. */
  25911. dimensionsAtRest: Vector3;
  25912. /**
  25913. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25914. */
  25915. needInitialSkinMatrix: boolean;
  25916. /**
  25917. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25918. */
  25919. overrideMesh: Nullable<AbstractMesh>;
  25920. /**
  25921. * Gets the list of animations attached to this skeleton
  25922. */
  25923. animations: Array<Animation>;
  25924. private _scene;
  25925. private _isDirty;
  25926. private _transformMatrices;
  25927. private _transformMatrixTexture;
  25928. private _meshesWithPoseMatrix;
  25929. private _animatables;
  25930. private _identity;
  25931. private _synchronizedWithMesh;
  25932. private _ranges;
  25933. private _lastAbsoluteTransformsUpdateId;
  25934. private _canUseTextureForBones;
  25935. private _uniqueId;
  25936. /** @hidden */
  25937. _numBonesWithLinkedTransformNode: number;
  25938. /** @hidden */
  25939. _hasWaitingData: Nullable<boolean>;
  25940. /** @hidden */
  25941. _waitingOverrideMeshId: Nullable<string>;
  25942. /**
  25943. * Specifies if the skeleton should be serialized
  25944. */
  25945. doNotSerialize: boolean;
  25946. private _useTextureToStoreBoneMatrices;
  25947. /**
  25948. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25949. * Please note that this option is not available if the hardware does not support it
  25950. */
  25951. get useTextureToStoreBoneMatrices(): boolean;
  25952. set useTextureToStoreBoneMatrices(value: boolean);
  25953. private _animationPropertiesOverride;
  25954. /**
  25955. * Gets or sets the animation properties override
  25956. */
  25957. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25958. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25959. /**
  25960. * List of inspectable custom properties (used by the Inspector)
  25961. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25962. */
  25963. inspectableCustomProperties: IInspectable[];
  25964. /**
  25965. * An observable triggered before computing the skeleton's matrices
  25966. */
  25967. onBeforeComputeObservable: Observable<Skeleton>;
  25968. /**
  25969. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25970. */
  25971. get isUsingTextureForMatrices(): boolean;
  25972. /**
  25973. * Gets the unique ID of this skeleton
  25974. */
  25975. get uniqueId(): number;
  25976. /**
  25977. * Creates a new skeleton
  25978. * @param name defines the skeleton name
  25979. * @param id defines the skeleton Id
  25980. * @param scene defines the hosting scene
  25981. */
  25982. constructor(
  25983. /** defines the skeleton name */
  25984. name: string,
  25985. /** defines the skeleton Id */
  25986. id: string, scene: Scene);
  25987. /**
  25988. * Gets the current object class name.
  25989. * @return the class name
  25990. */
  25991. getClassName(): string;
  25992. /**
  25993. * Returns an array containing the root bones
  25994. * @returns an array containing the root bones
  25995. */
  25996. getChildren(): Array<Bone>;
  25997. /**
  25998. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25999. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26000. * @returns a Float32Array containing matrices data
  26001. */
  26002. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26003. /**
  26004. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26005. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26006. * @returns a raw texture containing the data
  26007. */
  26008. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26009. /**
  26010. * Gets the current hosting scene
  26011. * @returns a scene object
  26012. */
  26013. getScene(): Scene;
  26014. /**
  26015. * Gets a string representing the current skeleton data
  26016. * @param fullDetails defines a boolean indicating if we want a verbose version
  26017. * @returns a string representing the current skeleton data
  26018. */
  26019. toString(fullDetails?: boolean): string;
  26020. /**
  26021. * Get bone's index searching by name
  26022. * @param name defines bone's name to search for
  26023. * @return the indice of the bone. Returns -1 if not found
  26024. */
  26025. getBoneIndexByName(name: string): number;
  26026. /**
  26027. * Creater a new animation range
  26028. * @param name defines the name of the range
  26029. * @param from defines the start key
  26030. * @param to defines the end key
  26031. */
  26032. createAnimationRange(name: string, from: number, to: number): void;
  26033. /**
  26034. * Delete a specific animation range
  26035. * @param name defines the name of the range
  26036. * @param deleteFrames defines if frames must be removed as well
  26037. */
  26038. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26039. /**
  26040. * Gets a specific animation range
  26041. * @param name defines the name of the range to look for
  26042. * @returns the requested animation range or null if not found
  26043. */
  26044. getAnimationRange(name: string): Nullable<AnimationRange>;
  26045. /**
  26046. * Gets the list of all animation ranges defined on this skeleton
  26047. * @returns an array
  26048. */
  26049. getAnimationRanges(): Nullable<AnimationRange>[];
  26050. /**
  26051. * Copy animation range from a source skeleton.
  26052. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26053. * @param source defines the source skeleton
  26054. * @param name defines the name of the range to copy
  26055. * @param rescaleAsRequired defines if rescaling must be applied if required
  26056. * @returns true if operation was successful
  26057. */
  26058. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26059. /**
  26060. * Forces the skeleton to go to rest pose
  26061. */
  26062. returnToRest(): void;
  26063. private _getHighestAnimationFrame;
  26064. /**
  26065. * Begin a specific animation range
  26066. * @param name defines the name of the range to start
  26067. * @param loop defines if looping must be turned on (false by default)
  26068. * @param speedRatio defines the speed ratio to apply (1 by default)
  26069. * @param onAnimationEnd defines a callback which will be called when animation will end
  26070. * @returns a new animatable
  26071. */
  26072. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26073. /**
  26074. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26075. * @param skeleton defines the Skeleton containing the animation range to convert
  26076. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26077. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26078. * @returns the original skeleton
  26079. */
  26080. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26081. /** @hidden */
  26082. _markAsDirty(): void;
  26083. /** @hidden */
  26084. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26085. /** @hidden */
  26086. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26087. private _computeTransformMatrices;
  26088. /**
  26089. * Build all resources required to render a skeleton
  26090. */
  26091. prepare(): void;
  26092. /**
  26093. * Gets the list of animatables currently running for this skeleton
  26094. * @returns an array of animatables
  26095. */
  26096. getAnimatables(): IAnimatable[];
  26097. /**
  26098. * Clone the current skeleton
  26099. * @param name defines the name of the new skeleton
  26100. * @param id defines the id of the new skeleton
  26101. * @returns the new skeleton
  26102. */
  26103. clone(name: string, id?: string): Skeleton;
  26104. /**
  26105. * Enable animation blending for this skeleton
  26106. * @param blendingSpeed defines the blending speed to apply
  26107. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26108. */
  26109. enableBlending(blendingSpeed?: number): void;
  26110. /**
  26111. * Releases all resources associated with the current skeleton
  26112. */
  26113. dispose(): void;
  26114. /**
  26115. * Serialize the skeleton in a JSON object
  26116. * @returns a JSON object
  26117. */
  26118. serialize(): any;
  26119. /**
  26120. * Creates a new skeleton from serialized data
  26121. * @param parsedSkeleton defines the serialized data
  26122. * @param scene defines the hosting scene
  26123. * @returns a new skeleton
  26124. */
  26125. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26126. /**
  26127. * Compute all node absolute transforms
  26128. * @param forceUpdate defines if computation must be done even if cache is up to date
  26129. */
  26130. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26131. /**
  26132. * Gets the root pose matrix
  26133. * @returns a matrix
  26134. */
  26135. getPoseMatrix(): Nullable<Matrix>;
  26136. /**
  26137. * Sorts bones per internal index
  26138. */
  26139. sortBones(): void;
  26140. private _sortBones;
  26141. /**
  26142. * Set the current local matrix as the restPose for all bones in the skeleton.
  26143. */
  26144. setCurrentPoseAsRest(): void;
  26145. }
  26146. }
  26147. declare module BABYLON {
  26148. /**
  26149. * Class used to store bone information
  26150. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26151. */
  26152. export class Bone extends Node {
  26153. /**
  26154. * defines the bone name
  26155. */
  26156. name: string;
  26157. private static _tmpVecs;
  26158. private static _tmpQuat;
  26159. private static _tmpMats;
  26160. /**
  26161. * Gets the list of child bones
  26162. */
  26163. children: Bone[];
  26164. /** Gets the animations associated with this bone */
  26165. animations: Animation[];
  26166. /**
  26167. * Gets or sets bone length
  26168. */
  26169. length: number;
  26170. /**
  26171. * @hidden Internal only
  26172. * Set this value to map this bone to a different index in the transform matrices
  26173. * Set this value to -1 to exclude the bone from the transform matrices
  26174. */
  26175. _index: Nullable<number>;
  26176. private _skeleton;
  26177. private _localMatrix;
  26178. private _restPose;
  26179. private _bindPose;
  26180. private _baseMatrix;
  26181. private _absoluteTransform;
  26182. private _invertedAbsoluteTransform;
  26183. private _parent;
  26184. private _scalingDeterminant;
  26185. private _worldTransform;
  26186. private _localScaling;
  26187. private _localRotation;
  26188. private _localPosition;
  26189. private _needToDecompose;
  26190. private _needToCompose;
  26191. /** @hidden */
  26192. _linkedTransformNode: Nullable<TransformNode>;
  26193. /** @hidden */
  26194. _waitingTransformNodeId: Nullable<string>;
  26195. /** @hidden */
  26196. get _matrix(): Matrix;
  26197. /** @hidden */
  26198. set _matrix(value: Matrix);
  26199. /**
  26200. * Create a new bone
  26201. * @param name defines the bone name
  26202. * @param skeleton defines the parent skeleton
  26203. * @param parentBone defines the parent (can be null if the bone is the root)
  26204. * @param localMatrix defines the local matrix
  26205. * @param restPose defines the rest pose matrix
  26206. * @param baseMatrix defines the base matrix
  26207. * @param index defines index of the bone in the hiearchy
  26208. */
  26209. constructor(
  26210. /**
  26211. * defines the bone name
  26212. */
  26213. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26214. /**
  26215. * Gets the current object class name.
  26216. * @return the class name
  26217. */
  26218. getClassName(): string;
  26219. /**
  26220. * Gets the parent skeleton
  26221. * @returns a skeleton
  26222. */
  26223. getSkeleton(): Skeleton;
  26224. /**
  26225. * Gets parent bone
  26226. * @returns a bone or null if the bone is the root of the bone hierarchy
  26227. */
  26228. getParent(): Nullable<Bone>;
  26229. /**
  26230. * Returns an array containing the root bones
  26231. * @returns an array containing the root bones
  26232. */
  26233. getChildren(): Array<Bone>;
  26234. /**
  26235. * Gets the node index in matrix array generated for rendering
  26236. * @returns the node index
  26237. */
  26238. getIndex(): number;
  26239. /**
  26240. * Sets the parent bone
  26241. * @param parent defines the parent (can be null if the bone is the root)
  26242. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26243. */
  26244. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26245. /**
  26246. * Gets the local matrix
  26247. * @returns a matrix
  26248. */
  26249. getLocalMatrix(): Matrix;
  26250. /**
  26251. * Gets the base matrix (initial matrix which remains unchanged)
  26252. * @returns a matrix
  26253. */
  26254. getBaseMatrix(): Matrix;
  26255. /**
  26256. * Gets the rest pose matrix
  26257. * @returns a matrix
  26258. */
  26259. getRestPose(): Matrix;
  26260. /**
  26261. * Sets the rest pose matrix
  26262. * @param matrix the local-space rest pose to set for this bone
  26263. */
  26264. setRestPose(matrix: Matrix): void;
  26265. /**
  26266. * Gets the bind pose matrix
  26267. * @returns the bind pose matrix
  26268. */
  26269. getBindPose(): Matrix;
  26270. /**
  26271. * Sets the bind pose matrix
  26272. * @param matrix the local-space bind pose to set for this bone
  26273. */
  26274. setBindPose(matrix: Matrix): void;
  26275. /**
  26276. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26277. */
  26278. getWorldMatrix(): Matrix;
  26279. /**
  26280. * Sets the local matrix to rest pose matrix
  26281. */
  26282. returnToRest(): void;
  26283. /**
  26284. * Gets the inverse of the absolute transform matrix.
  26285. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26286. * @returns a matrix
  26287. */
  26288. getInvertedAbsoluteTransform(): Matrix;
  26289. /**
  26290. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26291. * @returns a matrix
  26292. */
  26293. getAbsoluteTransform(): Matrix;
  26294. /**
  26295. * Links with the given transform node.
  26296. * The local matrix of this bone is copied from the transform node every frame.
  26297. * @param transformNode defines the transform node to link to
  26298. */
  26299. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26300. /**
  26301. * Gets the node used to drive the bone's transformation
  26302. * @returns a transform node or null
  26303. */
  26304. getTransformNode(): Nullable<TransformNode>;
  26305. /** Gets or sets current position (in local space) */
  26306. get position(): Vector3;
  26307. set position(newPosition: Vector3);
  26308. /** Gets or sets current rotation (in local space) */
  26309. get rotation(): Vector3;
  26310. set rotation(newRotation: Vector3);
  26311. /** Gets or sets current rotation quaternion (in local space) */
  26312. get rotationQuaternion(): Quaternion;
  26313. set rotationQuaternion(newRotation: Quaternion);
  26314. /** Gets or sets current scaling (in local space) */
  26315. get scaling(): Vector3;
  26316. set scaling(newScaling: Vector3);
  26317. /**
  26318. * Gets the animation properties override
  26319. */
  26320. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26321. private _decompose;
  26322. private _compose;
  26323. /**
  26324. * Update the base and local matrices
  26325. * @param matrix defines the new base or local matrix
  26326. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26327. * @param updateLocalMatrix defines if the local matrix should be updated
  26328. */
  26329. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26330. /** @hidden */
  26331. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26332. /**
  26333. * Flag the bone as dirty (Forcing it to update everything)
  26334. */
  26335. markAsDirty(): void;
  26336. /** @hidden */
  26337. _markAsDirtyAndCompose(): void;
  26338. private _markAsDirtyAndDecompose;
  26339. /**
  26340. * Translate the bone in local or world space
  26341. * @param vec The amount to translate the bone
  26342. * @param space The space that the translation is in
  26343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26344. */
  26345. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26346. /**
  26347. * Set the postion of the bone in local or world space
  26348. * @param position The position to set the bone
  26349. * @param space The space that the position is in
  26350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26351. */
  26352. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26353. /**
  26354. * Set the absolute position of the bone (world space)
  26355. * @param position The position to set the bone
  26356. * @param mesh The mesh that this bone is attached to
  26357. */
  26358. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26359. /**
  26360. * Scale the bone on the x, y and z axes (in local space)
  26361. * @param x The amount to scale the bone on the x axis
  26362. * @param y The amount to scale the bone on the y axis
  26363. * @param z The amount to scale the bone on the z axis
  26364. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26365. */
  26366. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26367. /**
  26368. * Set the bone scaling in local space
  26369. * @param scale defines the scaling vector
  26370. */
  26371. setScale(scale: Vector3): void;
  26372. /**
  26373. * Gets the current scaling in local space
  26374. * @returns the current scaling vector
  26375. */
  26376. getScale(): Vector3;
  26377. /**
  26378. * Gets the current scaling in local space and stores it in a target vector
  26379. * @param result defines the target vector
  26380. */
  26381. getScaleToRef(result: Vector3): void;
  26382. /**
  26383. * Set the yaw, pitch, and roll of the bone in local or world space
  26384. * @param yaw The rotation of the bone on the y axis
  26385. * @param pitch The rotation of the bone on the x axis
  26386. * @param roll The rotation of the bone on the z axis
  26387. * @param space The space that the axes of rotation are in
  26388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26389. */
  26390. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26391. /**
  26392. * Add a rotation to the bone on an axis in local or world space
  26393. * @param axis The axis to rotate the bone on
  26394. * @param amount The amount to rotate the bone
  26395. * @param space The space that the axis is in
  26396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26397. */
  26398. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26399. /**
  26400. * Set the rotation of the bone to a particular axis angle in local or world space
  26401. * @param axis The axis to rotate the bone on
  26402. * @param angle The angle that the bone should be rotated to
  26403. * @param space The space that the axis is in
  26404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26405. */
  26406. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26407. /**
  26408. * Set the euler rotation of the bone in local or world space
  26409. * @param rotation The euler rotation that the bone should be set to
  26410. * @param space The space that the rotation is in
  26411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26412. */
  26413. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26414. /**
  26415. * Set the quaternion rotation of the bone in local or world space
  26416. * @param quat The quaternion rotation that the bone should be set to
  26417. * @param space The space that the rotation is in
  26418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26419. */
  26420. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26421. /**
  26422. * Set the rotation matrix of the bone in local or world space
  26423. * @param rotMat The rotation matrix that the bone should be set to
  26424. * @param space The space that the rotation is in
  26425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26426. */
  26427. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26428. private _rotateWithMatrix;
  26429. private _getNegativeRotationToRef;
  26430. /**
  26431. * Get the position of the bone in local or world space
  26432. * @param space The space that the returned position is in
  26433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26434. * @returns The position of the bone
  26435. */
  26436. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26437. /**
  26438. * Copy the position of the bone to a vector3 in local or world space
  26439. * @param space The space that the returned position is in
  26440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26441. * @param result The vector3 to copy the position to
  26442. */
  26443. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26444. /**
  26445. * Get the absolute position of the bone (world space)
  26446. * @param mesh The mesh that this bone is attached to
  26447. * @returns The absolute position of the bone
  26448. */
  26449. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26450. /**
  26451. * Copy the absolute position of the bone (world space) to the result param
  26452. * @param mesh The mesh that this bone is attached to
  26453. * @param result The vector3 to copy the absolute position to
  26454. */
  26455. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26456. /**
  26457. * Compute the absolute transforms of this bone and its children
  26458. */
  26459. computeAbsoluteTransforms(): void;
  26460. /**
  26461. * Get the world direction from an axis that is in the local space of the bone
  26462. * @param localAxis The local direction that is used to compute the world direction
  26463. * @param mesh The mesh that this bone is attached to
  26464. * @returns The world direction
  26465. */
  26466. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26467. /**
  26468. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26469. * @param localAxis The local direction that is used to compute the world direction
  26470. * @param mesh The mesh that this bone is attached to
  26471. * @param result The vector3 that the world direction will be copied to
  26472. */
  26473. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26474. /**
  26475. * Get the euler rotation of the bone in local or world space
  26476. * @param space The space that the rotation should be in
  26477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26478. * @returns The euler rotation
  26479. */
  26480. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26481. /**
  26482. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26483. * @param space The space that the rotation should be in
  26484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26485. * @param result The vector3 that the rotation should be copied to
  26486. */
  26487. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26488. /**
  26489. * Get the quaternion rotation of the bone in either local or world space
  26490. * @param space The space that the rotation should be in
  26491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26492. * @returns The quaternion rotation
  26493. */
  26494. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26495. /**
  26496. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26497. * @param space The space that the rotation should be in
  26498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26499. * @param result The quaternion that the rotation should be copied to
  26500. */
  26501. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26502. /**
  26503. * Get the rotation matrix of the bone in local or world space
  26504. * @param space The space that the rotation should be in
  26505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26506. * @returns The rotation matrix
  26507. */
  26508. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26509. /**
  26510. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26511. * @param space The space that the rotation should be in
  26512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26513. * @param result The quaternion that the rotation should be copied to
  26514. */
  26515. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26516. /**
  26517. * Get the world position of a point that is in the local space of the bone
  26518. * @param position The local position
  26519. * @param mesh The mesh that this bone is attached to
  26520. * @returns The world position
  26521. */
  26522. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26523. /**
  26524. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26525. * @param position The local position
  26526. * @param mesh The mesh that this bone is attached to
  26527. * @param result The vector3 that the world position should be copied to
  26528. */
  26529. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26530. /**
  26531. * Get the local position of a point that is in world space
  26532. * @param position The world position
  26533. * @param mesh The mesh that this bone is attached to
  26534. * @returns The local position
  26535. */
  26536. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26537. /**
  26538. * Get the local position of a point that is in world space and copy it to the result param
  26539. * @param position The world position
  26540. * @param mesh The mesh that this bone is attached to
  26541. * @param result The vector3 that the local position should be copied to
  26542. */
  26543. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26544. /**
  26545. * Set the current local matrix as the restPose for this bone.
  26546. */
  26547. setCurrentPoseAsRest(): void;
  26548. }
  26549. }
  26550. declare module BABYLON {
  26551. /**
  26552. * 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.
  26553. * @see https://doc.babylonjs.com/how_to/transformnode
  26554. */
  26555. export class TransformNode extends Node {
  26556. /**
  26557. * Object will not rotate to face the camera
  26558. */
  26559. static BILLBOARDMODE_NONE: number;
  26560. /**
  26561. * Object will rotate to face the camera but only on the x axis
  26562. */
  26563. static BILLBOARDMODE_X: number;
  26564. /**
  26565. * Object will rotate to face the camera but only on the y axis
  26566. */
  26567. static BILLBOARDMODE_Y: number;
  26568. /**
  26569. * Object will rotate to face the camera but only on the z axis
  26570. */
  26571. static BILLBOARDMODE_Z: number;
  26572. /**
  26573. * Object will rotate to face the camera
  26574. */
  26575. static BILLBOARDMODE_ALL: number;
  26576. /**
  26577. * Object will rotate to face the camera's position instead of orientation
  26578. */
  26579. static BILLBOARDMODE_USE_POSITION: number;
  26580. private static _TmpRotation;
  26581. private static _TmpScaling;
  26582. private static _TmpTranslation;
  26583. private _forward;
  26584. private _forwardInverted;
  26585. private _up;
  26586. private _right;
  26587. private _rightInverted;
  26588. private _position;
  26589. private _rotation;
  26590. private _rotationQuaternion;
  26591. protected _scaling: Vector3;
  26592. protected _isDirty: boolean;
  26593. private _transformToBoneReferal;
  26594. private _isAbsoluteSynced;
  26595. private _billboardMode;
  26596. /**
  26597. * Gets or sets the billboard mode. Default is 0.
  26598. *
  26599. * | Value | Type | Description |
  26600. * | --- | --- | --- |
  26601. * | 0 | BILLBOARDMODE_NONE | |
  26602. * | 1 | BILLBOARDMODE_X | |
  26603. * | 2 | BILLBOARDMODE_Y | |
  26604. * | 4 | BILLBOARDMODE_Z | |
  26605. * | 7 | BILLBOARDMODE_ALL | |
  26606. *
  26607. */
  26608. get billboardMode(): number;
  26609. set billboardMode(value: number);
  26610. private _preserveParentRotationForBillboard;
  26611. /**
  26612. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26613. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26614. */
  26615. get preserveParentRotationForBillboard(): boolean;
  26616. set preserveParentRotationForBillboard(value: boolean);
  26617. /**
  26618. * 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
  26619. */
  26620. scalingDeterminant: number;
  26621. private _infiniteDistance;
  26622. /**
  26623. * Gets or sets the distance of the object to max, often used by skybox
  26624. */
  26625. get infiniteDistance(): boolean;
  26626. set infiniteDistance(value: boolean);
  26627. /**
  26628. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26629. * By default the system will update normals to compensate
  26630. */
  26631. ignoreNonUniformScaling: boolean;
  26632. /**
  26633. * 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
  26634. */
  26635. reIntegrateRotationIntoRotationQuaternion: boolean;
  26636. /** @hidden */
  26637. _poseMatrix: Nullable<Matrix>;
  26638. /** @hidden */
  26639. _localMatrix: Matrix;
  26640. private _usePivotMatrix;
  26641. private _absolutePosition;
  26642. private _absoluteScaling;
  26643. private _absoluteRotationQuaternion;
  26644. private _pivotMatrix;
  26645. private _pivotMatrixInverse;
  26646. /** @hidden */
  26647. _postMultiplyPivotMatrix: boolean;
  26648. protected _isWorldMatrixFrozen: boolean;
  26649. /** @hidden */
  26650. _indexInSceneTransformNodesArray: number;
  26651. /**
  26652. * An event triggered after the world matrix is updated
  26653. */
  26654. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26655. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26656. /**
  26657. * Gets a string identifying the name of the class
  26658. * @returns "TransformNode" string
  26659. */
  26660. getClassName(): string;
  26661. /**
  26662. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26663. */
  26664. get position(): Vector3;
  26665. set position(newPosition: Vector3);
  26666. /**
  26667. * 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)).
  26668. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26669. */
  26670. get rotation(): Vector3;
  26671. set rotation(newRotation: Vector3);
  26672. /**
  26673. * 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)).
  26674. */
  26675. get scaling(): Vector3;
  26676. set scaling(newScaling: Vector3);
  26677. /**
  26678. * 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).
  26679. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26680. */
  26681. get rotationQuaternion(): Nullable<Quaternion>;
  26682. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26683. /**
  26684. * The forward direction of that transform in world space.
  26685. */
  26686. get forward(): Vector3;
  26687. /**
  26688. * The up direction of that transform in world space.
  26689. */
  26690. get up(): Vector3;
  26691. /**
  26692. * The right direction of that transform in world space.
  26693. */
  26694. get right(): Vector3;
  26695. /**
  26696. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26697. * @param matrix the matrix to copy the pose from
  26698. * @returns this TransformNode.
  26699. */
  26700. updatePoseMatrix(matrix: Matrix): TransformNode;
  26701. /**
  26702. * Returns the mesh Pose matrix.
  26703. * @returns the pose matrix
  26704. */
  26705. getPoseMatrix(): Matrix;
  26706. /** @hidden */
  26707. _isSynchronized(): boolean;
  26708. /** @hidden */
  26709. _initCache(): void;
  26710. /**
  26711. * Flag the transform node as dirty (Forcing it to update everything)
  26712. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26713. * @returns this transform node
  26714. */
  26715. markAsDirty(property: string): TransformNode;
  26716. /**
  26717. * Returns the current mesh absolute position.
  26718. * Returns a Vector3.
  26719. */
  26720. get absolutePosition(): Vector3;
  26721. /**
  26722. * Returns the current mesh absolute scaling.
  26723. * Returns a Vector3.
  26724. */
  26725. get absoluteScaling(): Vector3;
  26726. /**
  26727. * Returns the current mesh absolute rotation.
  26728. * Returns a Quaternion.
  26729. */
  26730. get absoluteRotationQuaternion(): Quaternion;
  26731. /**
  26732. * Sets a new matrix to apply before all other transformation
  26733. * @param matrix defines the transform matrix
  26734. * @returns the current TransformNode
  26735. */
  26736. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26737. /**
  26738. * Sets a new pivot matrix to the current node
  26739. * @param matrix defines the new pivot matrix to use
  26740. * @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
  26741. * @returns the current TransformNode
  26742. */
  26743. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26744. /**
  26745. * Returns the mesh pivot matrix.
  26746. * Default : Identity.
  26747. * @returns the matrix
  26748. */
  26749. getPivotMatrix(): Matrix;
  26750. /**
  26751. * Instantiate (when possible) or clone that node with its hierarchy
  26752. * @param newParent defines the new parent to use for the instance (or clone)
  26753. * @param options defines options to configure how copy is done
  26754. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26755. * @returns an instance (or a clone) of the current node with its hiearchy
  26756. */
  26757. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26758. doNotInstantiate: boolean;
  26759. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26760. /**
  26761. * Prevents the World matrix to be computed any longer
  26762. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26763. * @returns the TransformNode.
  26764. */
  26765. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26766. /**
  26767. * Allows back the World matrix computation.
  26768. * @returns the TransformNode.
  26769. */
  26770. unfreezeWorldMatrix(): this;
  26771. /**
  26772. * True if the World matrix has been frozen.
  26773. */
  26774. get isWorldMatrixFrozen(): boolean;
  26775. /**
  26776. * Retuns the mesh absolute position in the World.
  26777. * @returns a Vector3.
  26778. */
  26779. getAbsolutePosition(): Vector3;
  26780. /**
  26781. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26782. * @param absolutePosition the absolute position to set
  26783. * @returns the TransformNode.
  26784. */
  26785. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26786. /**
  26787. * Sets the mesh position in its local space.
  26788. * @param vector3 the position to set in localspace
  26789. * @returns the TransformNode.
  26790. */
  26791. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26792. /**
  26793. * Returns the mesh position in the local space from the current World matrix values.
  26794. * @returns a new Vector3.
  26795. */
  26796. getPositionExpressedInLocalSpace(): Vector3;
  26797. /**
  26798. * Translates the mesh along the passed Vector3 in its local space.
  26799. * @param vector3 the distance to translate in localspace
  26800. * @returns the TransformNode.
  26801. */
  26802. locallyTranslate(vector3: Vector3): TransformNode;
  26803. private static _lookAtVectorCache;
  26804. /**
  26805. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26806. * @param targetPoint the position (must be in same space as current mesh) to look at
  26807. * @param yawCor optional yaw (y-axis) correction in radians
  26808. * @param pitchCor optional pitch (x-axis) correction in radians
  26809. * @param rollCor optional roll (z-axis) correction in radians
  26810. * @param space the choosen space of the target
  26811. * @returns the TransformNode.
  26812. */
  26813. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26814. /**
  26815. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26816. * This Vector3 is expressed in the World space.
  26817. * @param localAxis axis to rotate
  26818. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26819. */
  26820. getDirection(localAxis: Vector3): Vector3;
  26821. /**
  26822. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26823. * localAxis is expressed in the mesh local space.
  26824. * result is computed in the Wordl space from the mesh World matrix.
  26825. * @param localAxis axis to rotate
  26826. * @param result the resulting transformnode
  26827. * @returns this TransformNode.
  26828. */
  26829. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26830. /**
  26831. * Sets this transform node rotation to the given local axis.
  26832. * @param localAxis the axis in local space
  26833. * @param yawCor optional yaw (y-axis) correction in radians
  26834. * @param pitchCor optional pitch (x-axis) correction in radians
  26835. * @param rollCor optional roll (z-axis) correction in radians
  26836. * @returns this TransformNode
  26837. */
  26838. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26839. /**
  26840. * Sets a new pivot point to the current node
  26841. * @param point defines the new pivot point to use
  26842. * @param space defines if the point is in world or local space (local by default)
  26843. * @returns the current TransformNode
  26844. */
  26845. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26846. /**
  26847. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26848. * @returns the pivot point
  26849. */
  26850. getPivotPoint(): Vector3;
  26851. /**
  26852. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26853. * @param result the vector3 to store the result
  26854. * @returns this TransformNode.
  26855. */
  26856. getPivotPointToRef(result: Vector3): TransformNode;
  26857. /**
  26858. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26859. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26860. */
  26861. getAbsolutePivotPoint(): Vector3;
  26862. /**
  26863. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26864. * @param result vector3 to store the result
  26865. * @returns this TransformNode.
  26866. */
  26867. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26868. /**
  26869. * Defines the passed node as the parent of the current node.
  26870. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26871. * @see https://doc.babylonjs.com/how_to/parenting
  26872. * @param node the node ot set as the parent
  26873. * @returns this TransformNode.
  26874. */
  26875. setParent(node: Nullable<Node>): TransformNode;
  26876. private _nonUniformScaling;
  26877. /**
  26878. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26879. */
  26880. get nonUniformScaling(): boolean;
  26881. /** @hidden */
  26882. _updateNonUniformScalingState(value: boolean): boolean;
  26883. /**
  26884. * Attach the current TransformNode to another TransformNode associated with a bone
  26885. * @param bone Bone affecting the TransformNode
  26886. * @param affectedTransformNode TransformNode associated with the bone
  26887. * @returns this object
  26888. */
  26889. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26890. /**
  26891. * Detach the transform node if its associated with a bone
  26892. * @returns this object
  26893. */
  26894. detachFromBone(): TransformNode;
  26895. private static _rotationAxisCache;
  26896. /**
  26897. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26898. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26899. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26900. * The passed axis is also normalized.
  26901. * @param axis the axis to rotate around
  26902. * @param amount the amount to rotate in radians
  26903. * @param space Space to rotate in (Default: local)
  26904. * @returns the TransformNode.
  26905. */
  26906. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26907. /**
  26908. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26909. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26910. * The passed axis is also normalized. .
  26911. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26912. * @param point the point to rotate around
  26913. * @param axis the axis to rotate around
  26914. * @param amount the amount to rotate in radians
  26915. * @returns the TransformNode
  26916. */
  26917. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26918. /**
  26919. * Translates the mesh along the axis vector for the passed distance in the given space.
  26920. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26921. * @param axis the axis to translate in
  26922. * @param distance the distance to translate
  26923. * @param space Space to rotate in (Default: local)
  26924. * @returns the TransformNode.
  26925. */
  26926. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26927. /**
  26928. * Adds a rotation step to the mesh current rotation.
  26929. * x, y, z are Euler angles expressed in radians.
  26930. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26931. * This means this rotation is made in the mesh local space only.
  26932. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26933. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26934. * ```javascript
  26935. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26936. * ```
  26937. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26938. * 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.
  26939. * @param x Rotation to add
  26940. * @param y Rotation to add
  26941. * @param z Rotation to add
  26942. * @returns the TransformNode.
  26943. */
  26944. addRotation(x: number, y: number, z: number): TransformNode;
  26945. /**
  26946. * @hidden
  26947. */
  26948. protected _getEffectiveParent(): Nullable<Node>;
  26949. /**
  26950. * Computes the world matrix of the node
  26951. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26952. * @returns the world matrix
  26953. */
  26954. computeWorldMatrix(force?: boolean): Matrix;
  26955. /**
  26956. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26957. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26958. */
  26959. resetLocalMatrix(independentOfChildren?: boolean): void;
  26960. protected _afterComputeWorldMatrix(): void;
  26961. /**
  26962. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26963. * @param func callback function to add
  26964. *
  26965. * @returns the TransformNode.
  26966. */
  26967. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26968. /**
  26969. * Removes a registered callback function.
  26970. * @param func callback function to remove
  26971. * @returns the TransformNode.
  26972. */
  26973. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26974. /**
  26975. * Gets the position of the current mesh in camera space
  26976. * @param camera defines the camera to use
  26977. * @returns a position
  26978. */
  26979. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26980. /**
  26981. * Returns the distance from the mesh to the active camera
  26982. * @param camera defines the camera to use
  26983. * @returns the distance
  26984. */
  26985. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26986. /**
  26987. * Clone the current transform node
  26988. * @param name Name of the new clone
  26989. * @param newParent New parent for the clone
  26990. * @param doNotCloneChildren Do not clone children hierarchy
  26991. * @returns the new transform node
  26992. */
  26993. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26994. /**
  26995. * Serializes the objects information.
  26996. * @param currentSerializationObject defines the object to serialize in
  26997. * @returns the serialized object
  26998. */
  26999. serialize(currentSerializationObject?: any): any;
  27000. /**
  27001. * Returns a new TransformNode object parsed from the source provided.
  27002. * @param parsedTransformNode is the source.
  27003. * @param scene the scne the object belongs to
  27004. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27005. * @returns a new TransformNode object parsed from the source provided.
  27006. */
  27007. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27008. /**
  27009. * Get all child-transformNodes of this node
  27010. * @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
  27011. * @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
  27012. * @returns an array of TransformNode
  27013. */
  27014. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27015. /**
  27016. * Releases resources associated with this transform node.
  27017. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27018. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27019. */
  27020. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27021. /**
  27022. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27023. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27024. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27025. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27026. * @returns the current mesh
  27027. */
  27028. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27029. private _syncAbsoluteScalingAndRotation;
  27030. }
  27031. }
  27032. declare module BABYLON {
  27033. /**
  27034. * Defines the types of pose enabled controllers that are supported
  27035. */
  27036. export enum PoseEnabledControllerType {
  27037. /**
  27038. * HTC Vive
  27039. */
  27040. VIVE = 0,
  27041. /**
  27042. * Oculus Rift
  27043. */
  27044. OCULUS = 1,
  27045. /**
  27046. * Windows mixed reality
  27047. */
  27048. WINDOWS = 2,
  27049. /**
  27050. * Samsung gear VR
  27051. */
  27052. GEAR_VR = 3,
  27053. /**
  27054. * Google Daydream
  27055. */
  27056. DAYDREAM = 4,
  27057. /**
  27058. * Generic
  27059. */
  27060. GENERIC = 5
  27061. }
  27062. /**
  27063. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27064. */
  27065. export interface MutableGamepadButton {
  27066. /**
  27067. * Value of the button/trigger
  27068. */
  27069. value: number;
  27070. /**
  27071. * If the button/trigger is currently touched
  27072. */
  27073. touched: boolean;
  27074. /**
  27075. * If the button/trigger is currently pressed
  27076. */
  27077. pressed: boolean;
  27078. }
  27079. /**
  27080. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27081. * @hidden
  27082. */
  27083. export interface ExtendedGamepadButton extends GamepadButton {
  27084. /**
  27085. * If the button/trigger is currently pressed
  27086. */
  27087. readonly pressed: boolean;
  27088. /**
  27089. * If the button/trigger is currently touched
  27090. */
  27091. readonly touched: boolean;
  27092. /**
  27093. * Value of the button/trigger
  27094. */
  27095. readonly value: number;
  27096. }
  27097. /** @hidden */
  27098. export interface _GamePadFactory {
  27099. /**
  27100. * Returns whether or not the current gamepad can be created for this type of controller.
  27101. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27102. * @returns true if it can be created, otherwise false
  27103. */
  27104. canCreate(gamepadInfo: any): boolean;
  27105. /**
  27106. * Creates a new instance of the Gamepad.
  27107. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27108. * @returns the new gamepad instance
  27109. */
  27110. create(gamepadInfo: any): Gamepad;
  27111. }
  27112. /**
  27113. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27114. */
  27115. export class PoseEnabledControllerHelper {
  27116. /** @hidden */
  27117. static _ControllerFactories: _GamePadFactory[];
  27118. /** @hidden */
  27119. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27120. /**
  27121. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27122. * @param vrGamepad the gamepad to initialized
  27123. * @returns a vr controller of the type the gamepad identified as
  27124. */
  27125. static InitiateController(vrGamepad: any): Gamepad;
  27126. }
  27127. /**
  27128. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27129. */
  27130. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27131. /**
  27132. * If the controller is used in a webXR session
  27133. */
  27134. isXR: boolean;
  27135. private _deviceRoomPosition;
  27136. private _deviceRoomRotationQuaternion;
  27137. /**
  27138. * The device position in babylon space
  27139. */
  27140. devicePosition: Vector3;
  27141. /**
  27142. * The device rotation in babylon space
  27143. */
  27144. deviceRotationQuaternion: Quaternion;
  27145. /**
  27146. * The scale factor of the device in babylon space
  27147. */
  27148. deviceScaleFactor: number;
  27149. /**
  27150. * (Likely devicePosition should be used instead) The device position in its room space
  27151. */
  27152. position: Vector3;
  27153. /**
  27154. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27155. */
  27156. rotationQuaternion: Quaternion;
  27157. /**
  27158. * The type of controller (Eg. Windows mixed reality)
  27159. */
  27160. controllerType: PoseEnabledControllerType;
  27161. protected _calculatedPosition: Vector3;
  27162. private _calculatedRotation;
  27163. /**
  27164. * The raw pose from the device
  27165. */
  27166. rawPose: DevicePose;
  27167. private _trackPosition;
  27168. private _maxRotationDistFromHeadset;
  27169. private _draggedRoomRotation;
  27170. /**
  27171. * @hidden
  27172. */
  27173. _disableTrackPosition(fixedPosition: Vector3): void;
  27174. /**
  27175. * Internal, the mesh attached to the controller
  27176. * @hidden
  27177. */
  27178. _mesh: Nullable<AbstractMesh>;
  27179. private _poseControlledCamera;
  27180. private _leftHandSystemQuaternion;
  27181. /**
  27182. * Internal, matrix used to convert room space to babylon space
  27183. * @hidden
  27184. */
  27185. _deviceToWorld: Matrix;
  27186. /**
  27187. * Node to be used when casting a ray from the controller
  27188. * @hidden
  27189. */
  27190. _pointingPoseNode: Nullable<TransformNode>;
  27191. /**
  27192. * Name of the child mesh that can be used to cast a ray from the controller
  27193. */
  27194. static readonly POINTING_POSE: string;
  27195. /**
  27196. * Creates a new PoseEnabledController from a gamepad
  27197. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27198. */
  27199. constructor(browserGamepad: any);
  27200. private _workingMatrix;
  27201. /**
  27202. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27203. */
  27204. update(): void;
  27205. /**
  27206. * Updates only the pose device and mesh without doing any button event checking
  27207. */
  27208. protected _updatePoseAndMesh(): void;
  27209. /**
  27210. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27211. * @param poseData raw pose fromthe device
  27212. */
  27213. updateFromDevice(poseData: DevicePose): void;
  27214. /**
  27215. * @hidden
  27216. */
  27217. _meshAttachedObservable: Observable<AbstractMesh>;
  27218. /**
  27219. * Attaches a mesh to the controller
  27220. * @param mesh the mesh to be attached
  27221. */
  27222. attachToMesh(mesh: AbstractMesh): void;
  27223. /**
  27224. * Attaches the controllers mesh to a camera
  27225. * @param camera the camera the mesh should be attached to
  27226. */
  27227. attachToPoseControlledCamera(camera: TargetCamera): void;
  27228. /**
  27229. * Disposes of the controller
  27230. */
  27231. dispose(): void;
  27232. /**
  27233. * The mesh that is attached to the controller
  27234. */
  27235. get mesh(): Nullable<AbstractMesh>;
  27236. /**
  27237. * Gets the ray of the controller in the direction the controller is pointing
  27238. * @param length the length the resulting ray should be
  27239. * @returns a ray in the direction the controller is pointing
  27240. */
  27241. getForwardRay(length?: number): Ray;
  27242. }
  27243. }
  27244. declare module BABYLON {
  27245. /**
  27246. * Defines the WebVRController object that represents controllers tracked in 3D space
  27247. */
  27248. export abstract class WebVRController extends PoseEnabledController {
  27249. /**
  27250. * Internal, the default controller model for the controller
  27251. */
  27252. protected _defaultModel: Nullable<AbstractMesh>;
  27253. /**
  27254. * Fired when the trigger state has changed
  27255. */
  27256. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27257. /**
  27258. * Fired when the main button state has changed
  27259. */
  27260. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27261. /**
  27262. * Fired when the secondary button state has changed
  27263. */
  27264. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27265. /**
  27266. * Fired when the pad state has changed
  27267. */
  27268. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27269. /**
  27270. * Fired when controllers stick values have changed
  27271. */
  27272. onPadValuesChangedObservable: Observable<StickValues>;
  27273. /**
  27274. * Array of button availible on the controller
  27275. */
  27276. protected _buttons: Array<MutableGamepadButton>;
  27277. private _onButtonStateChange;
  27278. /**
  27279. * Fired when a controller button's state has changed
  27280. * @param callback the callback containing the button that was modified
  27281. */
  27282. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27283. /**
  27284. * X and Y axis corresponding to the controllers joystick
  27285. */
  27286. pad: StickValues;
  27287. /**
  27288. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27289. */
  27290. hand: string;
  27291. /**
  27292. * The default controller model for the controller
  27293. */
  27294. get defaultModel(): Nullable<AbstractMesh>;
  27295. /**
  27296. * Creates a new WebVRController from a gamepad
  27297. * @param vrGamepad the gamepad that the WebVRController should be created from
  27298. */
  27299. constructor(vrGamepad: any);
  27300. /**
  27301. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27302. */
  27303. update(): void;
  27304. /**
  27305. * Function to be called when a button is modified
  27306. */
  27307. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27308. /**
  27309. * Loads a mesh and attaches it to the controller
  27310. * @param scene the scene the mesh should be added to
  27311. * @param meshLoaded callback for when the mesh has been loaded
  27312. */
  27313. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27314. private _setButtonValue;
  27315. private _changes;
  27316. private _checkChanges;
  27317. /**
  27318. * Disposes of th webVRCOntroller
  27319. */
  27320. dispose(): void;
  27321. }
  27322. }
  27323. declare module BABYLON {
  27324. /**
  27325. * The HemisphericLight simulates the ambient environment light,
  27326. * so the passed direction is the light reflection direction, not the incoming direction.
  27327. */
  27328. export class HemisphericLight extends Light {
  27329. /**
  27330. * The groundColor is the light in the opposite direction to the one specified during creation.
  27331. * 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.
  27332. */
  27333. groundColor: Color3;
  27334. /**
  27335. * The light reflection direction, not the incoming direction.
  27336. */
  27337. direction: Vector3;
  27338. /**
  27339. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27340. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27341. * The HemisphericLight can't cast shadows.
  27342. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27343. * @param name The friendly name of the light
  27344. * @param direction The direction of the light reflection
  27345. * @param scene The scene the light belongs to
  27346. */
  27347. constructor(name: string, direction: Vector3, scene: Scene);
  27348. protected _buildUniformLayout(): void;
  27349. /**
  27350. * Returns the string "HemisphericLight".
  27351. * @return The class name
  27352. */
  27353. getClassName(): string;
  27354. /**
  27355. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27356. * Returns the updated direction.
  27357. * @param target The target the direction should point to
  27358. * @return The computed direction
  27359. */
  27360. setDirectionToTarget(target: Vector3): Vector3;
  27361. /**
  27362. * Returns the shadow generator associated to the light.
  27363. * @returns Always null for hemispheric lights because it does not support shadows.
  27364. */
  27365. getShadowGenerator(): Nullable<IShadowGenerator>;
  27366. /**
  27367. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27368. * @param effect The effect to update
  27369. * @param lightIndex The index of the light in the effect to update
  27370. * @returns The hemispheric light
  27371. */
  27372. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27373. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27374. /**
  27375. * Computes the world matrix of the node
  27376. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27377. * @param useWasUpdatedFlag defines a reserved property
  27378. * @returns the world matrix
  27379. */
  27380. computeWorldMatrix(): Matrix;
  27381. /**
  27382. * Returns the integer 3.
  27383. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27384. */
  27385. getTypeID(): number;
  27386. /**
  27387. * Prepares the list of defines specific to the light type.
  27388. * @param defines the list of defines
  27389. * @param lightIndex defines the index of the light for the effect
  27390. */
  27391. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27392. }
  27393. }
  27394. declare module BABYLON {
  27395. /** @hidden */
  27396. export var vrMultiviewToSingleviewPixelShader: {
  27397. name: string;
  27398. shader: string;
  27399. };
  27400. }
  27401. declare module BABYLON {
  27402. /**
  27403. * Renders to multiple views with a single draw call
  27404. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27405. */
  27406. export class MultiviewRenderTarget extends RenderTargetTexture {
  27407. /**
  27408. * Creates a multiview render target
  27409. * @param scene scene used with the render target
  27410. * @param size the size of the render target (used for each view)
  27411. */
  27412. constructor(scene: Scene, size?: number | {
  27413. width: number;
  27414. height: number;
  27415. } | {
  27416. ratio: number;
  27417. });
  27418. /**
  27419. * @hidden
  27420. * @param faceIndex the face index, if its a cube texture
  27421. */
  27422. _bindFrameBuffer(faceIndex?: number): void;
  27423. /**
  27424. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27425. * @returns the view count
  27426. */
  27427. getViewCount(): number;
  27428. }
  27429. }
  27430. declare module BABYLON {
  27431. interface Engine {
  27432. /**
  27433. * Creates a new multiview render target
  27434. * @param width defines the width of the texture
  27435. * @param height defines the height of the texture
  27436. * @returns the created multiview texture
  27437. */
  27438. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27439. /**
  27440. * Binds a multiview framebuffer to be drawn to
  27441. * @param multiviewTexture texture to bind
  27442. */
  27443. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27444. }
  27445. interface Camera {
  27446. /**
  27447. * @hidden
  27448. * 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)
  27449. */
  27450. _useMultiviewToSingleView: boolean;
  27451. /**
  27452. * @hidden
  27453. * 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)
  27454. */
  27455. _multiviewTexture: Nullable<RenderTargetTexture>;
  27456. /**
  27457. * @hidden
  27458. * ensures the multiview texture of the camera exists and has the specified width/height
  27459. * @param width height to set on the multiview texture
  27460. * @param height width to set on the multiview texture
  27461. */
  27462. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27463. }
  27464. interface Scene {
  27465. /** @hidden */
  27466. _transformMatrixR: Matrix;
  27467. /** @hidden */
  27468. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27469. /** @hidden */
  27470. _createMultiviewUbo(): void;
  27471. /** @hidden */
  27472. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27473. /** @hidden */
  27474. _renderMultiviewToSingleView(camera: Camera): void;
  27475. }
  27476. }
  27477. declare module BABYLON {
  27478. /**
  27479. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27480. * This will not be used for webXR as it supports displaying texture arrays directly
  27481. */
  27482. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27483. /**
  27484. * Gets a string identifying the name of the class
  27485. * @returns "VRMultiviewToSingleviewPostProcess" string
  27486. */
  27487. getClassName(): string;
  27488. /**
  27489. * Initializes a VRMultiviewToSingleview
  27490. * @param name name of the post process
  27491. * @param camera camera to be applied to
  27492. * @param scaleFactor scaling factor to the size of the output texture
  27493. */
  27494. constructor(name: string, camera: Camera, scaleFactor: number);
  27495. }
  27496. }
  27497. declare module BABYLON {
  27498. /**
  27499. * Interface used to define additional presentation attributes
  27500. */
  27501. export interface IVRPresentationAttributes {
  27502. /**
  27503. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27504. */
  27505. highRefreshRate: boolean;
  27506. /**
  27507. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27508. */
  27509. foveationLevel: number;
  27510. }
  27511. interface Engine {
  27512. /** @hidden */
  27513. _vrDisplay: any;
  27514. /** @hidden */
  27515. _vrSupported: boolean;
  27516. /** @hidden */
  27517. _oldSize: Size;
  27518. /** @hidden */
  27519. _oldHardwareScaleFactor: number;
  27520. /** @hidden */
  27521. _vrExclusivePointerMode: boolean;
  27522. /** @hidden */
  27523. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27524. /** @hidden */
  27525. _onVRDisplayPointerRestricted: () => void;
  27526. /** @hidden */
  27527. _onVRDisplayPointerUnrestricted: () => void;
  27528. /** @hidden */
  27529. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27530. /** @hidden */
  27531. _onVrDisplayDisconnect: Nullable<() => void>;
  27532. /** @hidden */
  27533. _onVrDisplayPresentChange: Nullable<() => void>;
  27534. /**
  27535. * Observable signaled when VR display mode changes
  27536. */
  27537. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27538. /**
  27539. * Observable signaled when VR request present is complete
  27540. */
  27541. onVRRequestPresentComplete: Observable<boolean>;
  27542. /**
  27543. * Observable signaled when VR request present starts
  27544. */
  27545. onVRRequestPresentStart: Observable<Engine>;
  27546. /**
  27547. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27548. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27549. */
  27550. isInVRExclusivePointerMode: boolean;
  27551. /**
  27552. * Gets a boolean indicating if a webVR device was detected
  27553. * @returns true if a webVR device was detected
  27554. */
  27555. isVRDevicePresent(): boolean;
  27556. /**
  27557. * Gets the current webVR device
  27558. * @returns the current webVR device (or null)
  27559. */
  27560. getVRDevice(): any;
  27561. /**
  27562. * Initializes a webVR display and starts listening to display change events
  27563. * The onVRDisplayChangedObservable will be notified upon these changes
  27564. * @returns A promise containing a VRDisplay and if vr is supported
  27565. */
  27566. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27567. /** @hidden */
  27568. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27569. /**
  27570. * Gets or sets the presentation attributes used to configure VR rendering
  27571. */
  27572. vrPresentationAttributes?: IVRPresentationAttributes;
  27573. /**
  27574. * Call this function to switch to webVR mode
  27575. * Will do nothing if webVR is not supported or if there is no webVR device
  27576. * @param options the webvr options provided to the camera. mainly used for multiview
  27577. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27578. */
  27579. enableVR(options: WebVROptions): void;
  27580. /** @hidden */
  27581. _onVRFullScreenTriggered(): void;
  27582. }
  27583. }
  27584. declare module BABYLON {
  27585. /**
  27586. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27587. * IMPORTANT!! The data is right-hand data.
  27588. * @export
  27589. * @interface DevicePose
  27590. */
  27591. export interface DevicePose {
  27592. /**
  27593. * The position of the device, values in array are [x,y,z].
  27594. */
  27595. readonly position: Nullable<Float32Array>;
  27596. /**
  27597. * The linearVelocity of the device, values in array are [x,y,z].
  27598. */
  27599. readonly linearVelocity: Nullable<Float32Array>;
  27600. /**
  27601. * The linearAcceleration of the device, values in array are [x,y,z].
  27602. */
  27603. readonly linearAcceleration: Nullable<Float32Array>;
  27604. /**
  27605. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27606. */
  27607. readonly orientation: Nullable<Float32Array>;
  27608. /**
  27609. * The angularVelocity of the device, values in array are [x,y,z].
  27610. */
  27611. readonly angularVelocity: Nullable<Float32Array>;
  27612. /**
  27613. * The angularAcceleration of the device, values in array are [x,y,z].
  27614. */
  27615. readonly angularAcceleration: Nullable<Float32Array>;
  27616. }
  27617. /**
  27618. * Interface representing a pose controlled object in Babylon.
  27619. * A pose controlled object has both regular pose values as well as pose values
  27620. * from an external device such as a VR head mounted display
  27621. */
  27622. export interface PoseControlled {
  27623. /**
  27624. * The position of the object in babylon space.
  27625. */
  27626. position: Vector3;
  27627. /**
  27628. * The rotation quaternion of the object in babylon space.
  27629. */
  27630. rotationQuaternion: Quaternion;
  27631. /**
  27632. * The position of the device in babylon space.
  27633. */
  27634. devicePosition?: Vector3;
  27635. /**
  27636. * The rotation quaternion of the device in babylon space.
  27637. */
  27638. deviceRotationQuaternion: Quaternion;
  27639. /**
  27640. * The raw pose coming from the device.
  27641. */
  27642. rawPose: Nullable<DevicePose>;
  27643. /**
  27644. * The scale of the device to be used when translating from device space to babylon space.
  27645. */
  27646. deviceScaleFactor: number;
  27647. /**
  27648. * Updates the poseControlled values based on the input device pose.
  27649. * @param poseData the pose data to update the object with
  27650. */
  27651. updateFromDevice(poseData: DevicePose): void;
  27652. }
  27653. /**
  27654. * Set of options to customize the webVRCamera
  27655. */
  27656. export interface WebVROptions {
  27657. /**
  27658. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27659. */
  27660. trackPosition?: boolean;
  27661. /**
  27662. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27663. */
  27664. positionScale?: number;
  27665. /**
  27666. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27667. */
  27668. displayName?: string;
  27669. /**
  27670. * Should the native controller meshes be initialized. (default: true)
  27671. */
  27672. controllerMeshes?: boolean;
  27673. /**
  27674. * Creating a default HemiLight only on controllers. (default: true)
  27675. */
  27676. defaultLightingOnControllers?: boolean;
  27677. /**
  27678. * If you don't want to use the default VR button of the helper. (default: false)
  27679. */
  27680. useCustomVRButton?: boolean;
  27681. /**
  27682. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27683. */
  27684. customVRButton?: HTMLButtonElement;
  27685. /**
  27686. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27687. */
  27688. rayLength?: number;
  27689. /**
  27690. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27691. */
  27692. defaultHeight?: number;
  27693. /**
  27694. * If multiview should be used if availible (default: false)
  27695. */
  27696. useMultiview?: boolean;
  27697. }
  27698. /**
  27699. * This represents a WebVR camera.
  27700. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27701. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27702. */
  27703. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27704. private webVROptions;
  27705. /**
  27706. * @hidden
  27707. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27708. */
  27709. _vrDevice: any;
  27710. /**
  27711. * The rawPose of the vrDevice.
  27712. */
  27713. rawPose: Nullable<DevicePose>;
  27714. private _onVREnabled;
  27715. private _specsVersion;
  27716. private _attached;
  27717. private _frameData;
  27718. protected _descendants: Array<Node>;
  27719. private _deviceRoomPosition;
  27720. /** @hidden */
  27721. _deviceRoomRotationQuaternion: Quaternion;
  27722. private _standingMatrix;
  27723. /**
  27724. * Represents device position in babylon space.
  27725. */
  27726. devicePosition: Vector3;
  27727. /**
  27728. * Represents device rotation in babylon space.
  27729. */
  27730. deviceRotationQuaternion: Quaternion;
  27731. /**
  27732. * The scale of the device to be used when translating from device space to babylon space.
  27733. */
  27734. deviceScaleFactor: number;
  27735. private _deviceToWorld;
  27736. private _worldToDevice;
  27737. /**
  27738. * References to the webVR controllers for the vrDevice.
  27739. */
  27740. controllers: Array<WebVRController>;
  27741. /**
  27742. * Emits an event when a controller is attached.
  27743. */
  27744. onControllersAttachedObservable: Observable<WebVRController[]>;
  27745. /**
  27746. * Emits an event when a controller's mesh has been loaded;
  27747. */
  27748. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27749. /**
  27750. * Emits an event when the HMD's pose has been updated.
  27751. */
  27752. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27753. private _poseSet;
  27754. /**
  27755. * If the rig cameras be used as parent instead of this camera.
  27756. */
  27757. rigParenting: boolean;
  27758. private _lightOnControllers;
  27759. private _defaultHeight?;
  27760. /**
  27761. * Instantiates a WebVRFreeCamera.
  27762. * @param name The name of the WebVRFreeCamera
  27763. * @param position The starting anchor position for the camera
  27764. * @param scene The scene the camera belongs to
  27765. * @param webVROptions a set of customizable options for the webVRCamera
  27766. */
  27767. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27768. /**
  27769. * Gets the device distance from the ground in meters.
  27770. * @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.
  27771. */
  27772. deviceDistanceToRoomGround(): number;
  27773. /**
  27774. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27775. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27776. */
  27777. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27778. /**
  27779. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27780. * @returns A promise with a boolean set to if the standing matrix is supported.
  27781. */
  27782. useStandingMatrixAsync(): Promise<boolean>;
  27783. /**
  27784. * Disposes the camera
  27785. */
  27786. dispose(): void;
  27787. /**
  27788. * Gets a vrController by name.
  27789. * @param name The name of the controller to retreive
  27790. * @returns the controller matching the name specified or null if not found
  27791. */
  27792. getControllerByName(name: string): Nullable<WebVRController>;
  27793. private _leftController;
  27794. /**
  27795. * The controller corresponding to the users left hand.
  27796. */
  27797. get leftController(): Nullable<WebVRController>;
  27798. private _rightController;
  27799. /**
  27800. * The controller corresponding to the users right hand.
  27801. */
  27802. get rightController(): Nullable<WebVRController>;
  27803. /**
  27804. * Casts a ray forward from the vrCamera's gaze.
  27805. * @param length Length of the ray (default: 100)
  27806. * @returns the ray corresponding to the gaze
  27807. */
  27808. getForwardRay(length?: number): Ray;
  27809. /**
  27810. * @hidden
  27811. * Updates the camera based on device's frame data
  27812. */
  27813. _checkInputs(): void;
  27814. /**
  27815. * Updates the poseControlled values based on the input device pose.
  27816. * @param poseData Pose coming from the device
  27817. */
  27818. updateFromDevice(poseData: DevicePose): void;
  27819. private _detachIfAttached;
  27820. /**
  27821. * WebVR's attach control will start broadcasting frames to the device.
  27822. * Note that in certain browsers (chrome for example) this function must be called
  27823. * within a user-interaction callback. Example:
  27824. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27825. *
  27826. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27827. */
  27828. attachControl(noPreventDefault?: boolean): void;
  27829. /**
  27830. * Detach the current controls from the specified dom element.
  27831. */
  27832. detachControl(): void;
  27833. /**
  27834. * @returns the name of this class
  27835. */
  27836. getClassName(): string;
  27837. /**
  27838. * Calls resetPose on the vrDisplay
  27839. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27840. */
  27841. resetToCurrentRotation(): void;
  27842. /**
  27843. * @hidden
  27844. * Updates the rig cameras (left and right eye)
  27845. */
  27846. _updateRigCameras(): void;
  27847. private _workingVector;
  27848. private _oneVector;
  27849. private _workingMatrix;
  27850. private updateCacheCalled;
  27851. private _correctPositionIfNotTrackPosition;
  27852. /**
  27853. * @hidden
  27854. * Updates the cached values of the camera
  27855. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27856. */
  27857. _updateCache(ignoreParentClass?: boolean): void;
  27858. /**
  27859. * @hidden
  27860. * Get current device position in babylon world
  27861. */
  27862. _computeDevicePosition(): void;
  27863. /**
  27864. * Updates the current device position and rotation in the babylon world
  27865. */
  27866. update(): void;
  27867. /**
  27868. * @hidden
  27869. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27870. * @returns an identity matrix
  27871. */
  27872. _getViewMatrix(): Matrix;
  27873. private _tmpMatrix;
  27874. /**
  27875. * This function is called by the two RIG cameras.
  27876. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27877. * @hidden
  27878. */
  27879. _getWebVRViewMatrix(): Matrix;
  27880. /** @hidden */
  27881. _getWebVRProjectionMatrix(): Matrix;
  27882. private _onGamepadConnectedObserver;
  27883. private _onGamepadDisconnectedObserver;
  27884. private _updateCacheWhenTrackingDisabledObserver;
  27885. /**
  27886. * Initializes the controllers and their meshes
  27887. */
  27888. initControllers(): void;
  27889. }
  27890. }
  27891. declare module BABYLON {
  27892. /**
  27893. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27894. *
  27895. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27896. *
  27897. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27898. */
  27899. export class MaterialHelper {
  27900. /**
  27901. * Bind the current view position to an effect.
  27902. * @param effect The effect to be bound
  27903. * @param scene The scene the eyes position is used from
  27904. * @param variableName name of the shader variable that will hold the eye position
  27905. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27906. * @return the computed eye position
  27907. */
  27908. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27909. /**
  27910. * Helps preparing the defines values about the UVs in used in the effect.
  27911. * UVs are shared as much as we can accross channels in the shaders.
  27912. * @param texture The texture we are preparing the UVs for
  27913. * @param defines The defines to update
  27914. * @param key The channel key "diffuse", "specular"... used in the shader
  27915. */
  27916. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27917. /**
  27918. * Binds a texture matrix value to its corrsponding uniform
  27919. * @param texture The texture to bind the matrix for
  27920. * @param uniformBuffer The uniform buffer receivin the data
  27921. * @param key The channel key "diffuse", "specular"... used in the shader
  27922. */
  27923. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27924. /**
  27925. * Gets the current status of the fog (should it be enabled?)
  27926. * @param mesh defines the mesh to evaluate for fog support
  27927. * @param scene defines the hosting scene
  27928. * @returns true if fog must be enabled
  27929. */
  27930. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27931. /**
  27932. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27933. * @param mesh defines the current mesh
  27934. * @param scene defines the current scene
  27935. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27936. * @param pointsCloud defines if point cloud rendering has to be turned on
  27937. * @param fogEnabled defines if fog has to be turned on
  27938. * @param alphaTest defines if alpha testing has to be turned on
  27939. * @param defines defines the current list of defines
  27940. */
  27941. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27942. /**
  27943. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27944. * @param scene defines the current scene
  27945. * @param engine defines the current engine
  27946. * @param defines specifies the list of active defines
  27947. * @param useInstances defines if instances have to be turned on
  27948. * @param useClipPlane defines if clip plane have to be turned on
  27949. * @param useInstances defines if instances have to be turned on
  27950. * @param useThinInstances defines if thin instances have to be turned on
  27951. */
  27952. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27953. /**
  27954. * Prepares the defines for bones
  27955. * @param mesh The mesh containing the geometry data we will draw
  27956. * @param defines The defines to update
  27957. */
  27958. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27959. /**
  27960. * Prepares the defines for morph targets
  27961. * @param mesh The mesh containing the geometry data we will draw
  27962. * @param defines The defines to update
  27963. */
  27964. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27965. /**
  27966. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27967. * @param mesh The mesh containing the geometry data we will draw
  27968. * @param defines The defines to update
  27969. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27970. * @param useBones Precise whether bones should be used or not (override mesh info)
  27971. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27972. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27973. * @returns false if defines are considered not dirty and have not been checked
  27974. */
  27975. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27976. /**
  27977. * Prepares the defines related to multiview
  27978. * @param scene The scene we are intending to draw
  27979. * @param defines The defines to update
  27980. */
  27981. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27982. /**
  27983. * Prepares the defines related to the prepass
  27984. * @param scene The scene we are intending to draw
  27985. * @param defines The defines to update
  27986. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27987. */
  27988. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27989. /**
  27990. * Prepares the defines related to the light information passed in parameter
  27991. * @param scene The scene we are intending to draw
  27992. * @param mesh The mesh the effect is compiling for
  27993. * @param light The light the effect is compiling for
  27994. * @param lightIndex The index of the light
  27995. * @param defines The defines to update
  27996. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27997. * @param state Defines the current state regarding what is needed (normals, etc...)
  27998. */
  27999. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28000. needNormals: boolean;
  28001. needRebuild: boolean;
  28002. shadowEnabled: boolean;
  28003. specularEnabled: boolean;
  28004. lightmapMode: boolean;
  28005. }): void;
  28006. /**
  28007. * Prepares the defines related to the light information passed in parameter
  28008. * @param scene The scene we are intending to draw
  28009. * @param mesh The mesh the effect is compiling for
  28010. * @param defines The defines to update
  28011. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28012. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28013. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28014. * @returns true if normals will be required for the rest of the effect
  28015. */
  28016. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28017. /**
  28018. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28019. * @param lightIndex defines the light index
  28020. * @param uniformsList The uniform list
  28021. * @param samplersList The sampler list
  28022. * @param projectedLightTexture defines if projected texture must be used
  28023. * @param uniformBuffersList defines an optional list of uniform buffers
  28024. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28025. */
  28026. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28027. /**
  28028. * Prepares the uniforms and samplers list to be used in the effect
  28029. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28030. * @param samplersList The sampler list
  28031. * @param defines The defines helping in the list generation
  28032. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28033. */
  28034. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28035. /**
  28036. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28037. * @param defines The defines to update while falling back
  28038. * @param fallbacks The authorized effect fallbacks
  28039. * @param maxSimultaneousLights The maximum number of lights allowed
  28040. * @param rank the current rank of the Effect
  28041. * @returns The newly affected rank
  28042. */
  28043. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28044. private static _TmpMorphInfluencers;
  28045. /**
  28046. * Prepares the list of attributes required for morph targets according to the effect defines.
  28047. * @param attribs The current list of supported attribs
  28048. * @param mesh The mesh to prepare the morph targets attributes for
  28049. * @param influencers The number of influencers
  28050. */
  28051. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28052. /**
  28053. * Prepares the list of attributes required for morph targets according to the effect defines.
  28054. * @param attribs The current list of supported attribs
  28055. * @param mesh The mesh to prepare the morph targets attributes for
  28056. * @param defines The current Defines of the effect
  28057. */
  28058. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28059. /**
  28060. * Prepares the list of attributes required for bones according to the effect defines.
  28061. * @param attribs The current list of supported attribs
  28062. * @param mesh The mesh to prepare the bones attributes for
  28063. * @param defines The current Defines of the effect
  28064. * @param fallbacks The current efffect fallback strategy
  28065. */
  28066. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28067. /**
  28068. * Check and prepare the list of attributes required for instances according to the effect defines.
  28069. * @param attribs The current list of supported attribs
  28070. * @param defines The current MaterialDefines of the effect
  28071. */
  28072. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28073. /**
  28074. * Add the list of attributes required for instances to the attribs array.
  28075. * @param attribs The current list of supported attribs
  28076. */
  28077. static PushAttributesForInstances(attribs: string[]): void;
  28078. /**
  28079. * Binds the light information to the effect.
  28080. * @param light The light containing the generator
  28081. * @param effect The effect we are binding the data to
  28082. * @param lightIndex The light index in the effect used to render
  28083. */
  28084. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28085. /**
  28086. * Binds the lights information from the scene to the effect for the given mesh.
  28087. * @param light Light to bind
  28088. * @param lightIndex Light index
  28089. * @param scene The scene where the light belongs to
  28090. * @param effect The effect we are binding the data to
  28091. * @param useSpecular Defines if specular is supported
  28092. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28093. */
  28094. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28095. /**
  28096. * Binds the lights information from the scene to the effect for the given mesh.
  28097. * @param scene The scene the lights belongs to
  28098. * @param mesh The mesh we are binding the information to render
  28099. * @param effect The effect we are binding the data to
  28100. * @param defines The generated defines for the effect
  28101. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28102. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28103. */
  28104. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28105. private static _tempFogColor;
  28106. /**
  28107. * Binds the fog information from the scene to the effect for the given mesh.
  28108. * @param scene The scene the lights belongs to
  28109. * @param mesh The mesh we are binding the information to render
  28110. * @param effect The effect we are binding the data to
  28111. * @param linearSpace Defines if the fog effect is applied in linear space
  28112. */
  28113. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28114. /**
  28115. * Binds the bones information from the mesh to the effect.
  28116. * @param mesh The mesh we are binding the information to render
  28117. * @param effect The effect we are binding the data to
  28118. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28119. */
  28120. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28121. private static _CopyBonesTransformationMatrices;
  28122. /**
  28123. * Binds the morph targets information from the mesh to the effect.
  28124. * @param abstractMesh The mesh we are binding the information to render
  28125. * @param effect The effect we are binding the data to
  28126. */
  28127. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28128. /**
  28129. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28130. * @param defines The generated defines used in the effect
  28131. * @param effect The effect we are binding the data to
  28132. * @param scene The scene we are willing to render with logarithmic scale for
  28133. */
  28134. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28135. /**
  28136. * Binds the clip plane information from the scene to the effect.
  28137. * @param scene The scene the clip plane information are extracted from
  28138. * @param effect The effect we are binding the data to
  28139. */
  28140. static BindClipPlane(effect: Effect, scene: Scene): void;
  28141. }
  28142. }
  28143. declare module BABYLON {
  28144. /** @hidden */
  28145. export var bayerDitherFunctions: {
  28146. name: string;
  28147. shader: string;
  28148. };
  28149. }
  28150. declare module BABYLON {
  28151. /** @hidden */
  28152. export var shadowMapFragmentDeclaration: {
  28153. name: string;
  28154. shader: string;
  28155. };
  28156. }
  28157. declare module BABYLON {
  28158. /** @hidden */
  28159. export var shadowMapFragment: {
  28160. name: string;
  28161. shader: string;
  28162. };
  28163. }
  28164. declare module BABYLON {
  28165. /** @hidden */
  28166. export var shadowMapPixelShader: {
  28167. name: string;
  28168. shader: string;
  28169. };
  28170. }
  28171. declare module BABYLON {
  28172. /** @hidden */
  28173. export var shadowMapVertexDeclaration: {
  28174. name: string;
  28175. shader: string;
  28176. };
  28177. }
  28178. declare module BABYLON {
  28179. /** @hidden */
  28180. export var shadowMapVertexNormalBias: {
  28181. name: string;
  28182. shader: string;
  28183. };
  28184. }
  28185. declare module BABYLON {
  28186. /** @hidden */
  28187. export var shadowMapVertexMetric: {
  28188. name: string;
  28189. shader: string;
  28190. };
  28191. }
  28192. declare module BABYLON {
  28193. /** @hidden */
  28194. export var shadowMapVertexShader: {
  28195. name: string;
  28196. shader: string;
  28197. };
  28198. }
  28199. declare module BABYLON {
  28200. /** @hidden */
  28201. export var depthBoxBlurPixelShader: {
  28202. name: string;
  28203. shader: string;
  28204. };
  28205. }
  28206. declare module BABYLON {
  28207. /** @hidden */
  28208. export var shadowMapFragmentSoftTransparentShadow: {
  28209. name: string;
  28210. shader: string;
  28211. };
  28212. }
  28213. declare module BABYLON {
  28214. /**
  28215. * Creates an instance based on a source mesh.
  28216. */
  28217. export class InstancedMesh extends AbstractMesh {
  28218. private _sourceMesh;
  28219. private _currentLOD;
  28220. /** @hidden */
  28221. _indexInSourceMeshInstanceArray: number;
  28222. constructor(name: string, source: Mesh);
  28223. /**
  28224. * Returns the string "InstancedMesh".
  28225. */
  28226. getClassName(): string;
  28227. /** Gets the list of lights affecting that mesh */
  28228. get lightSources(): Light[];
  28229. _resyncLightSources(): void;
  28230. _resyncLightSource(light: Light): void;
  28231. _removeLightSource(light: Light, dispose: boolean): void;
  28232. /**
  28233. * If the source mesh receives shadows
  28234. */
  28235. get receiveShadows(): boolean;
  28236. /**
  28237. * The material of the source mesh
  28238. */
  28239. get material(): Nullable<Material>;
  28240. /**
  28241. * Visibility of the source mesh
  28242. */
  28243. get visibility(): number;
  28244. /**
  28245. * Skeleton of the source mesh
  28246. */
  28247. get skeleton(): Nullable<Skeleton>;
  28248. /**
  28249. * Rendering ground id of the source mesh
  28250. */
  28251. get renderingGroupId(): number;
  28252. set renderingGroupId(value: number);
  28253. /**
  28254. * Returns the total number of vertices (integer).
  28255. */
  28256. getTotalVertices(): number;
  28257. /**
  28258. * Returns a positive integer : the total number of indices in this mesh geometry.
  28259. * @returns the numner of indices or zero if the mesh has no geometry.
  28260. */
  28261. getTotalIndices(): number;
  28262. /**
  28263. * The source mesh of the instance
  28264. */
  28265. get sourceMesh(): Mesh;
  28266. /**
  28267. * Creates a new InstancedMesh object from the mesh model.
  28268. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28269. * @param name defines the name of the new instance
  28270. * @returns a new InstancedMesh
  28271. */
  28272. createInstance(name: string): InstancedMesh;
  28273. /**
  28274. * Is this node ready to be used/rendered
  28275. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28276. * @return {boolean} is it ready
  28277. */
  28278. isReady(completeCheck?: boolean): boolean;
  28279. /**
  28280. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28281. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28282. * @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.
  28283. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28284. */
  28285. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28286. /**
  28287. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28288. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28289. * The `data` are either a numeric array either a Float32Array.
  28290. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28291. * 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).
  28292. * Note that a new underlying VertexBuffer object is created each call.
  28293. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28294. *
  28295. * Possible `kind` values :
  28296. * - VertexBuffer.PositionKind
  28297. * - VertexBuffer.UVKind
  28298. * - VertexBuffer.UV2Kind
  28299. * - VertexBuffer.UV3Kind
  28300. * - VertexBuffer.UV4Kind
  28301. * - VertexBuffer.UV5Kind
  28302. * - VertexBuffer.UV6Kind
  28303. * - VertexBuffer.ColorKind
  28304. * - VertexBuffer.MatricesIndicesKind
  28305. * - VertexBuffer.MatricesIndicesExtraKind
  28306. * - VertexBuffer.MatricesWeightsKind
  28307. * - VertexBuffer.MatricesWeightsExtraKind
  28308. *
  28309. * Returns the Mesh.
  28310. */
  28311. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28312. /**
  28313. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28314. * If the mesh has no geometry, it is simply returned as it is.
  28315. * The `data` are either a numeric array either a Float32Array.
  28316. * No new underlying VertexBuffer object is created.
  28317. * 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.
  28318. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28319. *
  28320. * Possible `kind` values :
  28321. * - VertexBuffer.PositionKind
  28322. * - VertexBuffer.UVKind
  28323. * - VertexBuffer.UV2Kind
  28324. * - VertexBuffer.UV3Kind
  28325. * - VertexBuffer.UV4Kind
  28326. * - VertexBuffer.UV5Kind
  28327. * - VertexBuffer.UV6Kind
  28328. * - VertexBuffer.ColorKind
  28329. * - VertexBuffer.MatricesIndicesKind
  28330. * - VertexBuffer.MatricesIndicesExtraKind
  28331. * - VertexBuffer.MatricesWeightsKind
  28332. * - VertexBuffer.MatricesWeightsExtraKind
  28333. *
  28334. * Returns the Mesh.
  28335. */
  28336. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28337. /**
  28338. * Sets the mesh indices.
  28339. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28340. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28341. * This method creates a new index buffer each call.
  28342. * Returns the Mesh.
  28343. */
  28344. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28345. /**
  28346. * Boolean : True if the mesh owns the requested kind of data.
  28347. */
  28348. isVerticesDataPresent(kind: string): boolean;
  28349. /**
  28350. * Returns an array of indices (IndicesArray).
  28351. */
  28352. getIndices(): Nullable<IndicesArray>;
  28353. get _positions(): Nullable<Vector3[]>;
  28354. /**
  28355. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28356. * This means the mesh underlying bounding box and sphere are recomputed.
  28357. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28358. * @returns the current mesh
  28359. */
  28360. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28361. /** @hidden */
  28362. _preActivate(): InstancedMesh;
  28363. /** @hidden */
  28364. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28365. /** @hidden */
  28366. _postActivate(): void;
  28367. getWorldMatrix(): Matrix;
  28368. get isAnInstance(): boolean;
  28369. /**
  28370. * Returns the current associated LOD AbstractMesh.
  28371. */
  28372. getLOD(camera: Camera): AbstractMesh;
  28373. /** @hidden */
  28374. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28375. /** @hidden */
  28376. _syncSubMeshes(): InstancedMesh;
  28377. /** @hidden */
  28378. _generatePointsArray(): boolean;
  28379. /** @hidden */
  28380. _updateBoundingInfo(): AbstractMesh;
  28381. /**
  28382. * Creates a new InstancedMesh from the current mesh.
  28383. * - name (string) : the cloned mesh name
  28384. * - newParent (optional Node) : the optional Node to parent the clone to.
  28385. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28386. *
  28387. * Returns the clone.
  28388. */
  28389. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28390. /**
  28391. * Disposes the InstancedMesh.
  28392. * Returns nothing.
  28393. */
  28394. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28395. }
  28396. interface Mesh {
  28397. /**
  28398. * Register a custom buffer that will be instanced
  28399. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28400. * @param kind defines the buffer kind
  28401. * @param stride defines the stride in floats
  28402. */
  28403. registerInstancedBuffer(kind: string, stride: number): void;
  28404. /**
  28405. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28406. */
  28407. _invalidateInstanceVertexArrayObject(): void;
  28408. /**
  28409. * true to use the edge renderer for all instances of this mesh
  28410. */
  28411. edgesShareWithInstances: boolean;
  28412. /** @hidden */
  28413. _userInstancedBuffersStorage: {
  28414. data: {
  28415. [key: string]: Float32Array;
  28416. };
  28417. sizes: {
  28418. [key: string]: number;
  28419. };
  28420. vertexBuffers: {
  28421. [key: string]: Nullable<VertexBuffer>;
  28422. };
  28423. strides: {
  28424. [key: string]: number;
  28425. };
  28426. vertexArrayObjects?: {
  28427. [key: string]: WebGLVertexArrayObject;
  28428. };
  28429. };
  28430. }
  28431. interface AbstractMesh {
  28432. /**
  28433. * Object used to store instanced buffers defined by user
  28434. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28435. */
  28436. instancedBuffers: {
  28437. [key: string]: any;
  28438. };
  28439. }
  28440. }
  28441. declare module BABYLON {
  28442. /**
  28443. * Defines the options associated with the creation of a shader material.
  28444. */
  28445. export interface IShaderMaterialOptions {
  28446. /**
  28447. * Does the material work in alpha blend mode
  28448. */
  28449. needAlphaBlending: boolean;
  28450. /**
  28451. * Does the material work in alpha test mode
  28452. */
  28453. needAlphaTesting: boolean;
  28454. /**
  28455. * The list of attribute names used in the shader
  28456. */
  28457. attributes: string[];
  28458. /**
  28459. * The list of unifrom names used in the shader
  28460. */
  28461. uniforms: string[];
  28462. /**
  28463. * The list of UBO names used in the shader
  28464. */
  28465. uniformBuffers: string[];
  28466. /**
  28467. * The list of sampler names used in the shader
  28468. */
  28469. samplers: string[];
  28470. /**
  28471. * The list of defines used in the shader
  28472. */
  28473. defines: string[];
  28474. }
  28475. /**
  28476. * 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.
  28477. *
  28478. * This returned material effects how the mesh will look based on the code in the shaders.
  28479. *
  28480. * @see https://doc.babylonjs.com/how_to/shader_material
  28481. */
  28482. export class ShaderMaterial extends Material {
  28483. private _shaderPath;
  28484. private _options;
  28485. private _textures;
  28486. private _textureArrays;
  28487. private _floats;
  28488. private _ints;
  28489. private _floatsArrays;
  28490. private _colors3;
  28491. private _colors3Arrays;
  28492. private _colors4;
  28493. private _colors4Arrays;
  28494. private _vectors2;
  28495. private _vectors3;
  28496. private _vectors4;
  28497. private _matrices;
  28498. private _matrixArrays;
  28499. private _matrices3x3;
  28500. private _matrices2x2;
  28501. private _vectors2Arrays;
  28502. private _vectors3Arrays;
  28503. private _vectors4Arrays;
  28504. private _cachedWorldViewMatrix;
  28505. private _cachedWorldViewProjectionMatrix;
  28506. private _renderId;
  28507. private _multiview;
  28508. private _cachedDefines;
  28509. /** Define the Url to load snippets */
  28510. static SnippetUrl: string;
  28511. /** Snippet ID if the material was created from the snippet server */
  28512. snippetId: string;
  28513. /**
  28514. * Instantiate a new shader material.
  28515. * 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.
  28516. * This returned material effects how the mesh will look based on the code in the shaders.
  28517. * @see https://doc.babylonjs.com/how_to/shader_material
  28518. * @param name Define the name of the material in the scene
  28519. * @param scene Define the scene the material belongs to
  28520. * @param shaderPath Defines the route to the shader code in one of three ways:
  28521. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28522. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28523. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28524. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28525. * @param options Define the options used to create the shader
  28526. */
  28527. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28528. /**
  28529. * Gets the shader path used to define the shader code
  28530. * It can be modified to trigger a new compilation
  28531. */
  28532. get shaderPath(): any;
  28533. /**
  28534. * Sets the shader path used to define the shader code
  28535. * It can be modified to trigger a new compilation
  28536. */
  28537. set shaderPath(shaderPath: any);
  28538. /**
  28539. * Gets the options used to compile the shader.
  28540. * They can be modified to trigger a new compilation
  28541. */
  28542. get options(): IShaderMaterialOptions;
  28543. /**
  28544. * Gets the current class name of the material e.g. "ShaderMaterial"
  28545. * Mainly use in serialization.
  28546. * @returns the class name
  28547. */
  28548. getClassName(): string;
  28549. /**
  28550. * Specifies if the material will require alpha blending
  28551. * @returns a boolean specifying if alpha blending is needed
  28552. */
  28553. needAlphaBlending(): boolean;
  28554. /**
  28555. * Specifies if this material should be rendered in alpha test mode
  28556. * @returns a boolean specifying if an alpha test is needed.
  28557. */
  28558. needAlphaTesting(): boolean;
  28559. private _checkUniform;
  28560. /**
  28561. * Set a texture in the shader.
  28562. * @param name Define the name of the uniform samplers as defined in the shader
  28563. * @param texture Define the texture to bind to this sampler
  28564. * @return the material itself allowing "fluent" like uniform updates
  28565. */
  28566. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28567. /**
  28568. * Set a texture array in the shader.
  28569. * @param name Define the name of the uniform sampler array as defined in the shader
  28570. * @param textures Define the list of textures to bind to this sampler
  28571. * @return the material itself allowing "fluent" like uniform updates
  28572. */
  28573. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28574. /**
  28575. * Set a float in the shader.
  28576. * @param name Define the name of the uniform as defined in the shader
  28577. * @param value Define the value to give to the uniform
  28578. * @return the material itself allowing "fluent" like uniform updates
  28579. */
  28580. setFloat(name: string, value: number): ShaderMaterial;
  28581. /**
  28582. * Set a int in the shader.
  28583. * @param name Define the name of the uniform as defined in the shader
  28584. * @param value Define the value to give to the uniform
  28585. * @return the material itself allowing "fluent" like uniform updates
  28586. */
  28587. setInt(name: string, value: number): ShaderMaterial;
  28588. /**
  28589. * Set an array of floats in the shader.
  28590. * @param name Define the name of the uniform as defined in the shader
  28591. * @param value Define the value to give to the uniform
  28592. * @return the material itself allowing "fluent" like uniform updates
  28593. */
  28594. setFloats(name: string, value: number[]): ShaderMaterial;
  28595. /**
  28596. * Set a vec3 in the shader from a Color3.
  28597. * @param name Define the name of the uniform as defined in the shader
  28598. * @param value Define the value to give to the uniform
  28599. * @return the material itself allowing "fluent" like uniform updates
  28600. */
  28601. setColor3(name: string, value: Color3): ShaderMaterial;
  28602. /**
  28603. * Set a vec3 array in the shader from a Color3 array.
  28604. * @param name Define the name of the uniform as defined in the shader
  28605. * @param value Define the value to give to the uniform
  28606. * @return the material itself allowing "fluent" like uniform updates
  28607. */
  28608. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28609. /**
  28610. * Set a vec4 in the shader from a Color4.
  28611. * @param name Define the name of the uniform as defined in the shader
  28612. * @param value Define the value to give to the uniform
  28613. * @return the material itself allowing "fluent" like uniform updates
  28614. */
  28615. setColor4(name: string, value: Color4): ShaderMaterial;
  28616. /**
  28617. * Set a vec4 array in the shader from a Color4 array.
  28618. * @param name Define the name of the uniform as defined in the shader
  28619. * @param value Define the value to give to the uniform
  28620. * @return the material itself allowing "fluent" like uniform updates
  28621. */
  28622. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28623. /**
  28624. * Set a vec2 in the shader from a Vector2.
  28625. * @param name Define the name of the uniform as defined in the shader
  28626. * @param value Define the value to give to the uniform
  28627. * @return the material itself allowing "fluent" like uniform updates
  28628. */
  28629. setVector2(name: string, value: Vector2): ShaderMaterial;
  28630. /**
  28631. * Set a vec3 in the shader from a Vector3.
  28632. * @param name Define the name of the uniform as defined in the shader
  28633. * @param value Define the value to give to the uniform
  28634. * @return the material itself allowing "fluent" like uniform updates
  28635. */
  28636. setVector3(name: string, value: Vector3): ShaderMaterial;
  28637. /**
  28638. * Set a vec4 in the shader from a Vector4.
  28639. * @param name Define the name of the uniform as defined in the shader
  28640. * @param value Define the value to give to the uniform
  28641. * @return the material itself allowing "fluent" like uniform updates
  28642. */
  28643. setVector4(name: string, value: Vector4): ShaderMaterial;
  28644. /**
  28645. * Set a mat4 in the shader from a Matrix.
  28646. * @param name Define the name of the uniform as defined in the shader
  28647. * @param value Define the value to give to the uniform
  28648. * @return the material itself allowing "fluent" like uniform updates
  28649. */
  28650. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28651. /**
  28652. * Set a float32Array in the shader from a matrix array.
  28653. * @param name Define the name of the uniform as defined in the shader
  28654. * @param value Define the value to give to the uniform
  28655. * @return the material itself allowing "fluent" like uniform updates
  28656. */
  28657. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28658. /**
  28659. * Set a mat3 in the shader from a Float32Array.
  28660. * @param name Define the name of the uniform as defined in the shader
  28661. * @param value Define the value to give to the uniform
  28662. * @return the material itself allowing "fluent" like uniform updates
  28663. */
  28664. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28665. /**
  28666. * Set a mat2 in the shader from a Float32Array.
  28667. * @param name Define the name of the uniform as defined in the shader
  28668. * @param value Define the value to give to the uniform
  28669. * @return the material itself allowing "fluent" like uniform updates
  28670. */
  28671. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28672. /**
  28673. * Set a vec2 array in the shader from a number array.
  28674. * @param name Define the name of the uniform as defined in the shader
  28675. * @param value Define the value to give to the uniform
  28676. * @return the material itself allowing "fluent" like uniform updates
  28677. */
  28678. setArray2(name: string, value: number[]): ShaderMaterial;
  28679. /**
  28680. * Set a vec3 array in the shader from a number array.
  28681. * @param name Define the name of the uniform as defined in the shader
  28682. * @param value Define the value to give to the uniform
  28683. * @return the material itself allowing "fluent" like uniform updates
  28684. */
  28685. setArray3(name: string, value: number[]): ShaderMaterial;
  28686. /**
  28687. * Set a vec4 array in the shader from a number array.
  28688. * @param name Define the name of the uniform as defined in the shader
  28689. * @param value Define the value to give to the uniform
  28690. * @return the material itself allowing "fluent" like uniform updates
  28691. */
  28692. setArray4(name: string, value: number[]): ShaderMaterial;
  28693. private _checkCache;
  28694. /**
  28695. * Specifies that the submesh is ready to be used
  28696. * @param mesh defines the mesh to check
  28697. * @param subMesh defines which submesh to check
  28698. * @param useInstances specifies that instances should be used
  28699. * @returns a boolean indicating that the submesh is ready or not
  28700. */
  28701. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28702. /**
  28703. * Checks if the material is ready to render the requested mesh
  28704. * @param mesh Define the mesh to render
  28705. * @param useInstances Define whether or not the material is used with instances
  28706. * @returns true if ready, otherwise false
  28707. */
  28708. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28709. /**
  28710. * Binds the world matrix to the material
  28711. * @param world defines the world transformation matrix
  28712. * @param effectOverride - If provided, use this effect instead of internal effect
  28713. */
  28714. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28715. /**
  28716. * Binds the submesh to this material by preparing the effect and shader to draw
  28717. * @param world defines the world transformation matrix
  28718. * @param mesh defines the mesh containing the submesh
  28719. * @param subMesh defines the submesh to bind the material to
  28720. */
  28721. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28722. /**
  28723. * Binds the material to the mesh
  28724. * @param world defines the world transformation matrix
  28725. * @param mesh defines the mesh to bind the material to
  28726. * @param effectOverride - If provided, use this effect instead of internal effect
  28727. */
  28728. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28729. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28730. /**
  28731. * Gets the active textures from the material
  28732. * @returns an array of textures
  28733. */
  28734. getActiveTextures(): BaseTexture[];
  28735. /**
  28736. * Specifies if the material uses a texture
  28737. * @param texture defines the texture to check against the material
  28738. * @returns a boolean specifying if the material uses the texture
  28739. */
  28740. hasTexture(texture: BaseTexture): boolean;
  28741. /**
  28742. * Makes a duplicate of the material, and gives it a new name
  28743. * @param name defines the new name for the duplicated material
  28744. * @returns the cloned material
  28745. */
  28746. clone(name: string): ShaderMaterial;
  28747. /**
  28748. * Disposes the material
  28749. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28750. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28751. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28752. */
  28753. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28754. /**
  28755. * Serializes this material in a JSON representation
  28756. * @returns the serialized material object
  28757. */
  28758. serialize(): any;
  28759. /**
  28760. * Creates a shader material from parsed shader material data
  28761. * @param source defines the JSON represnetation of the material
  28762. * @param scene defines the hosting scene
  28763. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28764. * @returns a new material
  28765. */
  28766. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28767. /**
  28768. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28769. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28770. * @param url defines the url to load from
  28771. * @param scene defines the hosting scene
  28772. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28773. * @returns a promise that will resolve to the new ShaderMaterial
  28774. */
  28775. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28776. /**
  28777. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28778. * @param snippetId defines the snippet to load
  28779. * @param scene defines the hosting scene
  28780. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28781. * @returns a promise that will resolve to the new ShaderMaterial
  28782. */
  28783. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28784. }
  28785. }
  28786. declare module BABYLON {
  28787. /** @hidden */
  28788. export var colorPixelShader: {
  28789. name: string;
  28790. shader: string;
  28791. };
  28792. }
  28793. declare module BABYLON {
  28794. /** @hidden */
  28795. export var colorVertexShader: {
  28796. name: string;
  28797. shader: string;
  28798. };
  28799. }
  28800. declare module BABYLON {
  28801. /**
  28802. * Line mesh
  28803. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28804. */
  28805. export class LinesMesh extends Mesh {
  28806. /**
  28807. * If vertex color should be applied to the mesh
  28808. */
  28809. readonly useVertexColor?: boolean | undefined;
  28810. /**
  28811. * If vertex alpha should be applied to the mesh
  28812. */
  28813. readonly useVertexAlpha?: boolean | undefined;
  28814. /**
  28815. * Color of the line (Default: White)
  28816. */
  28817. color: Color3;
  28818. /**
  28819. * Alpha of the line (Default: 1)
  28820. */
  28821. alpha: number;
  28822. /**
  28823. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28824. * This margin is expressed in world space coordinates, so its value may vary.
  28825. * Default value is 0.1
  28826. */
  28827. intersectionThreshold: number;
  28828. private _colorShader;
  28829. private color4;
  28830. /**
  28831. * Creates a new LinesMesh
  28832. * @param name defines the name
  28833. * @param scene defines the hosting scene
  28834. * @param parent defines the parent mesh if any
  28835. * @param source defines the optional source LinesMesh used to clone data from
  28836. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28837. * When false, achieved by calling a clone(), also passing False.
  28838. * This will make creation of children, recursive.
  28839. * @param useVertexColor defines if this LinesMesh supports vertex color
  28840. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28841. */
  28842. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28843. /**
  28844. * If vertex color should be applied to the mesh
  28845. */
  28846. useVertexColor?: boolean | undefined,
  28847. /**
  28848. * If vertex alpha should be applied to the mesh
  28849. */
  28850. useVertexAlpha?: boolean | undefined);
  28851. private _addClipPlaneDefine;
  28852. private _removeClipPlaneDefine;
  28853. isReady(): boolean;
  28854. /**
  28855. * Returns the string "LineMesh"
  28856. */
  28857. getClassName(): string;
  28858. /**
  28859. * @hidden
  28860. */
  28861. get material(): Material;
  28862. /**
  28863. * @hidden
  28864. */
  28865. set material(value: Material);
  28866. /**
  28867. * @hidden
  28868. */
  28869. get checkCollisions(): boolean;
  28870. set checkCollisions(value: boolean);
  28871. /** @hidden */
  28872. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28873. /** @hidden */
  28874. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28875. /**
  28876. * Disposes of the line mesh
  28877. * @param doNotRecurse If children should be disposed
  28878. */
  28879. dispose(doNotRecurse?: boolean): void;
  28880. /**
  28881. * Returns a new LineMesh object cloned from the current one.
  28882. */
  28883. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28884. /**
  28885. * Creates a new InstancedLinesMesh object from the mesh model.
  28886. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28887. * @param name defines the name of the new instance
  28888. * @returns a new InstancedLinesMesh
  28889. */
  28890. createInstance(name: string): InstancedLinesMesh;
  28891. }
  28892. /**
  28893. * Creates an instance based on a source LinesMesh
  28894. */
  28895. export class InstancedLinesMesh extends InstancedMesh {
  28896. /**
  28897. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28898. * This margin is expressed in world space coordinates, so its value may vary.
  28899. * Initilized with the intersectionThreshold value of the source LinesMesh
  28900. */
  28901. intersectionThreshold: number;
  28902. constructor(name: string, source: LinesMesh);
  28903. /**
  28904. * Returns the string "InstancedLinesMesh".
  28905. */
  28906. getClassName(): string;
  28907. }
  28908. }
  28909. declare module BABYLON {
  28910. /** @hidden */
  28911. export var linePixelShader: {
  28912. name: string;
  28913. shader: string;
  28914. };
  28915. }
  28916. declare module BABYLON {
  28917. /** @hidden */
  28918. export var lineVertexShader: {
  28919. name: string;
  28920. shader: string;
  28921. };
  28922. }
  28923. declare module BABYLON {
  28924. interface Scene {
  28925. /** @hidden */
  28926. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28927. }
  28928. interface AbstractMesh {
  28929. /**
  28930. * Gets the edgesRenderer associated with the mesh
  28931. */
  28932. edgesRenderer: Nullable<EdgesRenderer>;
  28933. }
  28934. interface LinesMesh {
  28935. /**
  28936. * Enables the edge rendering mode on the mesh.
  28937. * This mode makes the mesh edges visible
  28938. * @param epsilon defines the maximal distance between two angles to detect a face
  28939. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28940. * @returns the currentAbstractMesh
  28941. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28942. */
  28943. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28944. }
  28945. interface InstancedLinesMesh {
  28946. /**
  28947. * Enables the edge rendering mode on the mesh.
  28948. * This mode makes the mesh edges visible
  28949. * @param epsilon defines the maximal distance between two angles to detect a face
  28950. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28951. * @returns the current InstancedLinesMesh
  28952. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28953. */
  28954. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28955. }
  28956. /**
  28957. * Defines the minimum contract an Edges renderer should follow.
  28958. */
  28959. export interface IEdgesRenderer extends IDisposable {
  28960. /**
  28961. * Gets or sets a boolean indicating if the edgesRenderer is active
  28962. */
  28963. isEnabled: boolean;
  28964. /**
  28965. * Renders the edges of the attached mesh,
  28966. */
  28967. render(): void;
  28968. /**
  28969. * Checks wether or not the edges renderer is ready to render.
  28970. * @return true if ready, otherwise false.
  28971. */
  28972. isReady(): boolean;
  28973. /**
  28974. * List of instances to render in case the source mesh has instances
  28975. */
  28976. customInstances: SmartArray<Matrix>;
  28977. }
  28978. /**
  28979. * Defines the additional options of the edges renderer
  28980. */
  28981. export interface IEdgesRendererOptions {
  28982. /**
  28983. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28984. * If not defined, the default value is true
  28985. */
  28986. useAlternateEdgeFinder?: boolean;
  28987. /**
  28988. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28989. * If not defined, the default value is true.
  28990. * 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)
  28991. * This option is used only if useAlternateEdgeFinder = true
  28992. */
  28993. useFastVertexMerger?: boolean;
  28994. /**
  28995. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28996. * The default value is 1e-6
  28997. * This option is used only if useAlternateEdgeFinder = true
  28998. */
  28999. epsilonVertexMerge?: number;
  29000. /**
  29001. * 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
  29002. * 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.
  29003. * This option is used only if useAlternateEdgeFinder = true
  29004. */
  29005. applyTessellation?: boolean;
  29006. /**
  29007. * 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
  29008. * The default value is 1e-6
  29009. * This option is used only if useAlternateEdgeFinder = true
  29010. */
  29011. epsilonVertexAligned?: number;
  29012. }
  29013. /**
  29014. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29015. */
  29016. export class EdgesRenderer implements IEdgesRenderer {
  29017. /**
  29018. * Define the size of the edges with an orthographic camera
  29019. */
  29020. edgesWidthScalerForOrthographic: number;
  29021. /**
  29022. * Define the size of the edges with a perspective camera
  29023. */
  29024. edgesWidthScalerForPerspective: number;
  29025. protected _source: AbstractMesh;
  29026. protected _linesPositions: number[];
  29027. protected _linesNormals: number[];
  29028. protected _linesIndices: number[];
  29029. protected _epsilon: number;
  29030. protected _indicesCount: number;
  29031. protected _lineShader: ShaderMaterial;
  29032. protected _ib: DataBuffer;
  29033. protected _buffers: {
  29034. [key: string]: Nullable<VertexBuffer>;
  29035. };
  29036. protected _buffersForInstances: {
  29037. [key: string]: Nullable<VertexBuffer>;
  29038. };
  29039. protected _checkVerticesInsteadOfIndices: boolean;
  29040. protected _options: Nullable<IEdgesRendererOptions>;
  29041. private _meshRebuildObserver;
  29042. private _meshDisposeObserver;
  29043. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29044. isEnabled: boolean;
  29045. /** Gets the vertices generated by the edge renderer */
  29046. get linesPositions(): Immutable<Array<number>>;
  29047. /** Gets the normals generated by the edge renderer */
  29048. get linesNormals(): Immutable<Array<number>>;
  29049. /** Gets the indices generated by the edge renderer */
  29050. get linesIndices(): Immutable<Array<number>>;
  29051. /**
  29052. * List of instances to render in case the source mesh has instances
  29053. */
  29054. customInstances: SmartArray<Matrix>;
  29055. private static GetShader;
  29056. /**
  29057. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29058. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29059. * @param source Mesh used to create edges
  29060. * @param epsilon sum of angles in adjacency to check for edge
  29061. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29062. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29063. * @param options The options to apply when generating the edges
  29064. */
  29065. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29066. protected _prepareRessources(): void;
  29067. /** @hidden */
  29068. _rebuild(): void;
  29069. /**
  29070. * Releases the required resources for the edges renderer
  29071. */
  29072. dispose(): void;
  29073. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29074. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29075. /**
  29076. * Checks if the pair of p0 and p1 is en edge
  29077. * @param faceIndex
  29078. * @param edge
  29079. * @param faceNormals
  29080. * @param p0
  29081. * @param p1
  29082. * @private
  29083. */
  29084. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29085. /**
  29086. * push line into the position, normal and index buffer
  29087. * @protected
  29088. */
  29089. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29090. /**
  29091. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29092. */
  29093. private _tessellateTriangle;
  29094. private _generateEdgesLinesAlternate;
  29095. /**
  29096. * Generates lines edges from adjacencjes
  29097. * @private
  29098. */
  29099. _generateEdgesLines(): void;
  29100. /**
  29101. * Checks wether or not the edges renderer is ready to render.
  29102. * @return true if ready, otherwise false.
  29103. */
  29104. isReady(): boolean;
  29105. /**
  29106. * Renders the edges of the attached mesh,
  29107. */
  29108. render(): void;
  29109. }
  29110. /**
  29111. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29112. */
  29113. export class LineEdgesRenderer extends EdgesRenderer {
  29114. /**
  29115. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29116. * @param source LineMesh used to generate edges
  29117. * @param epsilon not important (specified angle for edge detection)
  29118. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29119. */
  29120. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29121. /**
  29122. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29123. */
  29124. _generateEdgesLines(): void;
  29125. }
  29126. }
  29127. declare module BABYLON {
  29128. /**
  29129. * This represents the object necessary to create a rendering group.
  29130. * This is exclusively used and created by the rendering manager.
  29131. * To modify the behavior, you use the available helpers in your scene or meshes.
  29132. * @hidden
  29133. */
  29134. export class RenderingGroup {
  29135. index: number;
  29136. private static _zeroVector;
  29137. private _scene;
  29138. private _opaqueSubMeshes;
  29139. private _transparentSubMeshes;
  29140. private _alphaTestSubMeshes;
  29141. private _depthOnlySubMeshes;
  29142. private _particleSystems;
  29143. private _spriteManagers;
  29144. private _opaqueSortCompareFn;
  29145. private _alphaTestSortCompareFn;
  29146. private _transparentSortCompareFn;
  29147. private _renderOpaque;
  29148. private _renderAlphaTest;
  29149. private _renderTransparent;
  29150. /** @hidden */
  29151. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29152. onBeforeTransparentRendering: () => void;
  29153. /**
  29154. * Set the opaque sort comparison function.
  29155. * If null the sub meshes will be render in the order they were created
  29156. */
  29157. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29158. /**
  29159. * Set the alpha test sort comparison function.
  29160. * If null the sub meshes will be render in the order they were created
  29161. */
  29162. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29163. /**
  29164. * Set the transparent sort comparison function.
  29165. * If null the sub meshes will be render in the order they were created
  29166. */
  29167. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29168. /**
  29169. * Creates a new rendering group.
  29170. * @param index The rendering group index
  29171. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29172. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29173. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29174. */
  29175. 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>);
  29176. /**
  29177. * Render all the sub meshes contained in the group.
  29178. * @param customRenderFunction Used to override the default render behaviour of the group.
  29179. * @returns true if rendered some submeshes.
  29180. */
  29181. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29182. /**
  29183. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29184. * @param subMeshes The submeshes to render
  29185. */
  29186. private renderOpaqueSorted;
  29187. /**
  29188. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29189. * @param subMeshes The submeshes to render
  29190. */
  29191. private renderAlphaTestSorted;
  29192. /**
  29193. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29194. * @param subMeshes The submeshes to render
  29195. */
  29196. private renderTransparentSorted;
  29197. /**
  29198. * Renders the submeshes in a specified order.
  29199. * @param subMeshes The submeshes to sort before render
  29200. * @param sortCompareFn The comparison function use to sort
  29201. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29202. * @param transparent Specifies to activate blending if true
  29203. */
  29204. private static renderSorted;
  29205. /**
  29206. * Renders the submeshes in the order they were dispatched (no sort applied).
  29207. * @param subMeshes The submeshes to render
  29208. */
  29209. private static renderUnsorted;
  29210. /**
  29211. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29212. * are rendered back to front if in the same alpha index.
  29213. *
  29214. * @param a The first submesh
  29215. * @param b The second submesh
  29216. * @returns The result of the comparison
  29217. */
  29218. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29219. /**
  29220. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29221. * are rendered back to front.
  29222. *
  29223. * @param a The first submesh
  29224. * @param b The second submesh
  29225. * @returns The result of the comparison
  29226. */
  29227. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29228. /**
  29229. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29230. * are rendered front to back (prevent overdraw).
  29231. *
  29232. * @param a The first submesh
  29233. * @param b The second submesh
  29234. * @returns The result of the comparison
  29235. */
  29236. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29237. /**
  29238. * Resets the different lists of submeshes to prepare a new frame.
  29239. */
  29240. prepare(): void;
  29241. dispose(): void;
  29242. /**
  29243. * Inserts the submesh in its correct queue depending on its material.
  29244. * @param subMesh The submesh to dispatch
  29245. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29246. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29247. */
  29248. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29249. dispatchSprites(spriteManager: ISpriteManager): void;
  29250. dispatchParticles(particleSystem: IParticleSystem): void;
  29251. private _renderParticles;
  29252. private _renderSprites;
  29253. }
  29254. }
  29255. declare module BABYLON {
  29256. /**
  29257. * Interface describing the different options available in the rendering manager
  29258. * regarding Auto Clear between groups.
  29259. */
  29260. export interface IRenderingManagerAutoClearSetup {
  29261. /**
  29262. * Defines whether or not autoclear is enable.
  29263. */
  29264. autoClear: boolean;
  29265. /**
  29266. * Defines whether or not to autoclear the depth buffer.
  29267. */
  29268. depth: boolean;
  29269. /**
  29270. * Defines whether or not to autoclear the stencil buffer.
  29271. */
  29272. stencil: boolean;
  29273. }
  29274. /**
  29275. * This class is used by the onRenderingGroupObservable
  29276. */
  29277. export class RenderingGroupInfo {
  29278. /**
  29279. * The Scene that being rendered
  29280. */
  29281. scene: Scene;
  29282. /**
  29283. * The camera currently used for the rendering pass
  29284. */
  29285. camera: Nullable<Camera>;
  29286. /**
  29287. * The ID of the renderingGroup being processed
  29288. */
  29289. renderingGroupId: number;
  29290. }
  29291. /**
  29292. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29293. * It is enable to manage the different groups as well as the different necessary sort functions.
  29294. * This should not be used directly aside of the few static configurations
  29295. */
  29296. export class RenderingManager {
  29297. /**
  29298. * The max id used for rendering groups (not included)
  29299. */
  29300. static MAX_RENDERINGGROUPS: number;
  29301. /**
  29302. * The min id used for rendering groups (included)
  29303. */
  29304. static MIN_RENDERINGGROUPS: number;
  29305. /**
  29306. * Used to globally prevent autoclearing scenes.
  29307. */
  29308. static AUTOCLEAR: boolean;
  29309. /**
  29310. * @hidden
  29311. */
  29312. _useSceneAutoClearSetup: boolean;
  29313. private _scene;
  29314. private _renderingGroups;
  29315. private _depthStencilBufferAlreadyCleaned;
  29316. private _autoClearDepthStencil;
  29317. private _customOpaqueSortCompareFn;
  29318. private _customAlphaTestSortCompareFn;
  29319. private _customTransparentSortCompareFn;
  29320. private _renderingGroupInfo;
  29321. /**
  29322. * Instantiates a new rendering group for a particular scene
  29323. * @param scene Defines the scene the groups belongs to
  29324. */
  29325. constructor(scene: Scene);
  29326. private _clearDepthStencilBuffer;
  29327. /**
  29328. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29329. * @hidden
  29330. */
  29331. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29332. /**
  29333. * Resets the different information of the group to prepare a new frame
  29334. * @hidden
  29335. */
  29336. reset(): void;
  29337. /**
  29338. * Dispose and release the group and its associated resources.
  29339. * @hidden
  29340. */
  29341. dispose(): void;
  29342. /**
  29343. * Clear the info related to rendering groups preventing retention points during dispose.
  29344. */
  29345. freeRenderingGroups(): void;
  29346. private _prepareRenderingGroup;
  29347. /**
  29348. * Add a sprite manager to the rendering manager in order to render it this frame.
  29349. * @param spriteManager Define the sprite manager to render
  29350. */
  29351. dispatchSprites(spriteManager: ISpriteManager): void;
  29352. /**
  29353. * Add a particle system to the rendering manager in order to render it this frame.
  29354. * @param particleSystem Define the particle system to render
  29355. */
  29356. dispatchParticles(particleSystem: IParticleSystem): void;
  29357. /**
  29358. * Add a submesh to the manager in order to render it this frame
  29359. * @param subMesh The submesh to dispatch
  29360. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29361. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29362. */
  29363. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29364. /**
  29365. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29366. * This allowed control for front to back rendering or reversly depending of the special needs.
  29367. *
  29368. * @param renderingGroupId The rendering group id corresponding to its index
  29369. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29370. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29371. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29372. */
  29373. 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;
  29374. /**
  29375. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29376. *
  29377. * @param renderingGroupId The rendering group id corresponding to its index
  29378. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29379. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29380. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29381. */
  29382. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29383. /**
  29384. * Gets the current auto clear configuration for one rendering group of the rendering
  29385. * manager.
  29386. * @param index the rendering group index to get the information for
  29387. * @returns The auto clear setup for the requested rendering group
  29388. */
  29389. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29390. }
  29391. }
  29392. declare module BABYLON {
  29393. /**
  29394. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29395. */
  29396. export interface ICustomShaderOptions {
  29397. /**
  29398. * Gets or sets the custom shader name to use
  29399. */
  29400. shaderName: string;
  29401. /**
  29402. * The list of attribute names used in the shader
  29403. */
  29404. attributes?: string[];
  29405. /**
  29406. * The list of unifrom names used in the shader
  29407. */
  29408. uniforms?: string[];
  29409. /**
  29410. * The list of sampler names used in the shader
  29411. */
  29412. samplers?: string[];
  29413. /**
  29414. * The list of defines used in the shader
  29415. */
  29416. defines?: string[];
  29417. }
  29418. /**
  29419. * Interface to implement to create a shadow generator compatible with BJS.
  29420. */
  29421. export interface IShadowGenerator {
  29422. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29423. id: string;
  29424. /**
  29425. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29426. * @returns The render target texture if present otherwise, null
  29427. */
  29428. getShadowMap(): Nullable<RenderTargetTexture>;
  29429. /**
  29430. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29431. * @param subMesh The submesh we want to render in the shadow map
  29432. * @param useInstances Defines wether will draw in the map using instances
  29433. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29434. * @returns true if ready otherwise, false
  29435. */
  29436. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29437. /**
  29438. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29439. * @param defines Defines of the material we want to update
  29440. * @param lightIndex Index of the light in the enabled light list of the material
  29441. */
  29442. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29443. /**
  29444. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29445. * defined in the generator but impacting the effect).
  29446. * It implies the unifroms available on the materials are the standard BJS ones.
  29447. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29448. * @param effect The effect we are binfing the information for
  29449. */
  29450. bindShadowLight(lightIndex: string, effect: Effect): void;
  29451. /**
  29452. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29453. * (eq to shadow prjection matrix * light transform matrix)
  29454. * @returns The transform matrix used to create the shadow map
  29455. */
  29456. getTransformMatrix(): Matrix;
  29457. /**
  29458. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29459. * Cube and 2D textures for instance.
  29460. */
  29461. recreateShadowMap(): void;
  29462. /**
  29463. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29464. * @param onCompiled Callback triggered at the and of the effects compilation
  29465. * @param options Sets of optional options forcing the compilation with different modes
  29466. */
  29467. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29468. useInstances: boolean;
  29469. }>): void;
  29470. /**
  29471. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29472. * @param options Sets of optional options forcing the compilation with different modes
  29473. * @returns A promise that resolves when the compilation completes
  29474. */
  29475. forceCompilationAsync(options?: Partial<{
  29476. useInstances: boolean;
  29477. }>): Promise<void>;
  29478. /**
  29479. * Serializes the shadow generator setup to a json object.
  29480. * @returns The serialized JSON object
  29481. */
  29482. serialize(): any;
  29483. /**
  29484. * Disposes the Shadow map and related Textures and effects.
  29485. */
  29486. dispose(): void;
  29487. }
  29488. /**
  29489. * Default implementation IShadowGenerator.
  29490. * This is the main object responsible of generating shadows in the framework.
  29491. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29492. */
  29493. export class ShadowGenerator implements IShadowGenerator {
  29494. private static _Counter;
  29495. /**
  29496. * Name of the shadow generator class
  29497. */
  29498. static CLASSNAME: string;
  29499. /**
  29500. * Shadow generator mode None: no filtering applied.
  29501. */
  29502. static readonly FILTER_NONE: number;
  29503. /**
  29504. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29505. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29506. */
  29507. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29508. /**
  29509. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29510. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29511. */
  29512. static readonly FILTER_POISSONSAMPLING: number;
  29513. /**
  29514. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29515. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29516. */
  29517. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29518. /**
  29519. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29520. * edge artifacts on steep falloff.
  29521. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29522. */
  29523. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29524. /**
  29525. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29526. * edge artifacts on steep falloff.
  29527. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29528. */
  29529. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29530. /**
  29531. * Shadow generator mode PCF: Percentage Closer Filtering
  29532. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29533. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29534. */
  29535. static readonly FILTER_PCF: number;
  29536. /**
  29537. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29538. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29539. * Contact Hardening
  29540. */
  29541. static readonly FILTER_PCSS: number;
  29542. /**
  29543. * Reserved for PCF and PCSS
  29544. * Highest Quality.
  29545. *
  29546. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29547. *
  29548. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29549. */
  29550. static readonly QUALITY_HIGH: number;
  29551. /**
  29552. * Reserved for PCF and PCSS
  29553. * Good tradeoff for quality/perf cross devices
  29554. *
  29555. * Execute PCF on a 3*3 kernel.
  29556. *
  29557. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29558. */
  29559. static readonly QUALITY_MEDIUM: number;
  29560. /**
  29561. * Reserved for PCF and PCSS
  29562. * The lowest quality but the fastest.
  29563. *
  29564. * Execute PCF on a 1*1 kernel.
  29565. *
  29566. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29567. */
  29568. static readonly QUALITY_LOW: number;
  29569. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29570. id: string;
  29571. /** Gets or sets the custom shader name to use */
  29572. customShaderOptions: ICustomShaderOptions;
  29573. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29574. customAllowRendering: (subMesh: SubMesh) => boolean;
  29575. /**
  29576. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29577. */
  29578. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29579. /**
  29580. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29581. */
  29582. onAfterShadowMapRenderObservable: Observable<Effect>;
  29583. /**
  29584. * Observable triggered before a mesh is rendered in the shadow map.
  29585. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29586. */
  29587. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29588. /**
  29589. * Observable triggered after a mesh is rendered in the shadow map.
  29590. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29591. */
  29592. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29593. protected _bias: number;
  29594. /**
  29595. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29596. */
  29597. get bias(): number;
  29598. /**
  29599. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29600. */
  29601. set bias(bias: number);
  29602. protected _normalBias: number;
  29603. /**
  29604. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29605. */
  29606. get normalBias(): number;
  29607. /**
  29608. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29609. */
  29610. set normalBias(normalBias: number);
  29611. protected _blurBoxOffset: number;
  29612. /**
  29613. * Gets the blur box offset: offset applied during the blur pass.
  29614. * Only useful if useKernelBlur = false
  29615. */
  29616. get blurBoxOffset(): number;
  29617. /**
  29618. * Sets the blur box offset: offset applied during the blur pass.
  29619. * Only useful if useKernelBlur = false
  29620. */
  29621. set blurBoxOffset(value: number);
  29622. protected _blurScale: number;
  29623. /**
  29624. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29625. * 2 means half of the size.
  29626. */
  29627. get blurScale(): number;
  29628. /**
  29629. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29630. * 2 means half of the size.
  29631. */
  29632. set blurScale(value: number);
  29633. protected _blurKernel: number;
  29634. /**
  29635. * Gets the blur kernel: kernel size of the blur pass.
  29636. * Only useful if useKernelBlur = true
  29637. */
  29638. get blurKernel(): number;
  29639. /**
  29640. * Sets the blur kernel: kernel size of the blur pass.
  29641. * Only useful if useKernelBlur = true
  29642. */
  29643. set blurKernel(value: number);
  29644. protected _useKernelBlur: boolean;
  29645. /**
  29646. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29648. */
  29649. get useKernelBlur(): boolean;
  29650. /**
  29651. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29652. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29653. */
  29654. set useKernelBlur(value: boolean);
  29655. protected _depthScale: number;
  29656. /**
  29657. * Gets the depth scale used in ESM mode.
  29658. */
  29659. get depthScale(): number;
  29660. /**
  29661. * Sets the depth scale used in ESM mode.
  29662. * This can override the scale stored on the light.
  29663. */
  29664. set depthScale(value: number);
  29665. protected _validateFilter(filter: number): number;
  29666. protected _filter: number;
  29667. /**
  29668. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29669. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29670. */
  29671. get filter(): number;
  29672. /**
  29673. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29674. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29675. */
  29676. set filter(value: number);
  29677. /**
  29678. * Gets if the current filter is set to Poisson Sampling.
  29679. */
  29680. get usePoissonSampling(): boolean;
  29681. /**
  29682. * Sets the current filter to Poisson Sampling.
  29683. */
  29684. set usePoissonSampling(value: boolean);
  29685. /**
  29686. * Gets if the current filter is set to ESM.
  29687. */
  29688. get useExponentialShadowMap(): boolean;
  29689. /**
  29690. * Sets the current filter is to ESM.
  29691. */
  29692. set useExponentialShadowMap(value: boolean);
  29693. /**
  29694. * Gets if the current filter is set to filtered ESM.
  29695. */
  29696. get useBlurExponentialShadowMap(): boolean;
  29697. /**
  29698. * Gets if the current filter is set to filtered ESM.
  29699. */
  29700. set useBlurExponentialShadowMap(value: boolean);
  29701. /**
  29702. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29703. * exponential to prevent steep falloff artifacts).
  29704. */
  29705. get useCloseExponentialShadowMap(): boolean;
  29706. /**
  29707. * Sets the current filter to "close ESM" (using the inverse of the
  29708. * exponential to prevent steep falloff artifacts).
  29709. */
  29710. set useCloseExponentialShadowMap(value: boolean);
  29711. /**
  29712. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29713. * exponential to prevent steep falloff artifacts).
  29714. */
  29715. get useBlurCloseExponentialShadowMap(): boolean;
  29716. /**
  29717. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29718. * exponential to prevent steep falloff artifacts).
  29719. */
  29720. set useBlurCloseExponentialShadowMap(value: boolean);
  29721. /**
  29722. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29723. */
  29724. get usePercentageCloserFiltering(): boolean;
  29725. /**
  29726. * Sets the current filter to "PCF" (percentage closer filtering).
  29727. */
  29728. set usePercentageCloserFiltering(value: boolean);
  29729. protected _filteringQuality: number;
  29730. /**
  29731. * Gets the PCF or PCSS Quality.
  29732. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29733. */
  29734. get filteringQuality(): number;
  29735. /**
  29736. * Sets the PCF or PCSS Quality.
  29737. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29738. */
  29739. set filteringQuality(filteringQuality: number);
  29740. /**
  29741. * Gets if the current filter is set to "PCSS" (contact hardening).
  29742. */
  29743. get useContactHardeningShadow(): boolean;
  29744. /**
  29745. * Sets the current filter to "PCSS" (contact hardening).
  29746. */
  29747. set useContactHardeningShadow(value: boolean);
  29748. protected _contactHardeningLightSizeUVRatio: number;
  29749. /**
  29750. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29751. * Using a ratio helps keeping shape stability independently of the map size.
  29752. *
  29753. * It does not account for the light projection as it was having too much
  29754. * instability during the light setup or during light position changes.
  29755. *
  29756. * Only valid if useContactHardeningShadow is true.
  29757. */
  29758. get contactHardeningLightSizeUVRatio(): number;
  29759. /**
  29760. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29761. * Using a ratio helps keeping shape stability independently of the map size.
  29762. *
  29763. * It does not account for the light projection as it was having too much
  29764. * instability during the light setup or during light position changes.
  29765. *
  29766. * Only valid if useContactHardeningShadow is true.
  29767. */
  29768. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29769. protected _darkness: number;
  29770. /** Gets or sets the actual darkness of a shadow */
  29771. get darkness(): number;
  29772. set darkness(value: number);
  29773. /**
  29774. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29775. * 0 means strongest and 1 would means no shadow.
  29776. * @returns the darkness.
  29777. */
  29778. getDarkness(): number;
  29779. /**
  29780. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29781. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29782. * @returns the shadow generator allowing fluent coding.
  29783. */
  29784. setDarkness(darkness: number): ShadowGenerator;
  29785. protected _transparencyShadow: boolean;
  29786. /** Gets or sets the ability to have transparent shadow */
  29787. get transparencyShadow(): boolean;
  29788. set transparencyShadow(value: boolean);
  29789. /**
  29790. * Sets the ability to have transparent shadow (boolean).
  29791. * @param transparent True if transparent else False
  29792. * @returns the shadow generator allowing fluent coding
  29793. */
  29794. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29795. /**
  29796. * Enables or disables shadows with varying strength based on the transparency
  29797. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29798. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29799. * mesh.visibility * alphaTexture.a
  29800. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29801. */
  29802. enableSoftTransparentShadow: boolean;
  29803. protected _shadowMap: Nullable<RenderTargetTexture>;
  29804. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29805. /**
  29806. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29807. * @returns The render target texture if present otherwise, null
  29808. */
  29809. getShadowMap(): Nullable<RenderTargetTexture>;
  29810. /**
  29811. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29812. * @returns The render target texture if the shadow map is present otherwise, null
  29813. */
  29814. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29815. /**
  29816. * Gets the class name of that object
  29817. * @returns "ShadowGenerator"
  29818. */
  29819. getClassName(): string;
  29820. /**
  29821. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29822. * @param mesh Mesh to add
  29823. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29824. * @returns the Shadow Generator itself
  29825. */
  29826. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29827. /**
  29828. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29829. * @param mesh Mesh to remove
  29830. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29831. * @returns the Shadow Generator itself
  29832. */
  29833. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29834. /**
  29835. * Controls the extent to which the shadows fade out at the edge of the frustum
  29836. */
  29837. frustumEdgeFalloff: number;
  29838. protected _light: IShadowLight;
  29839. /**
  29840. * Returns the associated light object.
  29841. * @returns the light generating the shadow
  29842. */
  29843. getLight(): IShadowLight;
  29844. /**
  29845. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29846. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29847. * It might on the other hand introduce peter panning.
  29848. */
  29849. forceBackFacesOnly: boolean;
  29850. protected _scene: Scene;
  29851. protected _lightDirection: Vector3;
  29852. protected _viewMatrix: Matrix;
  29853. protected _projectionMatrix: Matrix;
  29854. protected _transformMatrix: Matrix;
  29855. protected _cachedPosition: Vector3;
  29856. protected _cachedDirection: Vector3;
  29857. protected _cachedDefines: string;
  29858. protected _currentRenderID: number;
  29859. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29860. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29861. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29862. protected _blurPostProcesses: PostProcess[];
  29863. protected _mapSize: number;
  29864. protected _currentFaceIndex: number;
  29865. protected _currentFaceIndexCache: number;
  29866. protected _textureType: number;
  29867. protected _defaultTextureMatrix: Matrix;
  29868. protected _storedUniqueId: Nullable<number>;
  29869. protected _nameForCustomEffect: string;
  29870. /** @hidden */
  29871. static _SceneComponentInitialization: (scene: Scene) => void;
  29872. /**
  29873. * Gets or sets the size of the texture what stores the shadows
  29874. */
  29875. get mapSize(): number;
  29876. set mapSize(size: number);
  29877. /**
  29878. * Creates a ShadowGenerator object.
  29879. * A ShadowGenerator is the required tool to use the shadows.
  29880. * Each light casting shadows needs to use its own ShadowGenerator.
  29881. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29882. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29883. * @param light The light object generating the shadows.
  29884. * @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.
  29885. */
  29886. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29887. protected _initializeGenerator(): void;
  29888. protected _createTargetRenderTexture(): void;
  29889. protected _initializeShadowMap(): void;
  29890. protected _initializeBlurRTTAndPostProcesses(): void;
  29891. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29892. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29893. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29894. protected _applyFilterValues(): void;
  29895. /**
  29896. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29897. * @param onCompiled Callback triggered at the and of the effects compilation
  29898. * @param options Sets of optional options forcing the compilation with different modes
  29899. */
  29900. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29901. useInstances: boolean;
  29902. }>): void;
  29903. /**
  29904. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29905. * @param options Sets of optional options forcing the compilation with different modes
  29906. * @returns A promise that resolves when the compilation completes
  29907. */
  29908. forceCompilationAsync(options?: Partial<{
  29909. useInstances: boolean;
  29910. }>): Promise<void>;
  29911. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29912. private _prepareShadowDefines;
  29913. /**
  29914. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29915. * @param subMesh The submesh we want to render in the shadow map
  29916. * @param useInstances Defines wether will draw in the map using instances
  29917. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29918. * @returns true if ready otherwise, false
  29919. */
  29920. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29921. /**
  29922. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29923. * @param defines Defines of the material we want to update
  29924. * @param lightIndex Index of the light in the enabled light list of the material
  29925. */
  29926. prepareDefines(defines: any, lightIndex: number): void;
  29927. /**
  29928. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29929. * defined in the generator but impacting the effect).
  29930. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29931. * @param effect The effect we are binfing the information for
  29932. */
  29933. bindShadowLight(lightIndex: string, effect: Effect): void;
  29934. /**
  29935. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29936. * (eq to shadow prjection matrix * light transform matrix)
  29937. * @returns The transform matrix used to create the shadow map
  29938. */
  29939. getTransformMatrix(): Matrix;
  29940. /**
  29941. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29942. * Cube and 2D textures for instance.
  29943. */
  29944. recreateShadowMap(): void;
  29945. protected _disposeBlurPostProcesses(): void;
  29946. protected _disposeRTTandPostProcesses(): void;
  29947. /**
  29948. * Disposes the ShadowGenerator.
  29949. * Returns nothing.
  29950. */
  29951. dispose(): void;
  29952. /**
  29953. * Serializes the shadow generator setup to a json object.
  29954. * @returns The serialized JSON object
  29955. */
  29956. serialize(): any;
  29957. /**
  29958. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29959. * @param parsedShadowGenerator The JSON object to parse
  29960. * @param scene The scene to create the shadow map for
  29961. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29962. * @returns The parsed shadow generator
  29963. */
  29964. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29965. }
  29966. }
  29967. declare module BABYLON {
  29968. /**
  29969. * Options to be used when creating a shadow depth material
  29970. */
  29971. export interface IIOptionShadowDepthMaterial {
  29972. /** Variables in the vertex shader code that need to have their names remapped.
  29973. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29974. * "var_name" should be either: worldPos or vNormalW
  29975. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29976. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29977. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29978. */
  29979. remappedVariables?: string[];
  29980. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29981. standalone?: boolean;
  29982. }
  29983. /**
  29984. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29985. */
  29986. export class ShadowDepthWrapper {
  29987. private _scene;
  29988. private _options?;
  29989. private _baseMaterial;
  29990. private _onEffectCreatedObserver;
  29991. private _subMeshToEffect;
  29992. private _subMeshToDepthEffect;
  29993. private _meshes;
  29994. /** @hidden */
  29995. _matriceNames: any;
  29996. /** Gets the standalone status of the wrapper */
  29997. get standalone(): boolean;
  29998. /** Gets the base material the wrapper is built upon */
  29999. get baseMaterial(): Material;
  30000. /**
  30001. * Instantiate a new shadow depth wrapper.
  30002. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30003. * generate the shadow depth map. For more information, please refer to the documentation:
  30004. * https://doc.babylonjs.com/babylon101/shadows
  30005. * @param baseMaterial Material to wrap
  30006. * @param scene Define the scene the material belongs to
  30007. * @param options Options used to create the wrapper
  30008. */
  30009. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30010. /**
  30011. * Gets the effect to use to generate the depth map
  30012. * @param subMesh subMesh to get the effect for
  30013. * @param shadowGenerator shadow generator to get the effect for
  30014. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30015. */
  30016. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30017. /**
  30018. * Specifies that the submesh is ready to be used for depth rendering
  30019. * @param subMesh submesh to check
  30020. * @param defines the list of defines to take into account when checking the effect
  30021. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30022. * @param useInstances specifies that instances should be used
  30023. * @returns a boolean indicating that the submesh is ready or not
  30024. */
  30025. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30026. /**
  30027. * Disposes the resources
  30028. */
  30029. dispose(): void;
  30030. private _makeEffect;
  30031. }
  30032. }
  30033. declare module BABYLON {
  30034. /**
  30035. * Options for compiling materials.
  30036. */
  30037. export interface IMaterialCompilationOptions {
  30038. /**
  30039. * Defines whether clip planes are enabled.
  30040. */
  30041. clipPlane: boolean;
  30042. /**
  30043. * Defines whether instances are enabled.
  30044. */
  30045. useInstances: boolean;
  30046. }
  30047. /**
  30048. * Options passed when calling customShaderNameResolve
  30049. */
  30050. export interface ICustomShaderNameResolveOptions {
  30051. /**
  30052. * 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
  30053. */
  30054. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30055. }
  30056. /**
  30057. * Base class for the main features of a material in Babylon.js
  30058. */
  30059. export class Material implements IAnimatable {
  30060. /**
  30061. * Returns the triangle fill mode
  30062. */
  30063. static readonly TriangleFillMode: number;
  30064. /**
  30065. * Returns the wireframe mode
  30066. */
  30067. static readonly WireFrameFillMode: number;
  30068. /**
  30069. * Returns the point fill mode
  30070. */
  30071. static readonly PointFillMode: number;
  30072. /**
  30073. * Returns the point list draw mode
  30074. */
  30075. static readonly PointListDrawMode: number;
  30076. /**
  30077. * Returns the line list draw mode
  30078. */
  30079. static readonly LineListDrawMode: number;
  30080. /**
  30081. * Returns the line loop draw mode
  30082. */
  30083. static readonly LineLoopDrawMode: number;
  30084. /**
  30085. * Returns the line strip draw mode
  30086. */
  30087. static readonly LineStripDrawMode: number;
  30088. /**
  30089. * Returns the triangle strip draw mode
  30090. */
  30091. static readonly TriangleStripDrawMode: number;
  30092. /**
  30093. * Returns the triangle fan draw mode
  30094. */
  30095. static readonly TriangleFanDrawMode: number;
  30096. /**
  30097. * Stores the clock-wise side orientation
  30098. */
  30099. static readonly ClockWiseSideOrientation: number;
  30100. /**
  30101. * Stores the counter clock-wise side orientation
  30102. */
  30103. static readonly CounterClockWiseSideOrientation: number;
  30104. /**
  30105. * The dirty texture flag value
  30106. */
  30107. static readonly TextureDirtyFlag: number;
  30108. /**
  30109. * The dirty light flag value
  30110. */
  30111. static readonly LightDirtyFlag: number;
  30112. /**
  30113. * The dirty fresnel flag value
  30114. */
  30115. static readonly FresnelDirtyFlag: number;
  30116. /**
  30117. * The dirty attribute flag value
  30118. */
  30119. static readonly AttributesDirtyFlag: number;
  30120. /**
  30121. * The dirty misc flag value
  30122. */
  30123. static readonly MiscDirtyFlag: number;
  30124. /**
  30125. * The dirty prepass flag value
  30126. */
  30127. static readonly PrePassDirtyFlag: number;
  30128. /**
  30129. * The all dirty flag value
  30130. */
  30131. static readonly AllDirtyFlag: number;
  30132. /**
  30133. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30134. */
  30135. static readonly MATERIAL_OPAQUE: number;
  30136. /**
  30137. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30138. */
  30139. static readonly MATERIAL_ALPHATEST: number;
  30140. /**
  30141. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30142. */
  30143. static readonly MATERIAL_ALPHABLEND: number;
  30144. /**
  30145. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30146. * They are also discarded below the alpha cutoff threshold to improve performances.
  30147. */
  30148. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30149. /**
  30150. * The Whiteout method is used to blend normals.
  30151. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30152. */
  30153. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30154. /**
  30155. * The Reoriented Normal Mapping method is used to blend normals.
  30156. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30157. */
  30158. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30159. /**
  30160. * Custom callback helping to override the default shader used in the material.
  30161. */
  30162. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30163. /**
  30164. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30165. */
  30166. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30167. /**
  30168. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30169. * This means that the material can keep using a previous shader while a new one is being compiled.
  30170. * This is mostly used when shader parallel compilation is supported (true by default)
  30171. */
  30172. allowShaderHotSwapping: boolean;
  30173. /**
  30174. * The ID of the material
  30175. */
  30176. id: string;
  30177. /**
  30178. * Gets or sets the unique id of the material
  30179. */
  30180. uniqueId: number;
  30181. /**
  30182. * The name of the material
  30183. */
  30184. name: string;
  30185. /**
  30186. * Gets or sets user defined metadata
  30187. */
  30188. metadata: any;
  30189. /**
  30190. * For internal use only. Please do not use.
  30191. */
  30192. reservedDataStore: any;
  30193. /**
  30194. * Specifies if the ready state should be checked on each call
  30195. */
  30196. checkReadyOnEveryCall: boolean;
  30197. /**
  30198. * Specifies if the ready state should be checked once
  30199. */
  30200. checkReadyOnlyOnce: boolean;
  30201. /**
  30202. * The state of the material
  30203. */
  30204. state: string;
  30205. /**
  30206. * If the material can be rendered to several textures with MRT extension
  30207. */
  30208. get canRenderToMRT(): boolean;
  30209. /**
  30210. * The alpha value of the material
  30211. */
  30212. protected _alpha: number;
  30213. /**
  30214. * List of inspectable custom properties (used by the Inspector)
  30215. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30216. */
  30217. inspectableCustomProperties: IInspectable[];
  30218. /**
  30219. * Sets the alpha value of the material
  30220. */
  30221. set alpha(value: number);
  30222. /**
  30223. * Gets the alpha value of the material
  30224. */
  30225. get alpha(): number;
  30226. /**
  30227. * Specifies if back face culling is enabled
  30228. */
  30229. protected _backFaceCulling: boolean;
  30230. /**
  30231. * Sets the back-face culling state
  30232. */
  30233. set backFaceCulling(value: boolean);
  30234. /**
  30235. * Gets the back-face culling state
  30236. */
  30237. get backFaceCulling(): boolean;
  30238. /**
  30239. * Stores the value for side orientation
  30240. */
  30241. sideOrientation: number;
  30242. /**
  30243. * Callback triggered when the material is compiled
  30244. */
  30245. onCompiled: Nullable<(effect: Effect) => void>;
  30246. /**
  30247. * Callback triggered when an error occurs
  30248. */
  30249. onError: Nullable<(effect: Effect, errors: string) => void>;
  30250. /**
  30251. * Callback triggered to get the render target textures
  30252. */
  30253. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30254. /**
  30255. * Gets a boolean indicating that current material needs to register RTT
  30256. */
  30257. get hasRenderTargetTextures(): boolean;
  30258. /**
  30259. * Specifies if the material should be serialized
  30260. */
  30261. doNotSerialize: boolean;
  30262. /**
  30263. * @hidden
  30264. */
  30265. _storeEffectOnSubMeshes: boolean;
  30266. /**
  30267. * Stores the animations for the material
  30268. */
  30269. animations: Nullable<Array<Animation>>;
  30270. /**
  30271. * An event triggered when the material is disposed
  30272. */
  30273. onDisposeObservable: Observable<Material>;
  30274. /**
  30275. * An observer which watches for dispose events
  30276. */
  30277. private _onDisposeObserver;
  30278. private _onUnBindObservable;
  30279. /**
  30280. * Called during a dispose event
  30281. */
  30282. set onDispose(callback: () => void);
  30283. private _onBindObservable;
  30284. /**
  30285. * An event triggered when the material is bound
  30286. */
  30287. get onBindObservable(): Observable<AbstractMesh>;
  30288. /**
  30289. * An observer which watches for bind events
  30290. */
  30291. private _onBindObserver;
  30292. /**
  30293. * Called during a bind event
  30294. */
  30295. set onBind(callback: (Mesh: AbstractMesh) => void);
  30296. /**
  30297. * An event triggered when the material is unbound
  30298. */
  30299. get onUnBindObservable(): Observable<Material>;
  30300. protected _onEffectCreatedObservable: Nullable<Observable<{
  30301. effect: Effect;
  30302. subMesh: Nullable<SubMesh>;
  30303. }>>;
  30304. /**
  30305. * An event triggered when the effect is (re)created
  30306. */
  30307. get onEffectCreatedObservable(): Observable<{
  30308. effect: Effect;
  30309. subMesh: Nullable<SubMesh>;
  30310. }>;
  30311. /**
  30312. * Stores the value of the alpha mode
  30313. */
  30314. private _alphaMode;
  30315. /**
  30316. * Sets the value of the alpha mode.
  30317. *
  30318. * | Value | Type | Description |
  30319. * | --- | --- | --- |
  30320. * | 0 | ALPHA_DISABLE | |
  30321. * | 1 | ALPHA_ADD | |
  30322. * | 2 | ALPHA_COMBINE | |
  30323. * | 3 | ALPHA_SUBTRACT | |
  30324. * | 4 | ALPHA_MULTIPLY | |
  30325. * | 5 | ALPHA_MAXIMIZED | |
  30326. * | 6 | ALPHA_ONEONE | |
  30327. * | 7 | ALPHA_PREMULTIPLIED | |
  30328. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30329. * | 9 | ALPHA_INTERPOLATE | |
  30330. * | 10 | ALPHA_SCREENMODE | |
  30331. *
  30332. */
  30333. set alphaMode(value: number);
  30334. /**
  30335. * Gets the value of the alpha mode
  30336. */
  30337. get alphaMode(): number;
  30338. /**
  30339. * Stores the state of the need depth pre-pass value
  30340. */
  30341. private _needDepthPrePass;
  30342. /**
  30343. * Sets the need depth pre-pass value
  30344. */
  30345. set needDepthPrePass(value: boolean);
  30346. /**
  30347. * Gets the depth pre-pass value
  30348. */
  30349. get needDepthPrePass(): boolean;
  30350. /**
  30351. * Specifies if depth writing should be disabled
  30352. */
  30353. disableDepthWrite: boolean;
  30354. /**
  30355. * Specifies if color writing should be disabled
  30356. */
  30357. disableColorWrite: boolean;
  30358. /**
  30359. * Specifies if depth writing should be forced
  30360. */
  30361. forceDepthWrite: boolean;
  30362. /**
  30363. * Specifies the depth function that should be used. 0 means the default engine function
  30364. */
  30365. depthFunction: number;
  30366. /**
  30367. * Specifies if there should be a separate pass for culling
  30368. */
  30369. separateCullingPass: boolean;
  30370. /**
  30371. * Stores the state specifing if fog should be enabled
  30372. */
  30373. private _fogEnabled;
  30374. /**
  30375. * Sets the state for enabling fog
  30376. */
  30377. set fogEnabled(value: boolean);
  30378. /**
  30379. * Gets the value of the fog enabled state
  30380. */
  30381. get fogEnabled(): boolean;
  30382. /**
  30383. * Stores the size of points
  30384. */
  30385. pointSize: number;
  30386. /**
  30387. * Stores the z offset value
  30388. */
  30389. zOffset: number;
  30390. get wireframe(): boolean;
  30391. /**
  30392. * Sets the state of wireframe mode
  30393. */
  30394. set wireframe(value: boolean);
  30395. /**
  30396. * Gets the value specifying if point clouds are enabled
  30397. */
  30398. get pointsCloud(): boolean;
  30399. /**
  30400. * Sets the state of point cloud mode
  30401. */
  30402. set pointsCloud(value: boolean);
  30403. /**
  30404. * Gets the material fill mode
  30405. */
  30406. get fillMode(): number;
  30407. /**
  30408. * Sets the material fill mode
  30409. */
  30410. set fillMode(value: number);
  30411. /**
  30412. * @hidden
  30413. * Stores the effects for the material
  30414. */
  30415. _effect: Nullable<Effect>;
  30416. /**
  30417. * Specifies if uniform buffers should be used
  30418. */
  30419. private _useUBO;
  30420. /**
  30421. * Stores a reference to the scene
  30422. */
  30423. private _scene;
  30424. private _needToBindSceneUbo;
  30425. /**
  30426. * Stores the fill mode state
  30427. */
  30428. private _fillMode;
  30429. /**
  30430. * Specifies if the depth write state should be cached
  30431. */
  30432. private _cachedDepthWriteState;
  30433. /**
  30434. * Specifies if the color write state should be cached
  30435. */
  30436. private _cachedColorWriteState;
  30437. /**
  30438. * Specifies if the depth function state should be cached
  30439. */
  30440. private _cachedDepthFunctionState;
  30441. /**
  30442. * Stores the uniform buffer
  30443. */
  30444. protected _uniformBuffer: UniformBuffer;
  30445. /** @hidden */
  30446. _indexInSceneMaterialArray: number;
  30447. /** @hidden */
  30448. meshMap: Nullable<{
  30449. [id: string]: AbstractMesh | undefined;
  30450. }>;
  30451. /**
  30452. * Creates a material instance
  30453. * @param name defines the name of the material
  30454. * @param scene defines the scene to reference
  30455. * @param doNotAdd specifies if the material should be added to the scene
  30456. */
  30457. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30458. /**
  30459. * Returns a string representation of the current material
  30460. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30461. * @returns a string with material information
  30462. */
  30463. toString(fullDetails?: boolean): string;
  30464. /**
  30465. * Gets the class name of the material
  30466. * @returns a string with the class name of the material
  30467. */
  30468. getClassName(): string;
  30469. /**
  30470. * Specifies if updates for the material been locked
  30471. */
  30472. get isFrozen(): boolean;
  30473. /**
  30474. * Locks updates for the material
  30475. */
  30476. freeze(): void;
  30477. /**
  30478. * Unlocks updates for the material
  30479. */
  30480. unfreeze(): void;
  30481. /**
  30482. * Specifies if the material is ready to be used
  30483. * @param mesh defines the mesh to check
  30484. * @param useInstances specifies if instances should be used
  30485. * @returns a boolean indicating if the material is ready to be used
  30486. */
  30487. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30488. /**
  30489. * Specifies that the submesh is ready to be used
  30490. * @param mesh defines the mesh to check
  30491. * @param subMesh defines which submesh to check
  30492. * @param useInstances specifies that instances should be used
  30493. * @returns a boolean indicating that the submesh is ready or not
  30494. */
  30495. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30496. /**
  30497. * Returns the material effect
  30498. * @returns the effect associated with the material
  30499. */
  30500. getEffect(): Nullable<Effect>;
  30501. /**
  30502. * Returns the current scene
  30503. * @returns a Scene
  30504. */
  30505. getScene(): Scene;
  30506. /**
  30507. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30508. */
  30509. protected _forceAlphaTest: boolean;
  30510. /**
  30511. * The transparency mode of the material.
  30512. */
  30513. protected _transparencyMode: Nullable<number>;
  30514. /**
  30515. * Gets the current transparency mode.
  30516. */
  30517. get transparencyMode(): Nullable<number>;
  30518. /**
  30519. * Sets the transparency mode of the material.
  30520. *
  30521. * | Value | Type | Description |
  30522. * | ----- | ----------------------------------- | ----------- |
  30523. * | 0 | OPAQUE | |
  30524. * | 1 | ALPHATEST | |
  30525. * | 2 | ALPHABLEND | |
  30526. * | 3 | ALPHATESTANDBLEND | |
  30527. *
  30528. */
  30529. set transparencyMode(value: Nullable<number>);
  30530. /**
  30531. * Returns true if alpha blending should be disabled.
  30532. */
  30533. protected get _disableAlphaBlending(): boolean;
  30534. /**
  30535. * Specifies whether or not this material should be rendered in alpha blend mode.
  30536. * @returns a boolean specifying if alpha blending is needed
  30537. */
  30538. needAlphaBlending(): boolean;
  30539. /**
  30540. * Specifies if the mesh will require alpha blending
  30541. * @param mesh defines the mesh to check
  30542. * @returns a boolean specifying if alpha blending is needed for the mesh
  30543. */
  30544. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30545. /**
  30546. * Specifies whether or not this material should be rendered in alpha test mode.
  30547. * @returns a boolean specifying if an alpha test is needed.
  30548. */
  30549. needAlphaTesting(): boolean;
  30550. /**
  30551. * Specifies if material alpha testing should be turned on for the mesh
  30552. * @param mesh defines the mesh to check
  30553. */
  30554. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30555. /**
  30556. * Gets the texture used for the alpha test
  30557. * @returns the texture to use for alpha testing
  30558. */
  30559. getAlphaTestTexture(): Nullable<BaseTexture>;
  30560. /**
  30561. * Marks the material to indicate that it needs to be re-calculated
  30562. */
  30563. markDirty(): void;
  30564. /** @hidden */
  30565. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30566. /**
  30567. * Binds the material to the mesh
  30568. * @param world defines the world transformation matrix
  30569. * @param mesh defines the mesh to bind the material to
  30570. */
  30571. bind(world: Matrix, mesh?: Mesh): void;
  30572. /**
  30573. * Binds the submesh to the material
  30574. * @param world defines the world transformation matrix
  30575. * @param mesh defines the mesh containing the submesh
  30576. * @param subMesh defines the submesh to bind the material to
  30577. */
  30578. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30579. /**
  30580. * Binds the world matrix to the material
  30581. * @param world defines the world transformation matrix
  30582. */
  30583. bindOnlyWorldMatrix(world: Matrix): void;
  30584. /**
  30585. * Update the scene ubo before it can be used in rendering processing
  30586. * @param scene the scene to retrieve the ubo from
  30587. * @returns the scene UniformBuffer
  30588. */
  30589. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30590. /**
  30591. * Binds the scene's uniform buffer to the effect.
  30592. * @param effect defines the effect to bind to the scene uniform buffer
  30593. * @param sceneUbo defines the uniform buffer storing scene data
  30594. */
  30595. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30596. /**
  30597. * Binds the view matrix to the effect
  30598. * @param effect defines the effect to bind the view matrix to
  30599. */
  30600. bindView(effect: Effect): void;
  30601. /**
  30602. * Binds the view projection and projection matrices to the effect
  30603. * @param effect defines the effect to bind the view projection and projection matrices to
  30604. */
  30605. bindViewProjection(effect: Effect): void;
  30606. /**
  30607. * Binds the view matrix to the effect
  30608. * @param effect defines the effect to bind the view matrix to
  30609. * @param variableName name of the shader variable that will hold the eye position
  30610. */
  30611. bindEyePosition(effect: Effect, variableName?: string): void;
  30612. /**
  30613. * Processes to execute after binding the material to a mesh
  30614. * @param mesh defines the rendered mesh
  30615. */
  30616. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30617. /**
  30618. * Unbinds the material from the mesh
  30619. */
  30620. unbind(): void;
  30621. /**
  30622. * Gets the active textures from the material
  30623. * @returns an array of textures
  30624. */
  30625. getActiveTextures(): BaseTexture[];
  30626. /**
  30627. * Specifies if the material uses a texture
  30628. * @param texture defines the texture to check against the material
  30629. * @returns a boolean specifying if the material uses the texture
  30630. */
  30631. hasTexture(texture: BaseTexture): boolean;
  30632. /**
  30633. * Makes a duplicate of the material, and gives it a new name
  30634. * @param name defines the new name for the duplicated material
  30635. * @returns the cloned material
  30636. */
  30637. clone(name: string): Nullable<Material>;
  30638. /**
  30639. * Gets the meshes bound to the material
  30640. * @returns an array of meshes bound to the material
  30641. */
  30642. getBindedMeshes(): AbstractMesh[];
  30643. /**
  30644. * Force shader compilation
  30645. * @param mesh defines the mesh associated with this material
  30646. * @param onCompiled defines a function to execute once the material is compiled
  30647. * @param options defines the options to configure the compilation
  30648. * @param onError defines a function to execute if the material fails compiling
  30649. */
  30650. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30651. /**
  30652. * Force shader compilation
  30653. * @param mesh defines the mesh that will use this material
  30654. * @param options defines additional options for compiling the shaders
  30655. * @returns a promise that resolves when the compilation completes
  30656. */
  30657. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30658. private static readonly _AllDirtyCallBack;
  30659. private static readonly _ImageProcessingDirtyCallBack;
  30660. private static readonly _TextureDirtyCallBack;
  30661. private static readonly _FresnelDirtyCallBack;
  30662. private static readonly _MiscDirtyCallBack;
  30663. private static readonly _PrePassDirtyCallBack;
  30664. private static readonly _LightsDirtyCallBack;
  30665. private static readonly _AttributeDirtyCallBack;
  30666. private static _FresnelAndMiscDirtyCallBack;
  30667. private static _TextureAndMiscDirtyCallBack;
  30668. private static readonly _DirtyCallbackArray;
  30669. private static readonly _RunDirtyCallBacks;
  30670. /**
  30671. * Marks a define in the material to indicate that it needs to be re-computed
  30672. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30673. */
  30674. markAsDirty(flag: number): void;
  30675. /**
  30676. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30677. * @param func defines a function which checks material defines against the submeshes
  30678. */
  30679. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30680. /**
  30681. * Indicates that the scene should check if the rendering now needs a prepass
  30682. */
  30683. protected _markScenePrePassDirty(): void;
  30684. /**
  30685. * Indicates that we need to re-calculated for all submeshes
  30686. */
  30687. protected _markAllSubMeshesAsAllDirty(): void;
  30688. /**
  30689. * Indicates that image processing needs to be re-calculated for all submeshes
  30690. */
  30691. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30692. /**
  30693. * Indicates that textures need to be re-calculated for all submeshes
  30694. */
  30695. protected _markAllSubMeshesAsTexturesDirty(): void;
  30696. /**
  30697. * Indicates that fresnel needs to be re-calculated for all submeshes
  30698. */
  30699. protected _markAllSubMeshesAsFresnelDirty(): void;
  30700. /**
  30701. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30702. */
  30703. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30704. /**
  30705. * Indicates that lights need to be re-calculated for all submeshes
  30706. */
  30707. protected _markAllSubMeshesAsLightsDirty(): void;
  30708. /**
  30709. * Indicates that attributes need to be re-calculated for all submeshes
  30710. */
  30711. protected _markAllSubMeshesAsAttributesDirty(): void;
  30712. /**
  30713. * Indicates that misc needs to be re-calculated for all submeshes
  30714. */
  30715. protected _markAllSubMeshesAsMiscDirty(): void;
  30716. /**
  30717. * Indicates that prepass needs to be re-calculated for all submeshes
  30718. */
  30719. protected _markAllSubMeshesAsPrePassDirty(): void;
  30720. /**
  30721. * Indicates that textures and misc need to be re-calculated for all submeshes
  30722. */
  30723. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30724. /**
  30725. * Sets the required values to the prepass renderer.
  30726. * @param prePassRenderer defines the prepass renderer to setup.
  30727. * @returns true if the pre pass is needed.
  30728. */
  30729. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30730. /**
  30731. * Disposes the material
  30732. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30733. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30734. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30735. */
  30736. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30737. /** @hidden */
  30738. private releaseVertexArrayObject;
  30739. /**
  30740. * Serializes this material
  30741. * @returns the serialized material object
  30742. */
  30743. serialize(): any;
  30744. /**
  30745. * Creates a material from parsed material data
  30746. * @param parsedMaterial defines parsed material data
  30747. * @param scene defines the hosting scene
  30748. * @param rootUrl defines the root URL to use to load textures
  30749. * @returns a new material
  30750. */
  30751. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30752. }
  30753. }
  30754. declare module BABYLON {
  30755. /**
  30756. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30757. * separate meshes. This can be use to improve performances.
  30758. * @see https://doc.babylonjs.com/how_to/multi_materials
  30759. */
  30760. export class MultiMaterial extends Material {
  30761. private _subMaterials;
  30762. /**
  30763. * Gets or Sets the list of Materials used within the multi material.
  30764. * They need to be ordered according to the submeshes order in the associated mesh
  30765. */
  30766. get subMaterials(): Nullable<Material>[];
  30767. set subMaterials(value: Nullable<Material>[]);
  30768. /**
  30769. * Function used to align with Node.getChildren()
  30770. * @returns the list of Materials used within the multi material
  30771. */
  30772. getChildren(): Nullable<Material>[];
  30773. /**
  30774. * Instantiates a new Multi Material
  30775. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30776. * separate meshes. This can be use to improve performances.
  30777. * @see https://doc.babylonjs.com/how_to/multi_materials
  30778. * @param name Define the name in the scene
  30779. * @param scene Define the scene the material belongs to
  30780. */
  30781. constructor(name: string, scene: Scene);
  30782. private _hookArray;
  30783. /**
  30784. * Get one of the submaterial by its index in the submaterials array
  30785. * @param index The index to look the sub material at
  30786. * @returns The Material if the index has been defined
  30787. */
  30788. getSubMaterial(index: number): Nullable<Material>;
  30789. /**
  30790. * Get the list of active textures for the whole sub materials list.
  30791. * @returns All the textures that will be used during the rendering
  30792. */
  30793. getActiveTextures(): BaseTexture[];
  30794. /**
  30795. * Specifies if any sub-materials of this multi-material use a given texture.
  30796. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30797. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30798. */
  30799. hasTexture(texture: BaseTexture): boolean;
  30800. /**
  30801. * Gets the current class name of the material e.g. "MultiMaterial"
  30802. * Mainly use in serialization.
  30803. * @returns the class name
  30804. */
  30805. getClassName(): string;
  30806. /**
  30807. * Checks if the material is ready to render the requested sub mesh
  30808. * @param mesh Define the mesh the submesh belongs to
  30809. * @param subMesh Define the sub mesh to look readyness for
  30810. * @param useInstances Define whether or not the material is used with instances
  30811. * @returns true if ready, otherwise false
  30812. */
  30813. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30814. /**
  30815. * Clones the current material and its related sub materials
  30816. * @param name Define the name of the newly cloned material
  30817. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30818. * @returns the cloned material
  30819. */
  30820. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30821. /**
  30822. * Serializes the materials into a JSON representation.
  30823. * @returns the JSON representation
  30824. */
  30825. serialize(): any;
  30826. /**
  30827. * Dispose the material and release its associated resources
  30828. * @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)
  30829. * @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)
  30830. * @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)
  30831. */
  30832. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30833. /**
  30834. * Creates a MultiMaterial from parsed MultiMaterial data.
  30835. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30836. * @param scene defines the hosting scene
  30837. * @returns a new MultiMaterial
  30838. */
  30839. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30840. }
  30841. }
  30842. declare module BABYLON {
  30843. /** @hidden */
  30844. export interface ICustomEffect {
  30845. effect: Effect;
  30846. defines: string;
  30847. }
  30848. /**
  30849. * Defines a subdivision inside a mesh
  30850. */
  30851. export class SubMesh implements ICullable {
  30852. /** the material index to use */
  30853. materialIndex: number;
  30854. /** vertex index start */
  30855. verticesStart: number;
  30856. /** vertices count */
  30857. verticesCount: number;
  30858. /** index start */
  30859. indexStart: number;
  30860. /** indices count */
  30861. indexCount: number;
  30862. /** @hidden */
  30863. _materialDefines: Nullable<MaterialDefines>;
  30864. /** @hidden */
  30865. _materialEffect: Nullable<Effect>;
  30866. /** @hidden */
  30867. _effectOverride: Nullable<Effect>;
  30868. private _customEffects;
  30869. /**
  30870. * Gets material defines used by the effect associated to the sub mesh
  30871. */
  30872. get materialDefines(): Nullable<MaterialDefines>;
  30873. /**
  30874. * Sets material defines used by the effect associated to the sub mesh
  30875. */
  30876. set materialDefines(defines: Nullable<MaterialDefines>);
  30877. /** @hidden */
  30878. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30879. /** @hidden */
  30880. _removeCustomEffect(name: string): void;
  30881. /**
  30882. * Gets associated effect
  30883. */
  30884. get effect(): Nullable<Effect>;
  30885. /**
  30886. * Sets associated effect (effect used to render this submesh)
  30887. * @param effect defines the effect to associate with
  30888. * @param defines defines the set of defines used to compile this effect
  30889. */
  30890. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30891. /** @hidden */
  30892. _linesIndexCount: number;
  30893. private _mesh;
  30894. private _renderingMesh;
  30895. private _boundingInfo;
  30896. private _linesIndexBuffer;
  30897. /** @hidden */
  30898. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30899. /** @hidden */
  30900. _trianglePlanes: Plane[];
  30901. /** @hidden */
  30902. _lastColliderTransformMatrix: Nullable<Matrix>;
  30903. /** @hidden */
  30904. _renderId: number;
  30905. /** @hidden */
  30906. _alphaIndex: number;
  30907. /** @hidden */
  30908. _distanceToCamera: number;
  30909. /** @hidden */
  30910. _id: number;
  30911. private _currentMaterial;
  30912. /**
  30913. * Add a new submesh to a mesh
  30914. * @param materialIndex defines the material index to use
  30915. * @param verticesStart defines vertex index start
  30916. * @param verticesCount defines vertices count
  30917. * @param indexStart defines index start
  30918. * @param indexCount defines indices count
  30919. * @param mesh defines the parent mesh
  30920. * @param renderingMesh defines an optional rendering mesh
  30921. * @param createBoundingBox defines if bounding box should be created for this submesh
  30922. * @returns the new submesh
  30923. */
  30924. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30925. /**
  30926. * Creates a new submesh
  30927. * @param materialIndex defines the material index to use
  30928. * @param verticesStart defines vertex index start
  30929. * @param verticesCount defines vertices count
  30930. * @param indexStart defines index start
  30931. * @param indexCount defines indices count
  30932. * @param mesh defines the parent mesh
  30933. * @param renderingMesh defines an optional rendering mesh
  30934. * @param createBoundingBox defines if bounding box should be created for this submesh
  30935. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30936. */
  30937. constructor(
  30938. /** the material index to use */
  30939. materialIndex: number,
  30940. /** vertex index start */
  30941. verticesStart: number,
  30942. /** vertices count */
  30943. verticesCount: number,
  30944. /** index start */
  30945. indexStart: number,
  30946. /** indices count */
  30947. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30948. /**
  30949. * Returns true if this submesh covers the entire parent mesh
  30950. * @ignorenaming
  30951. */
  30952. get IsGlobal(): boolean;
  30953. /**
  30954. * Returns the submesh BoudingInfo object
  30955. * @returns current bounding info (or mesh's one if the submesh is global)
  30956. */
  30957. getBoundingInfo(): BoundingInfo;
  30958. /**
  30959. * Sets the submesh BoundingInfo
  30960. * @param boundingInfo defines the new bounding info to use
  30961. * @returns the SubMesh
  30962. */
  30963. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30964. /**
  30965. * Returns the mesh of the current submesh
  30966. * @return the parent mesh
  30967. */
  30968. getMesh(): AbstractMesh;
  30969. /**
  30970. * Returns the rendering mesh of the submesh
  30971. * @returns the rendering mesh (could be different from parent mesh)
  30972. */
  30973. getRenderingMesh(): Mesh;
  30974. /**
  30975. * Returns the replacement mesh of the submesh
  30976. * @returns the replacement mesh (could be different from parent mesh)
  30977. */
  30978. getReplacementMesh(): Nullable<AbstractMesh>;
  30979. /**
  30980. * Returns the effective mesh of the submesh
  30981. * @returns the effective mesh (could be different from parent mesh)
  30982. */
  30983. getEffectiveMesh(): AbstractMesh;
  30984. /**
  30985. * Returns the submesh material
  30986. * @returns null or the current material
  30987. */
  30988. getMaterial(): Nullable<Material>;
  30989. private _IsMultiMaterial;
  30990. /**
  30991. * Sets a new updated BoundingInfo object to the submesh
  30992. * @param data defines an optional position array to use to determine the bounding info
  30993. * @returns the SubMesh
  30994. */
  30995. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30996. /** @hidden */
  30997. _checkCollision(collider: Collider): boolean;
  30998. /**
  30999. * Updates the submesh BoundingInfo
  31000. * @param world defines the world matrix to use to update the bounding info
  31001. * @returns the submesh
  31002. */
  31003. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31004. /**
  31005. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31006. * @param frustumPlanes defines the frustum planes
  31007. * @returns true if the submesh is intersecting with the frustum
  31008. */
  31009. isInFrustum(frustumPlanes: Plane[]): boolean;
  31010. /**
  31011. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31012. * @param frustumPlanes defines the frustum planes
  31013. * @returns true if the submesh is inside the frustum
  31014. */
  31015. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31016. /**
  31017. * Renders the submesh
  31018. * @param enableAlphaMode defines if alpha needs to be used
  31019. * @returns the submesh
  31020. */
  31021. render(enableAlphaMode: boolean): SubMesh;
  31022. /**
  31023. * @hidden
  31024. */
  31025. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31026. /**
  31027. * Checks if the submesh intersects with a ray
  31028. * @param ray defines the ray to test
  31029. * @returns true is the passed ray intersects the submesh bounding box
  31030. */
  31031. canIntersects(ray: Ray): boolean;
  31032. /**
  31033. * Intersects current submesh with a ray
  31034. * @param ray defines the ray to test
  31035. * @param positions defines mesh's positions array
  31036. * @param indices defines mesh's indices array
  31037. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31038. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31039. * @returns intersection info or null if no intersection
  31040. */
  31041. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31042. /** @hidden */
  31043. private _intersectLines;
  31044. /** @hidden */
  31045. private _intersectUnIndexedLines;
  31046. /** @hidden */
  31047. private _intersectTriangles;
  31048. /** @hidden */
  31049. private _intersectUnIndexedTriangles;
  31050. /** @hidden */
  31051. _rebuild(): void;
  31052. /**
  31053. * Creates a new submesh from the passed mesh
  31054. * @param newMesh defines the new hosting mesh
  31055. * @param newRenderingMesh defines an optional rendering mesh
  31056. * @returns the new submesh
  31057. */
  31058. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31059. /**
  31060. * Release associated resources
  31061. */
  31062. dispose(): void;
  31063. /**
  31064. * Gets the class name
  31065. * @returns the string "SubMesh".
  31066. */
  31067. getClassName(): string;
  31068. /**
  31069. * Creates a new submesh from indices data
  31070. * @param materialIndex the index of the main mesh material
  31071. * @param startIndex the index where to start the copy in the mesh indices array
  31072. * @param indexCount the number of indices to copy then from the startIndex
  31073. * @param mesh the main mesh to create the submesh from
  31074. * @param renderingMesh the optional rendering mesh
  31075. * @returns a new submesh
  31076. */
  31077. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31078. }
  31079. }
  31080. declare module BABYLON {
  31081. /**
  31082. * Class used to represent data loading progression
  31083. */
  31084. export class SceneLoaderFlags {
  31085. private static _ForceFullSceneLoadingForIncremental;
  31086. private static _ShowLoadingScreen;
  31087. private static _CleanBoneMatrixWeights;
  31088. private static _loggingLevel;
  31089. /**
  31090. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31091. */
  31092. static get ForceFullSceneLoadingForIncremental(): boolean;
  31093. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31094. /**
  31095. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31096. */
  31097. static get ShowLoadingScreen(): boolean;
  31098. static set ShowLoadingScreen(value: boolean);
  31099. /**
  31100. * Defines the current logging level (while loading the scene)
  31101. * @ignorenaming
  31102. */
  31103. static get loggingLevel(): number;
  31104. static set loggingLevel(value: number);
  31105. /**
  31106. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31107. */
  31108. static get CleanBoneMatrixWeights(): boolean;
  31109. static set CleanBoneMatrixWeights(value: boolean);
  31110. }
  31111. }
  31112. declare module BABYLON {
  31113. /**
  31114. * Class used to store geometry data (vertex buffers + index buffer)
  31115. */
  31116. export class Geometry implements IGetSetVerticesData {
  31117. /**
  31118. * Gets or sets the ID of the geometry
  31119. */
  31120. id: string;
  31121. /**
  31122. * Gets or sets the unique ID of the geometry
  31123. */
  31124. uniqueId: number;
  31125. /**
  31126. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31127. */
  31128. delayLoadState: number;
  31129. /**
  31130. * Gets the file containing the data to load when running in delay load state
  31131. */
  31132. delayLoadingFile: Nullable<string>;
  31133. /**
  31134. * Callback called when the geometry is updated
  31135. */
  31136. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31137. private _scene;
  31138. private _engine;
  31139. private _meshes;
  31140. private _totalVertices;
  31141. /** @hidden */
  31142. _indices: IndicesArray;
  31143. /** @hidden */
  31144. _vertexBuffers: {
  31145. [key: string]: VertexBuffer;
  31146. };
  31147. private _isDisposed;
  31148. private _extend;
  31149. private _boundingBias;
  31150. /** @hidden */
  31151. _delayInfo: Array<string>;
  31152. private _indexBuffer;
  31153. private _indexBufferIsUpdatable;
  31154. /** @hidden */
  31155. _boundingInfo: Nullable<BoundingInfo>;
  31156. /** @hidden */
  31157. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31158. /** @hidden */
  31159. _softwareSkinningFrameId: number;
  31160. private _vertexArrayObjects;
  31161. private _updatable;
  31162. /** @hidden */
  31163. _positions: Nullable<Vector3[]>;
  31164. private _positionsCache;
  31165. /**
  31166. * 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
  31167. */
  31168. get boundingBias(): Vector2;
  31169. /**
  31170. * 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
  31171. */
  31172. set boundingBias(value: Vector2);
  31173. /**
  31174. * Static function used to attach a new empty geometry to a mesh
  31175. * @param mesh defines the mesh to attach the geometry to
  31176. * @returns the new Geometry
  31177. */
  31178. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31179. /** Get the list of meshes using this geometry */
  31180. get meshes(): Mesh[];
  31181. /**
  31182. * 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
  31183. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31184. */
  31185. useBoundingInfoFromGeometry: boolean;
  31186. /**
  31187. * Creates a new geometry
  31188. * @param id defines the unique ID
  31189. * @param scene defines the hosting scene
  31190. * @param vertexData defines the VertexData used to get geometry data
  31191. * @param updatable defines if geometry must be updatable (false by default)
  31192. * @param mesh defines the mesh that will be associated with the geometry
  31193. */
  31194. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31195. /**
  31196. * Gets the current extend of the geometry
  31197. */
  31198. get extend(): {
  31199. minimum: Vector3;
  31200. maximum: Vector3;
  31201. };
  31202. /**
  31203. * Gets the hosting scene
  31204. * @returns the hosting Scene
  31205. */
  31206. getScene(): Scene;
  31207. /**
  31208. * Gets the hosting engine
  31209. * @returns the hosting Engine
  31210. */
  31211. getEngine(): Engine;
  31212. /**
  31213. * Defines if the geometry is ready to use
  31214. * @returns true if the geometry is ready to be used
  31215. */
  31216. isReady(): boolean;
  31217. /**
  31218. * Gets a value indicating that the geometry should not be serialized
  31219. */
  31220. get doNotSerialize(): boolean;
  31221. /** @hidden */
  31222. _rebuild(): void;
  31223. /**
  31224. * Affects all geometry data in one call
  31225. * @param vertexData defines the geometry data
  31226. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31227. */
  31228. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31229. /**
  31230. * Set specific vertex data
  31231. * @param kind defines the data kind (Position, normal, etc...)
  31232. * @param data defines the vertex data to use
  31233. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31234. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31235. */
  31236. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31237. /**
  31238. * Removes a specific vertex data
  31239. * @param kind defines the data kind (Position, normal, etc...)
  31240. */
  31241. removeVerticesData(kind: string): void;
  31242. /**
  31243. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31244. * @param buffer defines the vertex buffer to use
  31245. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31246. */
  31247. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31248. /**
  31249. * Update a specific vertex buffer
  31250. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31251. * It will do nothing if the buffer is not updatable
  31252. * @param kind defines the data kind (Position, normal, etc...)
  31253. * @param data defines the data to use
  31254. * @param offset defines the offset in the target buffer where to store the data
  31255. * @param useBytes set to true if the offset is in bytes
  31256. */
  31257. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31258. /**
  31259. * Update a specific vertex buffer
  31260. * This function will create a new buffer if the current one is not updatable
  31261. * @param kind defines the data kind (Position, normal, etc...)
  31262. * @param data defines the data to use
  31263. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31264. */
  31265. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31266. private _updateBoundingInfo;
  31267. /** @hidden */
  31268. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31269. [kind: string]: Nullable<VertexBuffer>;
  31270. }, overrideVertexArrayObjects?: {
  31271. [key: string]: WebGLVertexArrayObject;
  31272. }): void;
  31273. /**
  31274. * Gets total number of vertices
  31275. * @returns the total number of vertices
  31276. */
  31277. getTotalVertices(): number;
  31278. /**
  31279. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31280. * @param kind defines the data kind (Position, normal, etc...)
  31281. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31282. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31283. * @returns a float array containing vertex data
  31284. */
  31285. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31286. /**
  31287. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31288. * @param kind defines the data kind (Position, normal, etc...)
  31289. * @returns true if the vertex buffer with the specified kind is updatable
  31290. */
  31291. isVertexBufferUpdatable(kind: string): boolean;
  31292. /**
  31293. * Gets a specific vertex buffer
  31294. * @param kind defines the data kind (Position, normal, etc...)
  31295. * @returns a VertexBuffer
  31296. */
  31297. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31298. /**
  31299. * Returns all vertex buffers
  31300. * @return an object holding all vertex buffers indexed by kind
  31301. */
  31302. getVertexBuffers(): Nullable<{
  31303. [key: string]: VertexBuffer;
  31304. }>;
  31305. /**
  31306. * Gets a boolean indicating if specific vertex buffer is present
  31307. * @param kind defines the data kind (Position, normal, etc...)
  31308. * @returns true if data is present
  31309. */
  31310. isVerticesDataPresent(kind: string): boolean;
  31311. /**
  31312. * Gets a list of all attached data kinds (Position, normal, etc...)
  31313. * @returns a list of string containing all kinds
  31314. */
  31315. getVerticesDataKinds(): string[];
  31316. /**
  31317. * Update index buffer
  31318. * @param indices defines the indices to store in the index buffer
  31319. * @param offset defines the offset in the target buffer where to store the data
  31320. * @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)
  31321. */
  31322. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31323. /**
  31324. * Creates a new index buffer
  31325. * @param indices defines the indices to store in the index buffer
  31326. * @param totalVertices defines the total number of vertices (could be null)
  31327. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31328. */
  31329. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31330. /**
  31331. * Return the total number of indices
  31332. * @returns the total number of indices
  31333. */
  31334. getTotalIndices(): number;
  31335. /**
  31336. * Gets the index buffer array
  31337. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31338. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31339. * @returns the index buffer array
  31340. */
  31341. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31342. /**
  31343. * Gets the index buffer
  31344. * @return the index buffer
  31345. */
  31346. getIndexBuffer(): Nullable<DataBuffer>;
  31347. /** @hidden */
  31348. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31349. /**
  31350. * Release the associated resources for a specific mesh
  31351. * @param mesh defines the source mesh
  31352. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31353. */
  31354. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31355. /**
  31356. * Apply current geometry to a given mesh
  31357. * @param mesh defines the mesh to apply geometry to
  31358. */
  31359. applyToMesh(mesh: Mesh): void;
  31360. private _updateExtend;
  31361. private _applyToMesh;
  31362. private notifyUpdate;
  31363. /**
  31364. * Load the geometry if it was flagged as delay loaded
  31365. * @param scene defines the hosting scene
  31366. * @param onLoaded defines a callback called when the geometry is loaded
  31367. */
  31368. load(scene: Scene, onLoaded?: () => void): void;
  31369. private _queueLoad;
  31370. /**
  31371. * Invert the geometry to move from a right handed system to a left handed one.
  31372. */
  31373. toLeftHanded(): void;
  31374. /** @hidden */
  31375. _resetPointsArrayCache(): void;
  31376. /** @hidden */
  31377. _generatePointsArray(): boolean;
  31378. /**
  31379. * Gets a value indicating if the geometry is disposed
  31380. * @returns true if the geometry was disposed
  31381. */
  31382. isDisposed(): boolean;
  31383. private _disposeVertexArrayObjects;
  31384. /**
  31385. * Free all associated resources
  31386. */
  31387. dispose(): void;
  31388. /**
  31389. * Clone the current geometry into a new geometry
  31390. * @param id defines the unique ID of the new geometry
  31391. * @returns a new geometry object
  31392. */
  31393. copy(id: string): Geometry;
  31394. /**
  31395. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31396. * @return a JSON representation of the current geometry data (without the vertices data)
  31397. */
  31398. serialize(): any;
  31399. private toNumberArray;
  31400. /**
  31401. * Serialize all vertices data into a JSON oject
  31402. * @returns a JSON representation of the current geometry data
  31403. */
  31404. serializeVerticeData(): any;
  31405. /**
  31406. * Extracts a clone of a mesh geometry
  31407. * @param mesh defines the source mesh
  31408. * @param id defines the unique ID of the new geometry object
  31409. * @returns the new geometry object
  31410. */
  31411. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31412. /**
  31413. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31414. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31415. * Be aware Math.random() could cause collisions, but:
  31416. * "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"
  31417. * @returns a string containing a new GUID
  31418. */
  31419. static RandomId(): string;
  31420. /** @hidden */
  31421. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31422. private static _CleanMatricesWeights;
  31423. /**
  31424. * Create a new geometry from persisted data (Using .babylon file format)
  31425. * @param parsedVertexData defines the persisted data
  31426. * @param scene defines the hosting scene
  31427. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31428. * @returns the new geometry object
  31429. */
  31430. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31431. }
  31432. }
  31433. declare module BABYLON {
  31434. /**
  31435. * Defines a target to use with MorphTargetManager
  31436. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31437. */
  31438. export class MorphTarget implements IAnimatable {
  31439. /** defines the name of the target */
  31440. name: string;
  31441. /**
  31442. * Gets or sets the list of animations
  31443. */
  31444. animations: Animation[];
  31445. private _scene;
  31446. private _positions;
  31447. private _normals;
  31448. private _tangents;
  31449. private _uvs;
  31450. private _influence;
  31451. private _uniqueId;
  31452. /**
  31453. * Observable raised when the influence changes
  31454. */
  31455. onInfluenceChanged: Observable<boolean>;
  31456. /** @hidden */
  31457. _onDataLayoutChanged: Observable<void>;
  31458. /**
  31459. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31460. */
  31461. get influence(): number;
  31462. set influence(influence: number);
  31463. /**
  31464. * Gets or sets the id of the morph Target
  31465. */
  31466. id: string;
  31467. private _animationPropertiesOverride;
  31468. /**
  31469. * Gets or sets the animation properties override
  31470. */
  31471. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31472. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31473. /**
  31474. * Creates a new MorphTarget
  31475. * @param name defines the name of the target
  31476. * @param influence defines the influence to use
  31477. * @param scene defines the scene the morphtarget belongs to
  31478. */
  31479. constructor(
  31480. /** defines the name of the target */
  31481. name: string, influence?: number, scene?: Nullable<Scene>);
  31482. /**
  31483. * Gets the unique ID of this manager
  31484. */
  31485. get uniqueId(): number;
  31486. /**
  31487. * Gets a boolean defining if the target contains position data
  31488. */
  31489. get hasPositions(): boolean;
  31490. /**
  31491. * Gets a boolean defining if the target contains normal data
  31492. */
  31493. get hasNormals(): boolean;
  31494. /**
  31495. * Gets a boolean defining if the target contains tangent data
  31496. */
  31497. get hasTangents(): boolean;
  31498. /**
  31499. * Gets a boolean defining if the target contains texture coordinates data
  31500. */
  31501. get hasUVs(): boolean;
  31502. /**
  31503. * Affects position data to this target
  31504. * @param data defines the position data to use
  31505. */
  31506. setPositions(data: Nullable<FloatArray>): void;
  31507. /**
  31508. * Gets the position data stored in this target
  31509. * @returns a FloatArray containing the position data (or null if not present)
  31510. */
  31511. getPositions(): Nullable<FloatArray>;
  31512. /**
  31513. * Affects normal data to this target
  31514. * @param data defines the normal data to use
  31515. */
  31516. setNormals(data: Nullable<FloatArray>): void;
  31517. /**
  31518. * Gets the normal data stored in this target
  31519. * @returns a FloatArray containing the normal data (or null if not present)
  31520. */
  31521. getNormals(): Nullable<FloatArray>;
  31522. /**
  31523. * Affects tangent data to this target
  31524. * @param data defines the tangent data to use
  31525. */
  31526. setTangents(data: Nullable<FloatArray>): void;
  31527. /**
  31528. * Gets the tangent data stored in this target
  31529. * @returns a FloatArray containing the tangent data (or null if not present)
  31530. */
  31531. getTangents(): Nullable<FloatArray>;
  31532. /**
  31533. * Affects texture coordinates data to this target
  31534. * @param data defines the texture coordinates data to use
  31535. */
  31536. setUVs(data: Nullable<FloatArray>): void;
  31537. /**
  31538. * Gets the texture coordinates data stored in this target
  31539. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31540. */
  31541. getUVs(): Nullable<FloatArray>;
  31542. /**
  31543. * Clone the current target
  31544. * @returns a new MorphTarget
  31545. */
  31546. clone(): MorphTarget;
  31547. /**
  31548. * Serializes the current target into a Serialization object
  31549. * @returns the serialized object
  31550. */
  31551. serialize(): any;
  31552. /**
  31553. * Returns the string "MorphTarget"
  31554. * @returns "MorphTarget"
  31555. */
  31556. getClassName(): string;
  31557. /**
  31558. * Creates a new target from serialized data
  31559. * @param serializationObject defines the serialized data to use
  31560. * @returns a new MorphTarget
  31561. */
  31562. static Parse(serializationObject: any): MorphTarget;
  31563. /**
  31564. * Creates a MorphTarget from mesh data
  31565. * @param mesh defines the source mesh
  31566. * @param name defines the name to use for the new target
  31567. * @param influence defines the influence to attach to the target
  31568. * @returns a new MorphTarget
  31569. */
  31570. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31571. }
  31572. }
  31573. declare module BABYLON {
  31574. /**
  31575. * This class is used to deform meshes using morphing between different targets
  31576. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31577. */
  31578. export class MorphTargetManager {
  31579. private _targets;
  31580. private _targetInfluenceChangedObservers;
  31581. private _targetDataLayoutChangedObservers;
  31582. private _activeTargets;
  31583. private _scene;
  31584. private _influences;
  31585. private _supportsNormals;
  31586. private _supportsTangents;
  31587. private _supportsUVs;
  31588. private _vertexCount;
  31589. private _uniqueId;
  31590. private _tempInfluences;
  31591. /**
  31592. * Gets or sets a boolean indicating if normals must be morphed
  31593. */
  31594. enableNormalMorphing: boolean;
  31595. /**
  31596. * Gets or sets a boolean indicating if tangents must be morphed
  31597. */
  31598. enableTangentMorphing: boolean;
  31599. /**
  31600. * Gets or sets a boolean indicating if UV must be morphed
  31601. */
  31602. enableUVMorphing: boolean;
  31603. /**
  31604. * Creates a new MorphTargetManager
  31605. * @param scene defines the current scene
  31606. */
  31607. constructor(scene?: Nullable<Scene>);
  31608. /**
  31609. * Gets the unique ID of this manager
  31610. */
  31611. get uniqueId(): number;
  31612. /**
  31613. * Gets the number of vertices handled by this manager
  31614. */
  31615. get vertexCount(): number;
  31616. /**
  31617. * Gets a boolean indicating if this manager supports morphing of normals
  31618. */
  31619. get supportsNormals(): boolean;
  31620. /**
  31621. * Gets a boolean indicating if this manager supports morphing of tangents
  31622. */
  31623. get supportsTangents(): boolean;
  31624. /**
  31625. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31626. */
  31627. get supportsUVs(): boolean;
  31628. /**
  31629. * Gets the number of targets stored in this manager
  31630. */
  31631. get numTargets(): number;
  31632. /**
  31633. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31634. */
  31635. get numInfluencers(): number;
  31636. /**
  31637. * Gets the list of influences (one per target)
  31638. */
  31639. get influences(): Float32Array;
  31640. /**
  31641. * Gets the active target at specified index. An active target is a target with an influence > 0
  31642. * @param index defines the index to check
  31643. * @returns the requested target
  31644. */
  31645. getActiveTarget(index: number): MorphTarget;
  31646. /**
  31647. * Gets the target at specified index
  31648. * @param index defines the index to check
  31649. * @returns the requested target
  31650. */
  31651. getTarget(index: number): MorphTarget;
  31652. /**
  31653. * Add a new target to this manager
  31654. * @param target defines the target to add
  31655. */
  31656. addTarget(target: MorphTarget): void;
  31657. /**
  31658. * Removes a target from the manager
  31659. * @param target defines the target to remove
  31660. */
  31661. removeTarget(target: MorphTarget): void;
  31662. /**
  31663. * Clone the current manager
  31664. * @returns a new MorphTargetManager
  31665. */
  31666. clone(): MorphTargetManager;
  31667. /**
  31668. * Serializes the current manager into a Serialization object
  31669. * @returns the serialized object
  31670. */
  31671. serialize(): any;
  31672. private _syncActiveTargets;
  31673. /**
  31674. * Syncrhonize the targets with all the meshes using this morph target manager
  31675. */
  31676. synchronize(): void;
  31677. /**
  31678. * Creates a new MorphTargetManager from serialized data
  31679. * @param serializationObject defines the serialized data
  31680. * @param scene defines the hosting scene
  31681. * @returns the new MorphTargetManager
  31682. */
  31683. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31684. }
  31685. }
  31686. declare module BABYLON {
  31687. /**
  31688. * Class used to represent a specific level of detail of a mesh
  31689. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31690. */
  31691. export class MeshLODLevel {
  31692. /** Defines the distance where this level should start being displayed */
  31693. distance: number;
  31694. /** Defines the mesh to use to render this level */
  31695. mesh: Nullable<Mesh>;
  31696. /**
  31697. * Creates a new LOD level
  31698. * @param distance defines the distance where this level should star being displayed
  31699. * @param mesh defines the mesh to use to render this level
  31700. */
  31701. constructor(
  31702. /** Defines the distance where this level should start being displayed */
  31703. distance: number,
  31704. /** Defines the mesh to use to render this level */
  31705. mesh: Nullable<Mesh>);
  31706. }
  31707. }
  31708. declare module BABYLON {
  31709. /**
  31710. * Helper class used to generate a canvas to manipulate images
  31711. */
  31712. export class CanvasGenerator {
  31713. /**
  31714. * Create a new canvas (or offscreen canvas depending on the context)
  31715. * @param width defines the expected width
  31716. * @param height defines the expected height
  31717. * @return a new canvas or offscreen canvas
  31718. */
  31719. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31720. }
  31721. }
  31722. declare module BABYLON {
  31723. /**
  31724. * Mesh representing the gorund
  31725. */
  31726. export class GroundMesh extends Mesh {
  31727. /** If octree should be generated */
  31728. generateOctree: boolean;
  31729. private _heightQuads;
  31730. /** @hidden */
  31731. _subdivisionsX: number;
  31732. /** @hidden */
  31733. _subdivisionsY: number;
  31734. /** @hidden */
  31735. _width: number;
  31736. /** @hidden */
  31737. _height: number;
  31738. /** @hidden */
  31739. _minX: number;
  31740. /** @hidden */
  31741. _maxX: number;
  31742. /** @hidden */
  31743. _minZ: number;
  31744. /** @hidden */
  31745. _maxZ: number;
  31746. constructor(name: string, scene: Scene);
  31747. /**
  31748. * "GroundMesh"
  31749. * @returns "GroundMesh"
  31750. */
  31751. getClassName(): string;
  31752. /**
  31753. * The minimum of x and y subdivisions
  31754. */
  31755. get subdivisions(): number;
  31756. /**
  31757. * X subdivisions
  31758. */
  31759. get subdivisionsX(): number;
  31760. /**
  31761. * Y subdivisions
  31762. */
  31763. get subdivisionsY(): number;
  31764. /**
  31765. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31766. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31767. * @param chunksCount the number of subdivisions for x and y
  31768. * @param octreeBlocksSize (Default: 32)
  31769. */
  31770. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31771. /**
  31772. * Returns a height (y) value in the Worl system :
  31773. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31774. * @param x x coordinate
  31775. * @param z z coordinate
  31776. * @returns the ground y position if (x, z) are outside the ground surface.
  31777. */
  31778. getHeightAtCoordinates(x: number, z: number): number;
  31779. /**
  31780. * Returns a normalized vector (Vector3) orthogonal to the ground
  31781. * at the ground coordinates (x, z) expressed in the World system.
  31782. * @param x x coordinate
  31783. * @param z z coordinate
  31784. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31785. */
  31786. getNormalAtCoordinates(x: number, z: number): Vector3;
  31787. /**
  31788. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31789. * at the ground coordinates (x, z) expressed in the World system.
  31790. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31791. * @param x x coordinate
  31792. * @param z z coordinate
  31793. * @param ref vector to store the result
  31794. * @returns the GroundMesh.
  31795. */
  31796. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31797. /**
  31798. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31799. * if the ground has been updated.
  31800. * This can be used in the render loop.
  31801. * @returns the GroundMesh.
  31802. */
  31803. updateCoordinateHeights(): GroundMesh;
  31804. private _getFacetAt;
  31805. private _initHeightQuads;
  31806. private _computeHeightQuads;
  31807. /**
  31808. * Serializes this ground mesh
  31809. * @param serializationObject object to write serialization to
  31810. */
  31811. serialize(serializationObject: any): void;
  31812. /**
  31813. * Parses a serialized ground mesh
  31814. * @param parsedMesh the serialized mesh
  31815. * @param scene the scene to create the ground mesh in
  31816. * @returns the created ground mesh
  31817. */
  31818. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31819. }
  31820. }
  31821. declare module BABYLON {
  31822. /**
  31823. * Interface for Physics-Joint data
  31824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31825. */
  31826. export interface PhysicsJointData {
  31827. /**
  31828. * The main pivot of the joint
  31829. */
  31830. mainPivot?: Vector3;
  31831. /**
  31832. * The connected pivot of the joint
  31833. */
  31834. connectedPivot?: Vector3;
  31835. /**
  31836. * The main axis of the joint
  31837. */
  31838. mainAxis?: Vector3;
  31839. /**
  31840. * The connected axis of the joint
  31841. */
  31842. connectedAxis?: Vector3;
  31843. /**
  31844. * The collision of the joint
  31845. */
  31846. collision?: boolean;
  31847. /**
  31848. * Native Oimo/Cannon/Energy data
  31849. */
  31850. nativeParams?: any;
  31851. }
  31852. /**
  31853. * This is a holder class for the physics joint created by the physics plugin
  31854. * It holds a set of functions to control the underlying joint
  31855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31856. */
  31857. export class PhysicsJoint {
  31858. /**
  31859. * The type of the physics joint
  31860. */
  31861. type: number;
  31862. /**
  31863. * The data for the physics joint
  31864. */
  31865. jointData: PhysicsJointData;
  31866. private _physicsJoint;
  31867. protected _physicsPlugin: IPhysicsEnginePlugin;
  31868. /**
  31869. * Initializes the physics joint
  31870. * @param type The type of the physics joint
  31871. * @param jointData The data for the physics joint
  31872. */
  31873. constructor(
  31874. /**
  31875. * The type of the physics joint
  31876. */
  31877. type: number,
  31878. /**
  31879. * The data for the physics joint
  31880. */
  31881. jointData: PhysicsJointData);
  31882. /**
  31883. * Gets the physics joint
  31884. */
  31885. get physicsJoint(): any;
  31886. /**
  31887. * Sets the physics joint
  31888. */
  31889. set physicsJoint(newJoint: any);
  31890. /**
  31891. * Sets the physics plugin
  31892. */
  31893. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31894. /**
  31895. * Execute a function that is physics-plugin specific.
  31896. * @param {Function} func the function that will be executed.
  31897. * It accepts two parameters: the physics world and the physics joint
  31898. */
  31899. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31900. /**
  31901. * Distance-Joint type
  31902. */
  31903. static DistanceJoint: number;
  31904. /**
  31905. * Hinge-Joint type
  31906. */
  31907. static HingeJoint: number;
  31908. /**
  31909. * Ball-and-Socket joint type
  31910. */
  31911. static BallAndSocketJoint: number;
  31912. /**
  31913. * Wheel-Joint type
  31914. */
  31915. static WheelJoint: number;
  31916. /**
  31917. * Slider-Joint type
  31918. */
  31919. static SliderJoint: number;
  31920. /**
  31921. * Prismatic-Joint type
  31922. */
  31923. static PrismaticJoint: number;
  31924. /**
  31925. * Universal-Joint type
  31926. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31927. */
  31928. static UniversalJoint: number;
  31929. /**
  31930. * Hinge-Joint 2 type
  31931. */
  31932. static Hinge2Joint: number;
  31933. /**
  31934. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31935. */
  31936. static PointToPointJoint: number;
  31937. /**
  31938. * Spring-Joint type
  31939. */
  31940. static SpringJoint: number;
  31941. /**
  31942. * Lock-Joint type
  31943. */
  31944. static LockJoint: number;
  31945. }
  31946. /**
  31947. * A class representing a physics distance joint
  31948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31949. */
  31950. export class DistanceJoint extends PhysicsJoint {
  31951. /**
  31952. *
  31953. * @param jointData The data for the Distance-Joint
  31954. */
  31955. constructor(jointData: DistanceJointData);
  31956. /**
  31957. * Update the predefined distance.
  31958. * @param maxDistance The maximum preferred distance
  31959. * @param minDistance The minimum preferred distance
  31960. */
  31961. updateDistance(maxDistance: number, minDistance?: number): void;
  31962. }
  31963. /**
  31964. * Represents a Motor-Enabled Joint
  31965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31966. */
  31967. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31968. /**
  31969. * Initializes the Motor-Enabled Joint
  31970. * @param type The type of the joint
  31971. * @param jointData The physica joint data for the joint
  31972. */
  31973. constructor(type: number, jointData: PhysicsJointData);
  31974. /**
  31975. * Set the motor values.
  31976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31977. * @param force the force to apply
  31978. * @param maxForce max force for this motor.
  31979. */
  31980. setMotor(force?: number, maxForce?: number): void;
  31981. /**
  31982. * Set the motor's limits.
  31983. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31984. * @param upperLimit The upper limit of the motor
  31985. * @param lowerLimit The lower limit of the motor
  31986. */
  31987. setLimit(upperLimit: number, lowerLimit?: number): void;
  31988. }
  31989. /**
  31990. * This class represents a single physics Hinge-Joint
  31991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31992. */
  31993. export class HingeJoint extends MotorEnabledJoint {
  31994. /**
  31995. * Initializes the Hinge-Joint
  31996. * @param jointData The joint data for the Hinge-Joint
  31997. */
  31998. constructor(jointData: PhysicsJointData);
  31999. /**
  32000. * Set the motor values.
  32001. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32002. * @param {number} force the force to apply
  32003. * @param {number} maxForce max force for this motor.
  32004. */
  32005. setMotor(force?: number, maxForce?: number): void;
  32006. /**
  32007. * Set the motor's limits.
  32008. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32009. * @param upperLimit The upper limit of the motor
  32010. * @param lowerLimit The lower limit of the motor
  32011. */
  32012. setLimit(upperLimit: number, lowerLimit?: number): void;
  32013. }
  32014. /**
  32015. * This class represents a dual hinge physics joint (same as wheel joint)
  32016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32017. */
  32018. export class Hinge2Joint extends MotorEnabledJoint {
  32019. /**
  32020. * Initializes the Hinge2-Joint
  32021. * @param jointData The joint data for the Hinge2-Joint
  32022. */
  32023. constructor(jointData: PhysicsJointData);
  32024. /**
  32025. * Set the motor values.
  32026. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32027. * @param {number} targetSpeed the speed the motor is to reach
  32028. * @param {number} maxForce max force for this motor.
  32029. * @param {motorIndex} the motor's index, 0 or 1.
  32030. */
  32031. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32032. /**
  32033. * Set the motor limits.
  32034. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32035. * @param {number} upperLimit the upper limit
  32036. * @param {number} lowerLimit lower limit
  32037. * @param {motorIndex} the motor's index, 0 or 1.
  32038. */
  32039. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32040. }
  32041. /**
  32042. * Interface for a motor enabled joint
  32043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32044. */
  32045. export interface IMotorEnabledJoint {
  32046. /**
  32047. * Physics joint
  32048. */
  32049. physicsJoint: any;
  32050. /**
  32051. * Sets the motor of the motor-enabled joint
  32052. * @param force The force of the motor
  32053. * @param maxForce The maximum force of the motor
  32054. * @param motorIndex The index of the motor
  32055. */
  32056. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32057. /**
  32058. * Sets the limit of the motor
  32059. * @param upperLimit The upper limit of the motor
  32060. * @param lowerLimit The lower limit of the motor
  32061. * @param motorIndex The index of the motor
  32062. */
  32063. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32064. }
  32065. /**
  32066. * Joint data for a Distance-Joint
  32067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32068. */
  32069. export interface DistanceJointData extends PhysicsJointData {
  32070. /**
  32071. * Max distance the 2 joint objects can be apart
  32072. */
  32073. maxDistance: number;
  32074. }
  32075. /**
  32076. * Joint data from a spring joint
  32077. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32078. */
  32079. export interface SpringJointData extends PhysicsJointData {
  32080. /**
  32081. * Length of the spring
  32082. */
  32083. length: number;
  32084. /**
  32085. * Stiffness of the spring
  32086. */
  32087. stiffness: number;
  32088. /**
  32089. * Damping of the spring
  32090. */
  32091. damping: number;
  32092. /** this callback will be called when applying the force to the impostors. */
  32093. forceApplicationCallback: () => void;
  32094. }
  32095. }
  32096. declare module BABYLON {
  32097. /**
  32098. * Holds the data for the raycast result
  32099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32100. */
  32101. export class PhysicsRaycastResult {
  32102. private _hasHit;
  32103. private _hitDistance;
  32104. private _hitNormalWorld;
  32105. private _hitPointWorld;
  32106. private _rayFromWorld;
  32107. private _rayToWorld;
  32108. /**
  32109. * Gets if there was a hit
  32110. */
  32111. get hasHit(): boolean;
  32112. /**
  32113. * Gets the distance from the hit
  32114. */
  32115. get hitDistance(): number;
  32116. /**
  32117. * Gets the hit normal/direction in the world
  32118. */
  32119. get hitNormalWorld(): Vector3;
  32120. /**
  32121. * Gets the hit point in the world
  32122. */
  32123. get hitPointWorld(): Vector3;
  32124. /**
  32125. * Gets the ray "start point" of the ray in the world
  32126. */
  32127. get rayFromWorld(): Vector3;
  32128. /**
  32129. * Gets the ray "end point" of the ray in the world
  32130. */
  32131. get rayToWorld(): Vector3;
  32132. /**
  32133. * Sets the hit data (normal & point in world space)
  32134. * @param hitNormalWorld defines the normal in world space
  32135. * @param hitPointWorld defines the point in world space
  32136. */
  32137. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32138. /**
  32139. * Sets the distance from the start point to the hit point
  32140. * @param distance
  32141. */
  32142. setHitDistance(distance: number): void;
  32143. /**
  32144. * Calculates the distance manually
  32145. */
  32146. calculateHitDistance(): void;
  32147. /**
  32148. * Resets all the values to default
  32149. * @param from The from point on world space
  32150. * @param to The to point on world space
  32151. */
  32152. reset(from?: Vector3, to?: Vector3): void;
  32153. }
  32154. /**
  32155. * Interface for the size containing width and height
  32156. */
  32157. interface IXYZ {
  32158. /**
  32159. * X
  32160. */
  32161. x: number;
  32162. /**
  32163. * Y
  32164. */
  32165. y: number;
  32166. /**
  32167. * Z
  32168. */
  32169. z: number;
  32170. }
  32171. }
  32172. declare module BABYLON {
  32173. /**
  32174. * Interface used to describe a physics joint
  32175. */
  32176. export interface PhysicsImpostorJoint {
  32177. /** Defines the main impostor to which the joint is linked */
  32178. mainImpostor: PhysicsImpostor;
  32179. /** Defines the impostor that is connected to the main impostor using this joint */
  32180. connectedImpostor: PhysicsImpostor;
  32181. /** Defines the joint itself */
  32182. joint: PhysicsJoint;
  32183. }
  32184. /** @hidden */
  32185. export interface IPhysicsEnginePlugin {
  32186. world: any;
  32187. name: string;
  32188. setGravity(gravity: Vector3): void;
  32189. setTimeStep(timeStep: number): void;
  32190. getTimeStep(): number;
  32191. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32192. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32193. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32194. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32195. removePhysicsBody(impostor: PhysicsImpostor): void;
  32196. generateJoint(joint: PhysicsImpostorJoint): void;
  32197. removeJoint(joint: PhysicsImpostorJoint): void;
  32198. isSupported(): boolean;
  32199. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32200. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32201. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32202. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32203. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32204. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32205. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32206. getBodyMass(impostor: PhysicsImpostor): number;
  32207. getBodyFriction(impostor: PhysicsImpostor): number;
  32208. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32209. getBodyRestitution(impostor: PhysicsImpostor): number;
  32210. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32211. getBodyPressure?(impostor: PhysicsImpostor): number;
  32212. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32213. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32214. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32215. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32216. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32217. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32218. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32219. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32220. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32221. sleepBody(impostor: PhysicsImpostor): void;
  32222. wakeUpBody(impostor: PhysicsImpostor): void;
  32223. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32224. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32225. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32226. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32227. getRadius(impostor: PhysicsImpostor): number;
  32228. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32229. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32230. dispose(): void;
  32231. }
  32232. /**
  32233. * Interface used to define a physics engine
  32234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32235. */
  32236. export interface IPhysicsEngine {
  32237. /**
  32238. * Gets the gravity vector used by the simulation
  32239. */
  32240. gravity: Vector3;
  32241. /**
  32242. * Sets the gravity vector used by the simulation
  32243. * @param gravity defines the gravity vector to use
  32244. */
  32245. setGravity(gravity: Vector3): void;
  32246. /**
  32247. * Set the time step of the physics engine.
  32248. * Default is 1/60.
  32249. * To slow it down, enter 1/600 for example.
  32250. * To speed it up, 1/30
  32251. * @param newTimeStep the new timestep to apply to this world.
  32252. */
  32253. setTimeStep(newTimeStep: number): void;
  32254. /**
  32255. * Get the time step of the physics engine.
  32256. * @returns the current time step
  32257. */
  32258. getTimeStep(): number;
  32259. /**
  32260. * Set the sub time step of the physics engine.
  32261. * Default is 0 meaning there is no sub steps
  32262. * To increase physics resolution precision, set a small value (like 1 ms)
  32263. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32264. */
  32265. setSubTimeStep(subTimeStep: number): void;
  32266. /**
  32267. * Get the sub time step of the physics engine.
  32268. * @returns the current sub time step
  32269. */
  32270. getSubTimeStep(): number;
  32271. /**
  32272. * Release all resources
  32273. */
  32274. dispose(): void;
  32275. /**
  32276. * Gets the name of the current physics plugin
  32277. * @returns the name of the plugin
  32278. */
  32279. getPhysicsPluginName(): string;
  32280. /**
  32281. * Adding a new impostor for the impostor tracking.
  32282. * This will be done by the impostor itself.
  32283. * @param impostor the impostor to add
  32284. */
  32285. addImpostor(impostor: PhysicsImpostor): void;
  32286. /**
  32287. * Remove an impostor from the engine.
  32288. * This impostor and its mesh will not longer be updated by the physics engine.
  32289. * @param impostor the impostor to remove
  32290. */
  32291. removeImpostor(impostor: PhysicsImpostor): void;
  32292. /**
  32293. * Add a joint to the physics engine
  32294. * @param mainImpostor defines the main impostor to which the joint is added.
  32295. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32296. * @param joint defines the joint that will connect both impostors.
  32297. */
  32298. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32299. /**
  32300. * Removes a joint from the simulation
  32301. * @param mainImpostor defines the impostor used with the joint
  32302. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32303. * @param joint defines the joint to remove
  32304. */
  32305. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32306. /**
  32307. * Gets the current plugin used to run the simulation
  32308. * @returns current plugin
  32309. */
  32310. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32311. /**
  32312. * Gets the list of physic impostors
  32313. * @returns an array of PhysicsImpostor
  32314. */
  32315. getImpostors(): Array<PhysicsImpostor>;
  32316. /**
  32317. * Gets the impostor for a physics enabled object
  32318. * @param object defines the object impersonated by the impostor
  32319. * @returns the PhysicsImpostor or null if not found
  32320. */
  32321. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32322. /**
  32323. * Gets the impostor for a physics body object
  32324. * @param body defines physics body used by the impostor
  32325. * @returns the PhysicsImpostor or null if not found
  32326. */
  32327. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32328. /**
  32329. * Does a raycast in the physics world
  32330. * @param from when should the ray start?
  32331. * @param to when should the ray end?
  32332. * @returns PhysicsRaycastResult
  32333. */
  32334. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32335. /**
  32336. * Called by the scene. No need to call it.
  32337. * @param delta defines the timespam between frames
  32338. */
  32339. _step(delta: number): void;
  32340. }
  32341. }
  32342. declare module BABYLON {
  32343. /**
  32344. * The interface for the physics imposter parameters
  32345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32346. */
  32347. export interface PhysicsImpostorParameters {
  32348. /**
  32349. * The mass of the physics imposter
  32350. */
  32351. mass: number;
  32352. /**
  32353. * The friction of the physics imposter
  32354. */
  32355. friction?: number;
  32356. /**
  32357. * The coefficient of restitution of the physics imposter
  32358. */
  32359. restitution?: number;
  32360. /**
  32361. * The native options of the physics imposter
  32362. */
  32363. nativeOptions?: any;
  32364. /**
  32365. * Specifies if the parent should be ignored
  32366. */
  32367. ignoreParent?: boolean;
  32368. /**
  32369. * Specifies if bi-directional transformations should be disabled
  32370. */
  32371. disableBidirectionalTransformation?: boolean;
  32372. /**
  32373. * The pressure inside the physics imposter, soft object only
  32374. */
  32375. pressure?: number;
  32376. /**
  32377. * The stiffness the physics imposter, soft object only
  32378. */
  32379. stiffness?: number;
  32380. /**
  32381. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32382. */
  32383. velocityIterations?: number;
  32384. /**
  32385. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32386. */
  32387. positionIterations?: number;
  32388. /**
  32389. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32390. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32391. * Add to fix multiple points
  32392. */
  32393. fixedPoints?: number;
  32394. /**
  32395. * The collision margin around a soft object
  32396. */
  32397. margin?: number;
  32398. /**
  32399. * The collision margin around a soft object
  32400. */
  32401. damping?: number;
  32402. /**
  32403. * The path for a rope based on an extrusion
  32404. */
  32405. path?: any;
  32406. /**
  32407. * The shape of an extrusion used for a rope based on an extrusion
  32408. */
  32409. shape?: any;
  32410. }
  32411. /**
  32412. * Interface for a physics-enabled object
  32413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32414. */
  32415. export interface IPhysicsEnabledObject {
  32416. /**
  32417. * The position of the physics-enabled object
  32418. */
  32419. position: Vector3;
  32420. /**
  32421. * The rotation of the physics-enabled object
  32422. */
  32423. rotationQuaternion: Nullable<Quaternion>;
  32424. /**
  32425. * The scale of the physics-enabled object
  32426. */
  32427. scaling: Vector3;
  32428. /**
  32429. * The rotation of the physics-enabled object
  32430. */
  32431. rotation?: Vector3;
  32432. /**
  32433. * The parent of the physics-enabled object
  32434. */
  32435. parent?: any;
  32436. /**
  32437. * The bounding info of the physics-enabled object
  32438. * @returns The bounding info of the physics-enabled object
  32439. */
  32440. getBoundingInfo(): BoundingInfo;
  32441. /**
  32442. * Computes the world matrix
  32443. * @param force Specifies if the world matrix should be computed by force
  32444. * @returns A world matrix
  32445. */
  32446. computeWorldMatrix(force: boolean): Matrix;
  32447. /**
  32448. * Gets the world matrix
  32449. * @returns A world matrix
  32450. */
  32451. getWorldMatrix?(): Matrix;
  32452. /**
  32453. * Gets the child meshes
  32454. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32455. * @returns An array of abstract meshes
  32456. */
  32457. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32458. /**
  32459. * Gets the vertex data
  32460. * @param kind The type of vertex data
  32461. * @returns A nullable array of numbers, or a float32 array
  32462. */
  32463. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32464. /**
  32465. * Gets the indices from the mesh
  32466. * @returns A nullable array of index arrays
  32467. */
  32468. getIndices?(): Nullable<IndicesArray>;
  32469. /**
  32470. * Gets the scene from the mesh
  32471. * @returns the indices array or null
  32472. */
  32473. getScene?(): Scene;
  32474. /**
  32475. * Gets the absolute position from the mesh
  32476. * @returns the absolute position
  32477. */
  32478. getAbsolutePosition(): Vector3;
  32479. /**
  32480. * Gets the absolute pivot point from the mesh
  32481. * @returns the absolute pivot point
  32482. */
  32483. getAbsolutePivotPoint(): Vector3;
  32484. /**
  32485. * Rotates the mesh
  32486. * @param axis The axis of rotation
  32487. * @param amount The amount of rotation
  32488. * @param space The space of the rotation
  32489. * @returns The rotation transform node
  32490. */
  32491. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32492. /**
  32493. * Translates the mesh
  32494. * @param axis The axis of translation
  32495. * @param distance The distance of translation
  32496. * @param space The space of the translation
  32497. * @returns The transform node
  32498. */
  32499. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32500. /**
  32501. * Sets the absolute position of the mesh
  32502. * @param absolutePosition The absolute position of the mesh
  32503. * @returns The transform node
  32504. */
  32505. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32506. /**
  32507. * Gets the class name of the mesh
  32508. * @returns The class name
  32509. */
  32510. getClassName(): string;
  32511. }
  32512. /**
  32513. * Represents a physics imposter
  32514. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32515. */
  32516. export class PhysicsImpostor {
  32517. /**
  32518. * The physics-enabled object used as the physics imposter
  32519. */
  32520. object: IPhysicsEnabledObject;
  32521. /**
  32522. * The type of the physics imposter
  32523. */
  32524. type: number;
  32525. private _options;
  32526. private _scene?;
  32527. /**
  32528. * The default object size of the imposter
  32529. */
  32530. static DEFAULT_OBJECT_SIZE: Vector3;
  32531. /**
  32532. * The identity quaternion of the imposter
  32533. */
  32534. static IDENTITY_QUATERNION: Quaternion;
  32535. /** @hidden */
  32536. _pluginData: any;
  32537. private _physicsEngine;
  32538. private _physicsBody;
  32539. private _bodyUpdateRequired;
  32540. private _onBeforePhysicsStepCallbacks;
  32541. private _onAfterPhysicsStepCallbacks;
  32542. /** @hidden */
  32543. _onPhysicsCollideCallbacks: Array<{
  32544. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32545. otherImpostors: Array<PhysicsImpostor>;
  32546. }>;
  32547. private _deltaPosition;
  32548. private _deltaRotation;
  32549. private _deltaRotationConjugated;
  32550. /** @hidden */
  32551. _isFromLine: boolean;
  32552. private _parent;
  32553. private _isDisposed;
  32554. private static _tmpVecs;
  32555. private static _tmpQuat;
  32556. /**
  32557. * Specifies if the physics imposter is disposed
  32558. */
  32559. get isDisposed(): boolean;
  32560. /**
  32561. * Gets the mass of the physics imposter
  32562. */
  32563. get mass(): number;
  32564. set mass(value: number);
  32565. /**
  32566. * Gets the coefficient of friction
  32567. */
  32568. get friction(): number;
  32569. /**
  32570. * Sets the coefficient of friction
  32571. */
  32572. set friction(value: number);
  32573. /**
  32574. * Gets the coefficient of restitution
  32575. */
  32576. get restitution(): number;
  32577. /**
  32578. * Sets the coefficient of restitution
  32579. */
  32580. set restitution(value: number);
  32581. /**
  32582. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32583. */
  32584. get pressure(): number;
  32585. /**
  32586. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32587. */
  32588. set pressure(value: number);
  32589. /**
  32590. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32591. */
  32592. get stiffness(): number;
  32593. /**
  32594. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32595. */
  32596. set stiffness(value: number);
  32597. /**
  32598. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32599. */
  32600. get velocityIterations(): number;
  32601. /**
  32602. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32603. */
  32604. set velocityIterations(value: number);
  32605. /**
  32606. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32607. */
  32608. get positionIterations(): number;
  32609. /**
  32610. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32611. */
  32612. set positionIterations(value: number);
  32613. /**
  32614. * The unique id of the physics imposter
  32615. * set by the physics engine when adding this impostor to the array
  32616. */
  32617. uniqueId: number;
  32618. /**
  32619. * @hidden
  32620. */
  32621. soft: boolean;
  32622. /**
  32623. * @hidden
  32624. */
  32625. segments: number;
  32626. private _joints;
  32627. /**
  32628. * Initializes the physics imposter
  32629. * @param object The physics-enabled object used as the physics imposter
  32630. * @param type The type of the physics imposter
  32631. * @param _options The options for the physics imposter
  32632. * @param _scene The Babylon scene
  32633. */
  32634. constructor(
  32635. /**
  32636. * The physics-enabled object used as the physics imposter
  32637. */
  32638. object: IPhysicsEnabledObject,
  32639. /**
  32640. * The type of the physics imposter
  32641. */
  32642. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32643. /**
  32644. * This function will completly initialize this impostor.
  32645. * It will create a new body - but only if this mesh has no parent.
  32646. * If it has, this impostor will not be used other than to define the impostor
  32647. * of the child mesh.
  32648. * @hidden
  32649. */
  32650. _init(): void;
  32651. private _getPhysicsParent;
  32652. /**
  32653. * Should a new body be generated.
  32654. * @returns boolean specifying if body initialization is required
  32655. */
  32656. isBodyInitRequired(): boolean;
  32657. /**
  32658. * Sets the updated scaling
  32659. * @param updated Specifies if the scaling is updated
  32660. */
  32661. setScalingUpdated(): void;
  32662. /**
  32663. * Force a regeneration of this or the parent's impostor's body.
  32664. * Use under cautious - This will remove all joints already implemented.
  32665. */
  32666. forceUpdate(): void;
  32667. /**
  32668. * Gets the body that holds this impostor. Either its own, or its parent.
  32669. */
  32670. get physicsBody(): any;
  32671. /**
  32672. * Get the parent of the physics imposter
  32673. * @returns Physics imposter or null
  32674. */
  32675. get parent(): Nullable<PhysicsImpostor>;
  32676. /**
  32677. * Sets the parent of the physics imposter
  32678. */
  32679. set parent(value: Nullable<PhysicsImpostor>);
  32680. /**
  32681. * Set the physics body. Used mainly by the physics engine/plugin
  32682. */
  32683. set physicsBody(physicsBody: any);
  32684. /**
  32685. * Resets the update flags
  32686. */
  32687. resetUpdateFlags(): void;
  32688. /**
  32689. * Gets the object extend size
  32690. * @returns the object extend size
  32691. */
  32692. getObjectExtendSize(): Vector3;
  32693. /**
  32694. * Gets the object center
  32695. * @returns The object center
  32696. */
  32697. getObjectCenter(): Vector3;
  32698. /**
  32699. * Get a specific parameter from the options parameters
  32700. * @param paramName The object parameter name
  32701. * @returns The object parameter
  32702. */
  32703. getParam(paramName: string): any;
  32704. /**
  32705. * Sets a specific parameter in the options given to the physics plugin
  32706. * @param paramName The parameter name
  32707. * @param value The value of the parameter
  32708. */
  32709. setParam(paramName: string, value: number): void;
  32710. /**
  32711. * Specifically change the body's mass option. Won't recreate the physics body object
  32712. * @param mass The mass of the physics imposter
  32713. */
  32714. setMass(mass: number): void;
  32715. /**
  32716. * Gets the linear velocity
  32717. * @returns linear velocity or null
  32718. */
  32719. getLinearVelocity(): Nullable<Vector3>;
  32720. /**
  32721. * Sets the linear velocity
  32722. * @param velocity linear velocity or null
  32723. */
  32724. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32725. /**
  32726. * Gets the angular velocity
  32727. * @returns angular velocity or null
  32728. */
  32729. getAngularVelocity(): Nullable<Vector3>;
  32730. /**
  32731. * Sets the angular velocity
  32732. * @param velocity The velocity or null
  32733. */
  32734. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32735. /**
  32736. * Execute a function with the physics plugin native code
  32737. * Provide a function the will have two variables - the world object and the physics body object
  32738. * @param func The function to execute with the physics plugin native code
  32739. */
  32740. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32741. /**
  32742. * Register a function that will be executed before the physics world is stepping forward
  32743. * @param func The function to execute before the physics world is stepped forward
  32744. */
  32745. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32746. /**
  32747. * Unregister a function that will be executed before the physics world is stepping forward
  32748. * @param func The function to execute before the physics world is stepped forward
  32749. */
  32750. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32751. /**
  32752. * Register a function that will be executed after the physics step
  32753. * @param func The function to execute after physics step
  32754. */
  32755. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32756. /**
  32757. * Unregisters a function that will be executed after the physics step
  32758. * @param func The function to execute after physics step
  32759. */
  32760. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32761. /**
  32762. * register a function that will be executed when this impostor collides against a different body
  32763. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32764. * @param func Callback that is executed on collision
  32765. */
  32766. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32767. /**
  32768. * Unregisters the physics imposter on contact
  32769. * @param collideAgainst The physics object to collide against
  32770. * @param func Callback to execute on collision
  32771. */
  32772. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32773. private _tmpQuat;
  32774. private _tmpQuat2;
  32775. /**
  32776. * Get the parent rotation
  32777. * @returns The parent rotation
  32778. */
  32779. getParentsRotation(): Quaternion;
  32780. /**
  32781. * this function is executed by the physics engine.
  32782. */
  32783. beforeStep: () => void;
  32784. /**
  32785. * this function is executed by the physics engine
  32786. */
  32787. afterStep: () => void;
  32788. /**
  32789. * Legacy collision detection event support
  32790. */
  32791. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32792. /**
  32793. * event and body object due to cannon's event-based architecture.
  32794. */
  32795. onCollide: (e: {
  32796. body: any;
  32797. point: Nullable<Vector3>;
  32798. }) => void;
  32799. /**
  32800. * Apply a force
  32801. * @param force The force to apply
  32802. * @param contactPoint The contact point for the force
  32803. * @returns The physics imposter
  32804. */
  32805. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32806. /**
  32807. * Apply an impulse
  32808. * @param force The impulse force
  32809. * @param contactPoint The contact point for the impulse force
  32810. * @returns The physics imposter
  32811. */
  32812. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32813. /**
  32814. * A help function to create a joint
  32815. * @param otherImpostor A physics imposter used to create a joint
  32816. * @param jointType The type of joint
  32817. * @param jointData The data for the joint
  32818. * @returns The physics imposter
  32819. */
  32820. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32821. /**
  32822. * Add a joint to this impostor with a different impostor
  32823. * @param otherImpostor A physics imposter used to add a joint
  32824. * @param joint The joint to add
  32825. * @returns The physics imposter
  32826. */
  32827. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32828. /**
  32829. * Add an anchor to a cloth impostor
  32830. * @param otherImpostor rigid impostor to anchor to
  32831. * @param width ratio across width from 0 to 1
  32832. * @param height ratio up height from 0 to 1
  32833. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32834. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32835. * @returns impostor the soft imposter
  32836. */
  32837. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32838. /**
  32839. * Add a hook to a rope impostor
  32840. * @param otherImpostor rigid impostor to anchor to
  32841. * @param length ratio across rope from 0 to 1
  32842. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32843. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32844. * @returns impostor the rope imposter
  32845. */
  32846. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32847. /**
  32848. * Will keep this body still, in a sleep mode.
  32849. * @returns the physics imposter
  32850. */
  32851. sleep(): PhysicsImpostor;
  32852. /**
  32853. * Wake the body up.
  32854. * @returns The physics imposter
  32855. */
  32856. wakeUp(): PhysicsImpostor;
  32857. /**
  32858. * Clones the physics imposter
  32859. * @param newObject The physics imposter clones to this physics-enabled object
  32860. * @returns A nullable physics imposter
  32861. */
  32862. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32863. /**
  32864. * Disposes the physics imposter
  32865. */
  32866. dispose(): void;
  32867. /**
  32868. * Sets the delta position
  32869. * @param position The delta position amount
  32870. */
  32871. setDeltaPosition(position: Vector3): void;
  32872. /**
  32873. * Sets the delta rotation
  32874. * @param rotation The delta rotation amount
  32875. */
  32876. setDeltaRotation(rotation: Quaternion): void;
  32877. /**
  32878. * Gets the box size of the physics imposter and stores the result in the input parameter
  32879. * @param result Stores the box size
  32880. * @returns The physics imposter
  32881. */
  32882. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32883. /**
  32884. * Gets the radius of the physics imposter
  32885. * @returns Radius of the physics imposter
  32886. */
  32887. getRadius(): number;
  32888. /**
  32889. * Sync a bone with this impostor
  32890. * @param bone The bone to sync to the impostor.
  32891. * @param boneMesh The mesh that the bone is influencing.
  32892. * @param jointPivot The pivot of the joint / bone in local space.
  32893. * @param distToJoint Optional distance from the impostor to the joint.
  32894. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32895. */
  32896. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32897. /**
  32898. * Sync impostor to a bone
  32899. * @param bone The bone that the impostor will be synced to.
  32900. * @param boneMesh The mesh that the bone is influencing.
  32901. * @param jointPivot The pivot of the joint / bone in local space.
  32902. * @param distToJoint Optional distance from the impostor to the joint.
  32903. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32904. * @param boneAxis Optional vector3 axis the bone is aligned with
  32905. */
  32906. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32907. /**
  32908. * No-Imposter type
  32909. */
  32910. static NoImpostor: number;
  32911. /**
  32912. * Sphere-Imposter type
  32913. */
  32914. static SphereImpostor: number;
  32915. /**
  32916. * Box-Imposter type
  32917. */
  32918. static BoxImpostor: number;
  32919. /**
  32920. * Plane-Imposter type
  32921. */
  32922. static PlaneImpostor: number;
  32923. /**
  32924. * Mesh-imposter type
  32925. */
  32926. static MeshImpostor: number;
  32927. /**
  32928. * Capsule-Impostor type (Ammo.js plugin only)
  32929. */
  32930. static CapsuleImpostor: number;
  32931. /**
  32932. * Cylinder-Imposter type
  32933. */
  32934. static CylinderImpostor: number;
  32935. /**
  32936. * Particle-Imposter type
  32937. */
  32938. static ParticleImpostor: number;
  32939. /**
  32940. * Heightmap-Imposter type
  32941. */
  32942. static HeightmapImpostor: number;
  32943. /**
  32944. * ConvexHull-Impostor type (Ammo.js plugin only)
  32945. */
  32946. static ConvexHullImpostor: number;
  32947. /**
  32948. * Custom-Imposter type (Ammo.js plugin only)
  32949. */
  32950. static CustomImpostor: number;
  32951. /**
  32952. * Rope-Imposter type
  32953. */
  32954. static RopeImpostor: number;
  32955. /**
  32956. * Cloth-Imposter type
  32957. */
  32958. static ClothImpostor: number;
  32959. /**
  32960. * Softbody-Imposter type
  32961. */
  32962. static SoftbodyImpostor: number;
  32963. }
  32964. }
  32965. declare module BABYLON {
  32966. /**
  32967. * @hidden
  32968. **/
  32969. export class _CreationDataStorage {
  32970. closePath?: boolean;
  32971. closeArray?: boolean;
  32972. idx: number[];
  32973. dashSize: number;
  32974. gapSize: number;
  32975. path3D: Path3D;
  32976. pathArray: Vector3[][];
  32977. arc: number;
  32978. radius: number;
  32979. cap: number;
  32980. tessellation: number;
  32981. }
  32982. /**
  32983. * @hidden
  32984. **/
  32985. class _InstanceDataStorage {
  32986. visibleInstances: any;
  32987. batchCache: _InstancesBatch;
  32988. instancesBufferSize: number;
  32989. instancesBuffer: Nullable<Buffer>;
  32990. instancesData: Float32Array;
  32991. overridenInstanceCount: number;
  32992. isFrozen: boolean;
  32993. previousBatch: Nullable<_InstancesBatch>;
  32994. hardwareInstancedRendering: boolean;
  32995. sideOrientation: number;
  32996. manualUpdate: boolean;
  32997. previousRenderId: number;
  32998. }
  32999. /**
  33000. * @hidden
  33001. **/
  33002. export class _InstancesBatch {
  33003. mustReturn: boolean;
  33004. visibleInstances: Nullable<InstancedMesh[]>[];
  33005. renderSelf: boolean[];
  33006. hardwareInstancedRendering: boolean[];
  33007. }
  33008. /**
  33009. * @hidden
  33010. **/
  33011. class _ThinInstanceDataStorage {
  33012. instancesCount: number;
  33013. matrixBuffer: Nullable<Buffer>;
  33014. matrixBufferSize: number;
  33015. matrixData: Nullable<Float32Array>;
  33016. boundingVectors: Array<Vector3>;
  33017. worldMatrices: Nullable<Matrix[]>;
  33018. }
  33019. /**
  33020. * Class used to represent renderable models
  33021. */
  33022. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33023. /**
  33024. * Mesh side orientation : usually the external or front surface
  33025. */
  33026. static readonly FRONTSIDE: number;
  33027. /**
  33028. * Mesh side orientation : usually the internal or back surface
  33029. */
  33030. static readonly BACKSIDE: number;
  33031. /**
  33032. * Mesh side orientation : both internal and external or front and back surfaces
  33033. */
  33034. static readonly DOUBLESIDE: number;
  33035. /**
  33036. * Mesh side orientation : by default, `FRONTSIDE`
  33037. */
  33038. static readonly DEFAULTSIDE: number;
  33039. /**
  33040. * Mesh cap setting : no cap
  33041. */
  33042. static readonly NO_CAP: number;
  33043. /**
  33044. * Mesh cap setting : one cap at the beginning of the mesh
  33045. */
  33046. static readonly CAP_START: number;
  33047. /**
  33048. * Mesh cap setting : one cap at the end of the mesh
  33049. */
  33050. static readonly CAP_END: number;
  33051. /**
  33052. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33053. */
  33054. static readonly CAP_ALL: number;
  33055. /**
  33056. * Mesh pattern setting : no flip or rotate
  33057. */
  33058. static readonly NO_FLIP: number;
  33059. /**
  33060. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33061. */
  33062. static readonly FLIP_TILE: number;
  33063. /**
  33064. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33065. */
  33066. static readonly ROTATE_TILE: number;
  33067. /**
  33068. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33069. */
  33070. static readonly FLIP_ROW: number;
  33071. /**
  33072. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33073. */
  33074. static readonly ROTATE_ROW: number;
  33075. /**
  33076. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33077. */
  33078. static readonly FLIP_N_ROTATE_TILE: number;
  33079. /**
  33080. * Mesh pattern setting : rotate pattern and rotate
  33081. */
  33082. static readonly FLIP_N_ROTATE_ROW: number;
  33083. /**
  33084. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33085. */
  33086. static readonly CENTER: number;
  33087. /**
  33088. * Mesh tile positioning : part tiles on left
  33089. */
  33090. static readonly LEFT: number;
  33091. /**
  33092. * Mesh tile positioning : part tiles on right
  33093. */
  33094. static readonly RIGHT: number;
  33095. /**
  33096. * Mesh tile positioning : part tiles on top
  33097. */
  33098. static readonly TOP: number;
  33099. /**
  33100. * Mesh tile positioning : part tiles on bottom
  33101. */
  33102. static readonly BOTTOM: number;
  33103. /**
  33104. * Gets the default side orientation.
  33105. * @param orientation the orientation to value to attempt to get
  33106. * @returns the default orientation
  33107. * @hidden
  33108. */
  33109. static _GetDefaultSideOrientation(orientation?: number): number;
  33110. private _internalMeshDataInfo;
  33111. get computeBonesUsingShaders(): boolean;
  33112. set computeBonesUsingShaders(value: boolean);
  33113. /**
  33114. * An event triggered before rendering the mesh
  33115. */
  33116. get onBeforeRenderObservable(): Observable<Mesh>;
  33117. /**
  33118. * An event triggered before binding the mesh
  33119. */
  33120. get onBeforeBindObservable(): Observable<Mesh>;
  33121. /**
  33122. * An event triggered after rendering the mesh
  33123. */
  33124. get onAfterRenderObservable(): Observable<Mesh>;
  33125. /**
  33126. * An event triggered before drawing the mesh
  33127. */
  33128. get onBeforeDrawObservable(): Observable<Mesh>;
  33129. private _onBeforeDrawObserver;
  33130. /**
  33131. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33132. */
  33133. set onBeforeDraw(callback: () => void);
  33134. get hasInstances(): boolean;
  33135. get hasThinInstances(): boolean;
  33136. /**
  33137. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33138. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33139. */
  33140. delayLoadState: number;
  33141. /**
  33142. * Gets the list of instances created from this mesh
  33143. * it is not supposed to be modified manually.
  33144. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33145. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33146. */
  33147. instances: InstancedMesh[];
  33148. /**
  33149. * Gets the file containing delay loading data for this mesh
  33150. */
  33151. delayLoadingFile: string;
  33152. /** @hidden */
  33153. _binaryInfo: any;
  33154. /**
  33155. * User defined function used to change how LOD level selection is done
  33156. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33157. */
  33158. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33159. /**
  33160. * Gets or sets the morph target manager
  33161. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33162. */
  33163. get morphTargetManager(): Nullable<MorphTargetManager>;
  33164. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33165. /** @hidden */
  33166. _creationDataStorage: Nullable<_CreationDataStorage>;
  33167. /** @hidden */
  33168. _geometry: Nullable<Geometry>;
  33169. /** @hidden */
  33170. _delayInfo: Array<string>;
  33171. /** @hidden */
  33172. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33173. /** @hidden */
  33174. _instanceDataStorage: _InstanceDataStorage;
  33175. /** @hidden */
  33176. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33177. private _effectiveMaterial;
  33178. /** @hidden */
  33179. _shouldGenerateFlatShading: boolean;
  33180. /** @hidden */
  33181. _originalBuilderSideOrientation: number;
  33182. /**
  33183. * Use this property to change the original side orientation defined at construction time
  33184. */
  33185. overrideMaterialSideOrientation: Nullable<number>;
  33186. /**
  33187. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33188. * Note this will reduce performance when set to true.
  33189. */
  33190. ignoreCameraMaxZ: boolean;
  33191. /**
  33192. * Gets the source mesh (the one used to clone this one from)
  33193. */
  33194. get source(): Nullable<Mesh>;
  33195. /**
  33196. * Gets the list of clones of this mesh
  33197. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33198. * Note that useClonedMeshMap=true is the default setting
  33199. */
  33200. get cloneMeshMap(): Nullable<{
  33201. [id: string]: Mesh | undefined;
  33202. }>;
  33203. /**
  33204. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33205. */
  33206. get isUnIndexed(): boolean;
  33207. set isUnIndexed(value: boolean);
  33208. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33209. get worldMatrixInstancedBuffer(): Float32Array;
  33210. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33211. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33212. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33213. /**
  33214. * @constructor
  33215. * @param name The value used by scene.getMeshByName() to do a lookup.
  33216. * @param scene The scene to add this mesh to.
  33217. * @param parent The parent of this mesh, if it has one
  33218. * @param source An optional Mesh from which geometry is shared, cloned.
  33219. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33220. * When false, achieved by calling a clone(), also passing False.
  33221. * This will make creation of children, recursive.
  33222. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33223. */
  33224. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33225. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33226. doNotInstantiate: boolean;
  33227. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33228. /**
  33229. * Gets the class name
  33230. * @returns the string "Mesh".
  33231. */
  33232. getClassName(): string;
  33233. /** @hidden */
  33234. get _isMesh(): boolean;
  33235. /**
  33236. * Returns a description of this mesh
  33237. * @param fullDetails define if full details about this mesh must be used
  33238. * @returns a descriptive string representing this mesh
  33239. */
  33240. toString(fullDetails?: boolean): string;
  33241. /** @hidden */
  33242. _unBindEffect(): void;
  33243. /**
  33244. * Gets a boolean indicating if this mesh has LOD
  33245. */
  33246. get hasLODLevels(): boolean;
  33247. /**
  33248. * Gets the list of MeshLODLevel associated with the current mesh
  33249. * @returns an array of MeshLODLevel
  33250. */
  33251. getLODLevels(): MeshLODLevel[];
  33252. private _sortLODLevels;
  33253. /**
  33254. * Add a mesh as LOD level triggered at the given distance.
  33255. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33256. * @param distance The distance from the center of the object to show this level
  33257. * @param mesh The mesh to be added as LOD level (can be null)
  33258. * @return This mesh (for chaining)
  33259. */
  33260. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33261. /**
  33262. * Returns the LOD level mesh at the passed distance or null if not found.
  33263. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33264. * @param distance The distance from the center of the object to show this level
  33265. * @returns a Mesh or `null`
  33266. */
  33267. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33268. /**
  33269. * Remove a mesh from the LOD array
  33270. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33271. * @param mesh defines the mesh to be removed
  33272. * @return This mesh (for chaining)
  33273. */
  33274. removeLODLevel(mesh: Mesh): Mesh;
  33275. /**
  33276. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33277. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33278. * @param camera defines the camera to use to compute distance
  33279. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33280. * @return This mesh (for chaining)
  33281. */
  33282. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33283. /**
  33284. * Gets the mesh internal Geometry object
  33285. */
  33286. get geometry(): Nullable<Geometry>;
  33287. /**
  33288. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33289. * @returns the total number of vertices
  33290. */
  33291. getTotalVertices(): number;
  33292. /**
  33293. * Returns the content of an associated vertex buffer
  33294. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33295. * - VertexBuffer.PositionKind
  33296. * - VertexBuffer.UVKind
  33297. * - VertexBuffer.UV2Kind
  33298. * - VertexBuffer.UV3Kind
  33299. * - VertexBuffer.UV4Kind
  33300. * - VertexBuffer.UV5Kind
  33301. * - VertexBuffer.UV6Kind
  33302. * - VertexBuffer.ColorKind
  33303. * - VertexBuffer.MatricesIndicesKind
  33304. * - VertexBuffer.MatricesIndicesExtraKind
  33305. * - VertexBuffer.MatricesWeightsKind
  33306. * - VertexBuffer.MatricesWeightsExtraKind
  33307. * @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
  33308. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33309. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33310. */
  33311. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33312. /**
  33313. * Returns the mesh VertexBuffer object from the requested `kind`
  33314. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33315. * - VertexBuffer.PositionKind
  33316. * - VertexBuffer.NormalKind
  33317. * - VertexBuffer.UVKind
  33318. * - VertexBuffer.UV2Kind
  33319. * - VertexBuffer.UV3Kind
  33320. * - VertexBuffer.UV4Kind
  33321. * - VertexBuffer.UV5Kind
  33322. * - VertexBuffer.UV6Kind
  33323. * - VertexBuffer.ColorKind
  33324. * - VertexBuffer.MatricesIndicesKind
  33325. * - VertexBuffer.MatricesIndicesExtraKind
  33326. * - VertexBuffer.MatricesWeightsKind
  33327. * - VertexBuffer.MatricesWeightsExtraKind
  33328. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33329. */
  33330. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33331. /**
  33332. * Tests if a specific vertex buffer is associated with this mesh
  33333. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33334. * - VertexBuffer.PositionKind
  33335. * - VertexBuffer.NormalKind
  33336. * - VertexBuffer.UVKind
  33337. * - VertexBuffer.UV2Kind
  33338. * - VertexBuffer.UV3Kind
  33339. * - VertexBuffer.UV4Kind
  33340. * - VertexBuffer.UV5Kind
  33341. * - VertexBuffer.UV6Kind
  33342. * - VertexBuffer.ColorKind
  33343. * - VertexBuffer.MatricesIndicesKind
  33344. * - VertexBuffer.MatricesIndicesExtraKind
  33345. * - VertexBuffer.MatricesWeightsKind
  33346. * - VertexBuffer.MatricesWeightsExtraKind
  33347. * @returns a boolean
  33348. */
  33349. isVerticesDataPresent(kind: string): boolean;
  33350. /**
  33351. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33352. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33353. * - VertexBuffer.PositionKind
  33354. * - VertexBuffer.UVKind
  33355. * - VertexBuffer.UV2Kind
  33356. * - VertexBuffer.UV3Kind
  33357. * - VertexBuffer.UV4Kind
  33358. * - VertexBuffer.UV5Kind
  33359. * - VertexBuffer.UV6Kind
  33360. * - VertexBuffer.ColorKind
  33361. * - VertexBuffer.MatricesIndicesKind
  33362. * - VertexBuffer.MatricesIndicesExtraKind
  33363. * - VertexBuffer.MatricesWeightsKind
  33364. * - VertexBuffer.MatricesWeightsExtraKind
  33365. * @returns a boolean
  33366. */
  33367. isVertexBufferUpdatable(kind: string): boolean;
  33368. /**
  33369. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33370. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33371. * - VertexBuffer.PositionKind
  33372. * - VertexBuffer.NormalKind
  33373. * - VertexBuffer.UVKind
  33374. * - VertexBuffer.UV2Kind
  33375. * - VertexBuffer.UV3Kind
  33376. * - VertexBuffer.UV4Kind
  33377. * - VertexBuffer.UV5Kind
  33378. * - VertexBuffer.UV6Kind
  33379. * - VertexBuffer.ColorKind
  33380. * - VertexBuffer.MatricesIndicesKind
  33381. * - VertexBuffer.MatricesIndicesExtraKind
  33382. * - VertexBuffer.MatricesWeightsKind
  33383. * - VertexBuffer.MatricesWeightsExtraKind
  33384. * @returns an array of strings
  33385. */
  33386. getVerticesDataKinds(): string[];
  33387. /**
  33388. * Returns a positive integer : the total number of indices in this mesh geometry.
  33389. * @returns the numner of indices or zero if the mesh has no geometry.
  33390. */
  33391. getTotalIndices(): number;
  33392. /**
  33393. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33394. * @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.
  33395. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33396. * @returns the indices array or an empty array if the mesh has no geometry
  33397. */
  33398. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33399. get isBlocked(): boolean;
  33400. /**
  33401. * Determine if the current mesh is ready to be rendered
  33402. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33403. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33404. * @returns true if all associated assets are ready (material, textures, shaders)
  33405. */
  33406. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33407. /**
  33408. * 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.
  33409. */
  33410. get areNormalsFrozen(): boolean;
  33411. /**
  33412. * 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.
  33413. * @returns the current mesh
  33414. */
  33415. freezeNormals(): Mesh;
  33416. /**
  33417. * 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
  33418. * @returns the current mesh
  33419. */
  33420. unfreezeNormals(): Mesh;
  33421. /**
  33422. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33423. */
  33424. set overridenInstanceCount(count: number);
  33425. /** @hidden */
  33426. _preActivate(): Mesh;
  33427. /** @hidden */
  33428. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33429. /** @hidden */
  33430. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33431. protected _afterComputeWorldMatrix(): void;
  33432. /** @hidden */
  33433. _postActivate(): void;
  33434. /**
  33435. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33436. * This means the mesh underlying bounding box and sphere are recomputed.
  33437. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33438. * @returns the current mesh
  33439. */
  33440. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33441. /** @hidden */
  33442. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33443. /**
  33444. * This function will subdivide the mesh into multiple submeshes
  33445. * @param count defines the expected number of submeshes
  33446. */
  33447. subdivide(count: number): void;
  33448. /**
  33449. * Copy a FloatArray into a specific associated vertex buffer
  33450. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33451. * - VertexBuffer.PositionKind
  33452. * - VertexBuffer.UVKind
  33453. * - VertexBuffer.UV2Kind
  33454. * - VertexBuffer.UV3Kind
  33455. * - VertexBuffer.UV4Kind
  33456. * - VertexBuffer.UV5Kind
  33457. * - VertexBuffer.UV6Kind
  33458. * - VertexBuffer.ColorKind
  33459. * - VertexBuffer.MatricesIndicesKind
  33460. * - VertexBuffer.MatricesIndicesExtraKind
  33461. * - VertexBuffer.MatricesWeightsKind
  33462. * - VertexBuffer.MatricesWeightsExtraKind
  33463. * @param data defines the data source
  33464. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33465. * @param stride defines the data stride size (can be null)
  33466. * @returns the current mesh
  33467. */
  33468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33469. /**
  33470. * Delete a vertex buffer associated with this mesh
  33471. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33472. * - VertexBuffer.PositionKind
  33473. * - VertexBuffer.UVKind
  33474. * - VertexBuffer.UV2Kind
  33475. * - VertexBuffer.UV3Kind
  33476. * - VertexBuffer.UV4Kind
  33477. * - VertexBuffer.UV5Kind
  33478. * - VertexBuffer.UV6Kind
  33479. * - VertexBuffer.ColorKind
  33480. * - VertexBuffer.MatricesIndicesKind
  33481. * - VertexBuffer.MatricesIndicesExtraKind
  33482. * - VertexBuffer.MatricesWeightsKind
  33483. * - VertexBuffer.MatricesWeightsExtraKind
  33484. */
  33485. removeVerticesData(kind: string): void;
  33486. /**
  33487. * Flags an associated vertex buffer as updatable
  33488. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33489. * - VertexBuffer.PositionKind
  33490. * - VertexBuffer.UVKind
  33491. * - VertexBuffer.UV2Kind
  33492. * - VertexBuffer.UV3Kind
  33493. * - VertexBuffer.UV4Kind
  33494. * - VertexBuffer.UV5Kind
  33495. * - VertexBuffer.UV6Kind
  33496. * - VertexBuffer.ColorKind
  33497. * - VertexBuffer.MatricesIndicesKind
  33498. * - VertexBuffer.MatricesIndicesExtraKind
  33499. * - VertexBuffer.MatricesWeightsKind
  33500. * - VertexBuffer.MatricesWeightsExtraKind
  33501. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33502. */
  33503. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33504. /**
  33505. * Sets the mesh global Vertex Buffer
  33506. * @param buffer defines the buffer to use
  33507. * @returns the current mesh
  33508. */
  33509. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33510. /**
  33511. * Update a specific associated vertex buffer
  33512. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33513. * - VertexBuffer.PositionKind
  33514. * - VertexBuffer.UVKind
  33515. * - VertexBuffer.UV2Kind
  33516. * - VertexBuffer.UV3Kind
  33517. * - VertexBuffer.UV4Kind
  33518. * - VertexBuffer.UV5Kind
  33519. * - VertexBuffer.UV6Kind
  33520. * - VertexBuffer.ColorKind
  33521. * - VertexBuffer.MatricesIndicesKind
  33522. * - VertexBuffer.MatricesIndicesExtraKind
  33523. * - VertexBuffer.MatricesWeightsKind
  33524. * - VertexBuffer.MatricesWeightsExtraKind
  33525. * @param data defines the data source
  33526. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33527. * @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)
  33528. * @returns the current mesh
  33529. */
  33530. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33531. /**
  33532. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33533. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33534. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33535. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33536. * @returns the current mesh
  33537. */
  33538. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33539. /**
  33540. * Creates a un-shared specific occurence of the geometry for the mesh.
  33541. * @returns the current mesh
  33542. */
  33543. makeGeometryUnique(): Mesh;
  33544. /**
  33545. * Set the index buffer of this mesh
  33546. * @param indices defines the source data
  33547. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33548. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33549. * @returns the current mesh
  33550. */
  33551. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33552. /**
  33553. * Update the current index buffer
  33554. * @param indices defines the source data
  33555. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33556. * @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)
  33557. * @returns the current mesh
  33558. */
  33559. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33560. /**
  33561. * Invert the geometry to move from a right handed system to a left handed one.
  33562. * @returns the current mesh
  33563. */
  33564. toLeftHanded(): Mesh;
  33565. /** @hidden */
  33566. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33567. /** @hidden */
  33568. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33569. /**
  33570. * Registers for this mesh a javascript function called just before the rendering process
  33571. * @param func defines the function to call before rendering this mesh
  33572. * @returns the current mesh
  33573. */
  33574. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33575. /**
  33576. * Disposes a previously registered javascript function called before the rendering
  33577. * @param func defines the function to remove
  33578. * @returns the current mesh
  33579. */
  33580. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33581. /**
  33582. * Registers for this mesh a javascript function called just after the rendering is complete
  33583. * @param func defines the function to call after rendering this mesh
  33584. * @returns the current mesh
  33585. */
  33586. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33587. /**
  33588. * Disposes a previously registered javascript function called after the rendering.
  33589. * @param func defines the function to remove
  33590. * @returns the current mesh
  33591. */
  33592. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33593. /** @hidden */
  33594. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33595. /** @hidden */
  33596. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33597. /** @hidden */
  33598. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33599. /** @hidden */
  33600. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33601. /** @hidden */
  33602. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33603. /** @hidden */
  33604. _rebuild(): void;
  33605. /** @hidden */
  33606. _freeze(): void;
  33607. /** @hidden */
  33608. _unFreeze(): void;
  33609. /**
  33610. * 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
  33611. * @param subMesh defines the subMesh to render
  33612. * @param enableAlphaMode defines if alpha mode can be changed
  33613. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33614. * @returns the current mesh
  33615. */
  33616. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33617. private _onBeforeDraw;
  33618. /**
  33619. * Renormalize the mesh and patch it up if there are no weights
  33620. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33621. * However in the case of zero weights then we set just a single influence to 1.
  33622. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33623. */
  33624. cleanMatrixWeights(): void;
  33625. private normalizeSkinFourWeights;
  33626. private normalizeSkinWeightsAndExtra;
  33627. /**
  33628. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33629. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33630. * the user know there was an issue with importing the mesh
  33631. * @returns a validation object with skinned, valid and report string
  33632. */
  33633. validateSkinning(): {
  33634. skinned: boolean;
  33635. valid: boolean;
  33636. report: string;
  33637. };
  33638. /** @hidden */
  33639. _checkDelayState(): Mesh;
  33640. private _queueLoad;
  33641. /**
  33642. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33643. * A mesh is in the frustum if its bounding box intersects the frustum
  33644. * @param frustumPlanes defines the frustum to test
  33645. * @returns true if the mesh is in the frustum planes
  33646. */
  33647. isInFrustum(frustumPlanes: Plane[]): boolean;
  33648. /**
  33649. * Sets the mesh material by the material or multiMaterial `id` property
  33650. * @param id is a string identifying the material or the multiMaterial
  33651. * @returns the current mesh
  33652. */
  33653. setMaterialByID(id: string): Mesh;
  33654. /**
  33655. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33656. * @returns an array of IAnimatable
  33657. */
  33658. getAnimatables(): IAnimatable[];
  33659. /**
  33660. * Modifies the mesh geometry according to the passed transformation matrix.
  33661. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33662. * The mesh normals are modified using the same transformation.
  33663. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33664. * @param transform defines the transform matrix to use
  33665. * @see https://doc.babylonjs.com/resources/baking_transformations
  33666. * @returns the current mesh
  33667. */
  33668. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33669. /**
  33670. * Modifies the mesh geometry according to its own current World Matrix.
  33671. * The mesh World Matrix is then reset.
  33672. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33673. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33674. * @see https://doc.babylonjs.com/resources/baking_transformations
  33675. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33676. * @returns the current mesh
  33677. */
  33678. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33679. /** @hidden */
  33680. get _positions(): Nullable<Vector3[]>;
  33681. /** @hidden */
  33682. _resetPointsArrayCache(): Mesh;
  33683. /** @hidden */
  33684. _generatePointsArray(): boolean;
  33685. /**
  33686. * Returns a new Mesh object generated from the current mesh properties.
  33687. * This method must not get confused with createInstance()
  33688. * @param name is a string, the name given to the new mesh
  33689. * @param newParent can be any Node object (default `null`)
  33690. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33691. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33692. * @returns a new mesh
  33693. */
  33694. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33695. /**
  33696. * Releases resources associated with this mesh.
  33697. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33698. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33699. */
  33700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33701. /** @hidden */
  33702. _disposeInstanceSpecificData(): void;
  33703. /** @hidden */
  33704. _disposeThinInstanceSpecificData(): void;
  33705. /**
  33706. * Modifies the mesh geometry according to a displacement map.
  33707. * 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.
  33708. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33709. * @param url is a string, the URL from the image file is to be downloaded.
  33710. * @param minHeight is the lower limit of the displacement.
  33711. * @param maxHeight is the upper limit of the displacement.
  33712. * @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.
  33713. * @param uvOffset is an optional vector2 used to offset UV.
  33714. * @param uvScale is an optional vector2 used to scale UV.
  33715. * @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.
  33716. * @returns the Mesh.
  33717. */
  33718. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33719. /**
  33720. * Modifies the mesh geometry according to a displacementMap buffer.
  33721. * 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.
  33722. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33723. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33724. * @param heightMapWidth is the width of the buffer image.
  33725. * @param heightMapHeight is the height of the buffer image.
  33726. * @param minHeight is the lower limit of the displacement.
  33727. * @param maxHeight is the upper limit of the displacement.
  33728. * @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.
  33729. * @param uvOffset is an optional vector2 used to offset UV.
  33730. * @param uvScale is an optional vector2 used to scale UV.
  33731. * @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.
  33732. * @returns the Mesh.
  33733. */
  33734. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33735. /**
  33736. * Modify the mesh to get a flat shading rendering.
  33737. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33738. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33739. * @returns current mesh
  33740. */
  33741. convertToFlatShadedMesh(): Mesh;
  33742. /**
  33743. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33744. * In other words, more vertices, no more indices and a single bigger VBO.
  33745. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33746. * @returns current mesh
  33747. */
  33748. convertToUnIndexedMesh(): Mesh;
  33749. /**
  33750. * Inverses facet orientations.
  33751. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33752. * @param flipNormals will also inverts the normals
  33753. * @returns current mesh
  33754. */
  33755. flipFaces(flipNormals?: boolean): Mesh;
  33756. /**
  33757. * Increase the number of facets and hence vertices in a mesh
  33758. * Vertex normals are interpolated from existing vertex normals
  33759. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33760. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33761. */
  33762. increaseVertices(numberPerEdge: number): void;
  33763. /**
  33764. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33765. * This will undo any application of covertToFlatShadedMesh
  33766. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33767. */
  33768. forceSharedVertices(): void;
  33769. /** @hidden */
  33770. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33771. /** @hidden */
  33772. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33773. /**
  33774. * Creates a new InstancedMesh object from the mesh model.
  33775. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33776. * @param name defines the name of the new instance
  33777. * @returns a new InstancedMesh
  33778. */
  33779. createInstance(name: string): InstancedMesh;
  33780. /**
  33781. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33782. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33783. * @returns the current mesh
  33784. */
  33785. synchronizeInstances(): Mesh;
  33786. /**
  33787. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33788. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33789. * This should be used together with the simplification to avoid disappearing triangles.
  33790. * @param successCallback an optional success callback to be called after the optimization finished.
  33791. * @returns the current mesh
  33792. */
  33793. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33794. /**
  33795. * Serialize current mesh
  33796. * @param serializationObject defines the object which will receive the serialization data
  33797. */
  33798. serialize(serializationObject: any): void;
  33799. /** @hidden */
  33800. _syncGeometryWithMorphTargetManager(): void;
  33801. /** @hidden */
  33802. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33803. /**
  33804. * Returns a new Mesh object parsed from the source provided.
  33805. * @param parsedMesh is the source
  33806. * @param scene defines the hosting scene
  33807. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33808. * @returns a new Mesh
  33809. */
  33810. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33811. /**
  33812. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33813. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33814. * @param name defines the name of the mesh to create
  33815. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33816. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33817. * @param closePath creates a seam between the first and the last points of each path of the path array
  33818. * @param offset is taken in account only if the `pathArray` is containing a single path
  33819. * @param scene defines the hosting scene
  33820. * @param updatable defines if the mesh must be flagged as updatable
  33821. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33822. * @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)
  33823. * @returns a new Mesh
  33824. */
  33825. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33826. /**
  33827. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33828. * @param name defines the name of the mesh to create
  33829. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33830. * @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
  33831. * @param scene defines the hosting scene
  33832. * @param updatable defines if the mesh must be flagged as updatable
  33833. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33834. * @returns a new Mesh
  33835. */
  33836. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33837. /**
  33838. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33839. * @param name defines the name of the mesh to create
  33840. * @param size sets the size (float) of each box side (default 1)
  33841. * @param scene defines the hosting scene
  33842. * @param updatable defines if the mesh must be flagged as updatable
  33843. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33844. * @returns a new Mesh
  33845. */
  33846. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33847. /**
  33848. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33849. * @param name defines the name of the mesh to create
  33850. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33851. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33852. * @param scene defines the hosting scene
  33853. * @param updatable defines if the mesh must be flagged as updatable
  33854. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33855. * @returns a new Mesh
  33856. */
  33857. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33858. /**
  33859. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33860. * @param name defines the name of the mesh to create
  33861. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33862. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33863. * @param scene defines the hosting scene
  33864. * @returns a new Mesh
  33865. */
  33866. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33867. /**
  33868. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33869. * @param name defines the name of the mesh to create
  33870. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33871. * @param diameterTop set the top cap diameter (floats, default 1)
  33872. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33873. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33874. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33875. * @param scene defines the hosting scene
  33876. * @param updatable defines if the mesh must be flagged as updatable
  33877. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33878. * @returns a new Mesh
  33879. */
  33880. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33881. /**
  33882. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33883. * @param name defines the name of the mesh to create
  33884. * @param diameter sets the diameter size (float) of the torus (default 1)
  33885. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33886. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33887. * @param scene defines the hosting scene
  33888. * @param updatable defines if the mesh must be flagged as updatable
  33889. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33890. * @returns a new Mesh
  33891. */
  33892. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33893. /**
  33894. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33895. * @param name defines the name of the mesh to create
  33896. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33897. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33898. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33899. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33900. * @param p the number of windings on X axis (positive integers, default 2)
  33901. * @param q the number of windings on Y axis (positive integers, default 3)
  33902. * @param scene defines the hosting scene
  33903. * @param updatable defines if the mesh must be flagged as updatable
  33904. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33905. * @returns a new Mesh
  33906. */
  33907. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33908. /**
  33909. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33910. * @param name defines the name of the mesh to create
  33911. * @param points is an array successive Vector3
  33912. * @param scene defines the hosting scene
  33913. * @param updatable defines if the mesh must be flagged as updatable
  33914. * @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).
  33915. * @returns a new Mesh
  33916. */
  33917. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33918. /**
  33919. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33920. * @param name defines the name of the mesh to create
  33921. * @param points is an array successive Vector3
  33922. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33923. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33924. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33925. * @param scene defines the hosting scene
  33926. * @param updatable defines if the mesh must be flagged as updatable
  33927. * @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)
  33928. * @returns a new Mesh
  33929. */
  33930. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33931. /**
  33932. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33933. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33934. * 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.
  33935. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33936. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33937. * Remember you can only change the shape positions, not their number when updating a polygon.
  33938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33939. * @param name defines the name of the mesh to create
  33940. * @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
  33941. * @param scene defines the hosting scene
  33942. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33943. * @param updatable defines if the mesh must be flagged as updatable
  33944. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33945. * @param earcutInjection can be used to inject your own earcut reference
  33946. * @returns a new Mesh
  33947. */
  33948. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33949. /**
  33950. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33952. * @param name defines the name of the mesh to create
  33953. * @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
  33954. * @param depth defines the height of extrusion
  33955. * @param scene defines the hosting scene
  33956. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33957. * @param updatable defines if the mesh must be flagged as updatable
  33958. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33959. * @param earcutInjection can be used to inject your own earcut reference
  33960. * @returns a new Mesh
  33961. */
  33962. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33963. /**
  33964. * Creates an extruded shape mesh.
  33965. * 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
  33966. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33967. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33968. * @param name defines the name of the mesh to create
  33969. * @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
  33970. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33971. * @param scale is the value to scale the shape
  33972. * @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
  33973. * @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
  33974. * @param scene defines the hosting scene
  33975. * @param updatable defines if the mesh must be flagged as updatable
  33976. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33977. * @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)
  33978. * @returns a new Mesh
  33979. */
  33980. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33981. /**
  33982. * Creates an custom extruded shape mesh.
  33983. * The custom extrusion is a parametric shape.
  33984. * It has no predefined shape. Its final shape will depend on the input parameters.
  33985. * Please consider using the same method from the MeshBuilder class instead
  33986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33987. * @param name defines the name of the mesh to create
  33988. * @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
  33989. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33990. * @param scaleFunction is a custom Javascript function called on each path point
  33991. * @param rotationFunction is a custom Javascript function called on each path point
  33992. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33993. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33994. * @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
  33995. * @param scene defines the hosting scene
  33996. * @param updatable defines if the mesh must be flagged as updatable
  33997. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33998. * @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)
  33999. * @returns a new Mesh
  34000. */
  34001. 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;
  34002. /**
  34003. * Creates lathe mesh.
  34004. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34005. * Please consider using the same method from the MeshBuilder class instead
  34006. * @param name defines the name of the mesh to create
  34007. * @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
  34008. * @param radius is the radius value of the lathe
  34009. * @param tessellation is the side number of the lathe.
  34010. * @param scene defines the hosting scene
  34011. * @param updatable defines if the mesh must be flagged as updatable
  34012. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34013. * @returns a new Mesh
  34014. */
  34015. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34016. /**
  34017. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34018. * @param name defines the name of the mesh to create
  34019. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34020. * @param scene defines the hosting scene
  34021. * @param updatable defines if the mesh must be flagged as updatable
  34022. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34023. * @returns a new Mesh
  34024. */
  34025. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34026. /**
  34027. * Creates a ground mesh.
  34028. * Please consider using the same method from the MeshBuilder class instead
  34029. * @param name defines the name of the mesh to create
  34030. * @param width set the width of the ground
  34031. * @param height set the height of the ground
  34032. * @param subdivisions sets the number of subdivisions per side
  34033. * @param scene defines the hosting scene
  34034. * @param updatable defines if the mesh must be flagged as updatable
  34035. * @returns a new Mesh
  34036. */
  34037. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34038. /**
  34039. * Creates a tiled ground mesh.
  34040. * Please consider using the same method from the MeshBuilder class instead
  34041. * @param name defines the name of the mesh to create
  34042. * @param xmin set the ground minimum X coordinate
  34043. * @param zmin set the ground minimum Y coordinate
  34044. * @param xmax set the ground maximum X coordinate
  34045. * @param zmax set the ground maximum Z coordinate
  34046. * @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
  34047. * @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
  34048. * @param scene defines the hosting scene
  34049. * @param updatable defines if the mesh must be flagged as updatable
  34050. * @returns a new Mesh
  34051. */
  34052. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34053. w: number;
  34054. h: number;
  34055. }, precision: {
  34056. w: number;
  34057. h: number;
  34058. }, scene: Scene, updatable?: boolean): Mesh;
  34059. /**
  34060. * Creates a ground mesh from a height map.
  34061. * Please consider using the same method from the MeshBuilder class instead
  34062. * @see https://doc.babylonjs.com/babylon101/height_map
  34063. * @param name defines the name of the mesh to create
  34064. * @param url sets the URL of the height map image resource
  34065. * @param width set the ground width size
  34066. * @param height set the ground height size
  34067. * @param subdivisions sets the number of subdivision per side
  34068. * @param minHeight is the minimum altitude on the ground
  34069. * @param maxHeight is the maximum altitude on the ground
  34070. * @param scene defines the hosting scene
  34071. * @param updatable defines if the mesh must be flagged as updatable
  34072. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34073. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34074. * @returns a new Mesh
  34075. */
  34076. 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;
  34077. /**
  34078. * Creates a tube mesh.
  34079. * The tube is a parametric shape.
  34080. * It has no predefined shape. Its final shape will depend on the input parameters.
  34081. * Please consider using the same method from the MeshBuilder class instead
  34082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34083. * @param name defines the name of the mesh to create
  34084. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34085. * @param radius sets the tube radius size
  34086. * @param tessellation is the number of sides on the tubular surface
  34087. * @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
  34088. * @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
  34089. * @param scene defines the hosting scene
  34090. * @param updatable defines if the mesh must be flagged as updatable
  34091. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34092. * @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)
  34093. * @returns a new Mesh
  34094. */
  34095. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34096. (i: number, distance: number): number;
  34097. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34098. /**
  34099. * Creates a polyhedron mesh.
  34100. * Please consider using the same method from the MeshBuilder class instead.
  34101. * * 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
  34102. * * The parameter `size` (positive float, default 1) sets the polygon size
  34103. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34104. * * 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`
  34105. * * 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
  34106. * * 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)`)
  34107. * * 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
  34108. * * 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
  34109. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34110. * * 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
  34111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34112. * @param name defines the name of the mesh to create
  34113. * @param options defines the options used to create the mesh
  34114. * @param scene defines the hosting scene
  34115. * @returns a new Mesh
  34116. */
  34117. static CreatePolyhedron(name: string, options: {
  34118. type?: number;
  34119. size?: number;
  34120. sizeX?: number;
  34121. sizeY?: number;
  34122. sizeZ?: number;
  34123. custom?: any;
  34124. faceUV?: Vector4[];
  34125. faceColors?: Color4[];
  34126. updatable?: boolean;
  34127. sideOrientation?: number;
  34128. }, scene: Scene): Mesh;
  34129. /**
  34130. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34131. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34132. * * 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`)
  34133. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34134. * * 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
  34135. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34136. * * 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
  34137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34138. * @param name defines the name of the mesh
  34139. * @param options defines the options used to create the mesh
  34140. * @param scene defines the hosting scene
  34141. * @returns a new Mesh
  34142. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34143. */
  34144. static CreateIcoSphere(name: string, options: {
  34145. radius?: number;
  34146. flat?: boolean;
  34147. subdivisions?: number;
  34148. sideOrientation?: number;
  34149. updatable?: boolean;
  34150. }, scene: Scene): Mesh;
  34151. /**
  34152. * Creates a decal mesh.
  34153. * Please consider using the same method from the MeshBuilder class instead.
  34154. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34155. * @param name defines the name of the mesh
  34156. * @param sourceMesh defines the mesh receiving the decal
  34157. * @param position sets the position of the decal in world coordinates
  34158. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34159. * @param size sets the decal scaling
  34160. * @param angle sets the angle to rotate the decal
  34161. * @returns a new Mesh
  34162. */
  34163. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34164. /** Creates a Capsule Mesh
  34165. * @param name defines the name of the mesh.
  34166. * @param options the constructors options used to shape the mesh.
  34167. * @param scene defines the scene the mesh is scoped to.
  34168. * @returns the capsule mesh
  34169. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34170. */
  34171. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34172. /**
  34173. * Prepare internal position array for software CPU skinning
  34174. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34175. */
  34176. setPositionsForCPUSkinning(): Float32Array;
  34177. /**
  34178. * Prepare internal normal array for software CPU skinning
  34179. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34180. */
  34181. setNormalsForCPUSkinning(): Float32Array;
  34182. /**
  34183. * Updates the vertex buffer by applying transformation from the bones
  34184. * @param skeleton defines the skeleton to apply to current mesh
  34185. * @returns the current mesh
  34186. */
  34187. applySkeleton(skeleton: Skeleton): Mesh;
  34188. /**
  34189. * 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
  34190. * @param meshes defines the list of meshes to scan
  34191. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34192. */
  34193. static MinMax(meshes: AbstractMesh[]): {
  34194. min: Vector3;
  34195. max: Vector3;
  34196. };
  34197. /**
  34198. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34199. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34200. * @returns a vector3
  34201. */
  34202. static Center(meshesOrMinMaxVector: {
  34203. min: Vector3;
  34204. max: Vector3;
  34205. } | AbstractMesh[]): Vector3;
  34206. /**
  34207. * Merge the array of meshes into a single mesh for performance reasons.
  34208. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34209. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34210. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34211. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34212. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34213. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34214. * @returns a new mesh
  34215. */
  34216. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34217. /** @hidden */
  34218. addInstance(instance: InstancedMesh): void;
  34219. /** @hidden */
  34220. removeInstance(instance: InstancedMesh): void;
  34221. }
  34222. }
  34223. declare module BABYLON {
  34224. /**
  34225. * The options Interface for creating a Capsule Mesh
  34226. */
  34227. export interface ICreateCapsuleOptions {
  34228. /** The Orientation of the capsule. Default : Vector3.Up() */
  34229. orientation?: Vector3;
  34230. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34231. subdivisions: number;
  34232. /** Number of cylindrical segments on the capsule. */
  34233. tessellation: number;
  34234. /** Height or Length of the capsule. */
  34235. height: number;
  34236. /** Radius of the capsule. */
  34237. radius: number;
  34238. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34239. capSubdivisions: number;
  34240. /** Overwrite for the top radius. */
  34241. radiusTop?: number;
  34242. /** Overwrite for the bottom radius. */
  34243. radiusBottom?: number;
  34244. /** Overwrite for the top capSubdivisions. */
  34245. topCapSubdivisions?: number;
  34246. /** Overwrite for the bottom capSubdivisions. */
  34247. bottomCapSubdivisions?: number;
  34248. }
  34249. /**
  34250. * Class containing static functions to help procedurally build meshes
  34251. */
  34252. export class CapsuleBuilder {
  34253. /**
  34254. * Creates a capsule or a pill mesh
  34255. * @param name defines the name of the mesh
  34256. * @param options The constructors options.
  34257. * @param scene The scene the mesh is scoped to.
  34258. * @returns Capsule Mesh
  34259. */
  34260. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34261. }
  34262. }
  34263. declare module BABYLON {
  34264. /**
  34265. * Define an interface for all classes that will get and set the data on vertices
  34266. */
  34267. export interface IGetSetVerticesData {
  34268. /**
  34269. * Gets a boolean indicating if specific vertex data is present
  34270. * @param kind defines the vertex data kind to use
  34271. * @returns true is data kind is present
  34272. */
  34273. isVerticesDataPresent(kind: string): boolean;
  34274. /**
  34275. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34276. * @param kind defines the data kind (Position, normal, etc...)
  34277. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34278. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34279. * @returns a float array containing vertex data
  34280. */
  34281. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34282. /**
  34283. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34284. * @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.
  34285. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34286. * @returns the indices array or an empty array if the mesh has no geometry
  34287. */
  34288. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34289. /**
  34290. * Set specific vertex data
  34291. * @param kind defines the data kind (Position, normal, etc...)
  34292. * @param data defines the vertex data to use
  34293. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34294. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34295. */
  34296. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34297. /**
  34298. * Update a specific associated vertex buffer
  34299. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34300. * - VertexBuffer.PositionKind
  34301. * - VertexBuffer.UVKind
  34302. * - VertexBuffer.UV2Kind
  34303. * - VertexBuffer.UV3Kind
  34304. * - VertexBuffer.UV4Kind
  34305. * - VertexBuffer.UV5Kind
  34306. * - VertexBuffer.UV6Kind
  34307. * - VertexBuffer.ColorKind
  34308. * - VertexBuffer.MatricesIndicesKind
  34309. * - VertexBuffer.MatricesIndicesExtraKind
  34310. * - VertexBuffer.MatricesWeightsKind
  34311. * - VertexBuffer.MatricesWeightsExtraKind
  34312. * @param data defines the data source
  34313. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34314. * @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)
  34315. */
  34316. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34317. /**
  34318. * Creates a new index buffer
  34319. * @param indices defines the indices to store in the index buffer
  34320. * @param totalVertices defines the total number of vertices (could be null)
  34321. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34322. */
  34323. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34324. }
  34325. /**
  34326. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34327. */
  34328. export class VertexData {
  34329. /**
  34330. * Mesh side orientation : usually the external or front surface
  34331. */
  34332. static readonly FRONTSIDE: number;
  34333. /**
  34334. * Mesh side orientation : usually the internal or back surface
  34335. */
  34336. static readonly BACKSIDE: number;
  34337. /**
  34338. * Mesh side orientation : both internal and external or front and back surfaces
  34339. */
  34340. static readonly DOUBLESIDE: number;
  34341. /**
  34342. * Mesh side orientation : by default, `FRONTSIDE`
  34343. */
  34344. static readonly DEFAULTSIDE: number;
  34345. /**
  34346. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34347. */
  34348. positions: Nullable<FloatArray>;
  34349. /**
  34350. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34351. */
  34352. normals: Nullable<FloatArray>;
  34353. /**
  34354. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34355. */
  34356. tangents: Nullable<FloatArray>;
  34357. /**
  34358. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34359. */
  34360. uvs: Nullable<FloatArray>;
  34361. /**
  34362. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34363. */
  34364. uvs2: Nullable<FloatArray>;
  34365. /**
  34366. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34367. */
  34368. uvs3: Nullable<FloatArray>;
  34369. /**
  34370. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34371. */
  34372. uvs4: Nullable<FloatArray>;
  34373. /**
  34374. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34375. */
  34376. uvs5: Nullable<FloatArray>;
  34377. /**
  34378. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34379. */
  34380. uvs6: Nullable<FloatArray>;
  34381. /**
  34382. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34383. */
  34384. colors: Nullable<FloatArray>;
  34385. /**
  34386. * 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).
  34387. */
  34388. matricesIndices: Nullable<FloatArray>;
  34389. /**
  34390. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34391. */
  34392. matricesWeights: Nullable<FloatArray>;
  34393. /**
  34394. * An array extending the number of possible indices
  34395. */
  34396. matricesIndicesExtra: Nullable<FloatArray>;
  34397. /**
  34398. * An array extending the number of possible weights when the number of indices is extended
  34399. */
  34400. matricesWeightsExtra: Nullable<FloatArray>;
  34401. /**
  34402. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34403. */
  34404. indices: Nullable<IndicesArray>;
  34405. /**
  34406. * Uses the passed data array to set the set the values for the specified kind of data
  34407. * @param data a linear array of floating numbers
  34408. * @param kind the type of data that is being set, eg positions, colors etc
  34409. */
  34410. set(data: FloatArray, kind: string): void;
  34411. /**
  34412. * Associates the vertexData to the passed Mesh.
  34413. * Sets it as updatable or not (default `false`)
  34414. * @param mesh the mesh the vertexData is applied to
  34415. * @param updatable when used and having the value true allows new data to update the vertexData
  34416. * @returns the VertexData
  34417. */
  34418. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34419. /**
  34420. * Associates the vertexData to the passed Geometry.
  34421. * Sets it as updatable or not (default `false`)
  34422. * @param geometry the geometry the vertexData is applied to
  34423. * @param updatable when used and having the value true allows new data to update the vertexData
  34424. * @returns VertexData
  34425. */
  34426. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34427. /**
  34428. * Updates the associated mesh
  34429. * @param mesh the mesh to be updated
  34430. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34431. * @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
  34432. * @returns VertexData
  34433. */
  34434. updateMesh(mesh: Mesh): VertexData;
  34435. /**
  34436. * Updates the associated geometry
  34437. * @param geometry the geometry to be updated
  34438. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34439. * @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
  34440. * @returns VertexData.
  34441. */
  34442. updateGeometry(geometry: Geometry): VertexData;
  34443. private _applyTo;
  34444. private _update;
  34445. /**
  34446. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34447. * @param matrix the transforming matrix
  34448. * @returns the VertexData
  34449. */
  34450. transform(matrix: Matrix): VertexData;
  34451. /**
  34452. * Merges the passed VertexData into the current one
  34453. * @param other the VertexData to be merged into the current one
  34454. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34455. * @returns the modified VertexData
  34456. */
  34457. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34458. private _mergeElement;
  34459. private _validate;
  34460. /**
  34461. * Serializes the VertexData
  34462. * @returns a serialized object
  34463. */
  34464. serialize(): any;
  34465. /**
  34466. * Extracts the vertexData from a mesh
  34467. * @param mesh the mesh from which to extract the VertexData
  34468. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34469. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34470. * @returns the object VertexData associated to the passed mesh
  34471. */
  34472. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34473. /**
  34474. * Extracts the vertexData from the geometry
  34475. * @param geometry the geometry from which to extract the VertexData
  34476. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34477. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34478. * @returns the object VertexData associated to the passed mesh
  34479. */
  34480. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34481. private static _ExtractFrom;
  34482. /**
  34483. * Creates the VertexData for a Ribbon
  34484. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34485. * * pathArray array of paths, each of which an array of successive Vector3
  34486. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34487. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34488. * * 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
  34489. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34490. * * 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)
  34491. * * 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)
  34492. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34493. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34494. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34495. * @returns the VertexData of the ribbon
  34496. */
  34497. static CreateRibbon(options: {
  34498. pathArray: Vector3[][];
  34499. closeArray?: boolean;
  34500. closePath?: boolean;
  34501. offset?: number;
  34502. sideOrientation?: number;
  34503. frontUVs?: Vector4;
  34504. backUVs?: Vector4;
  34505. invertUV?: boolean;
  34506. uvs?: Vector2[];
  34507. colors?: Color4[];
  34508. }): VertexData;
  34509. /**
  34510. * Creates the VertexData for a box
  34511. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34512. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34513. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34514. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34515. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34516. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34517. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34519. * * 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)
  34520. * * 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)
  34521. * @returns the VertexData of the box
  34522. */
  34523. static CreateBox(options: {
  34524. size?: number;
  34525. width?: number;
  34526. height?: number;
  34527. depth?: number;
  34528. faceUV?: Vector4[];
  34529. faceColors?: Color4[];
  34530. sideOrientation?: number;
  34531. frontUVs?: Vector4;
  34532. backUVs?: Vector4;
  34533. }): VertexData;
  34534. /**
  34535. * Creates the VertexData for a tiled box
  34536. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34537. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34538. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34539. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34541. * @returns the VertexData of the box
  34542. */
  34543. static CreateTiledBox(options: {
  34544. pattern?: number;
  34545. width?: number;
  34546. height?: number;
  34547. depth?: number;
  34548. tileSize?: number;
  34549. tileWidth?: number;
  34550. tileHeight?: number;
  34551. alignHorizontal?: number;
  34552. alignVertical?: number;
  34553. faceUV?: Vector4[];
  34554. faceColors?: Color4[];
  34555. sideOrientation?: number;
  34556. }): VertexData;
  34557. /**
  34558. * Creates the VertexData for a tiled plane
  34559. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34560. * * pattern a limited pattern arrangement depending on the number
  34561. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34562. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34563. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34565. * * 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)
  34566. * * 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)
  34567. * @returns the VertexData of the tiled plane
  34568. */
  34569. static CreateTiledPlane(options: {
  34570. pattern?: number;
  34571. tileSize?: number;
  34572. tileWidth?: number;
  34573. tileHeight?: number;
  34574. size?: number;
  34575. width?: number;
  34576. height?: number;
  34577. alignHorizontal?: number;
  34578. alignVertical?: number;
  34579. sideOrientation?: number;
  34580. frontUVs?: Vector4;
  34581. backUVs?: Vector4;
  34582. }): VertexData;
  34583. /**
  34584. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34585. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34586. * * segments sets the number of horizontal strips optional, default 32
  34587. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34588. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34589. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34590. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34591. * * 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
  34592. * * 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
  34593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34594. * * 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)
  34595. * * 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)
  34596. * @returns the VertexData of the ellipsoid
  34597. */
  34598. static CreateSphere(options: {
  34599. segments?: number;
  34600. diameter?: number;
  34601. diameterX?: number;
  34602. diameterY?: number;
  34603. diameterZ?: number;
  34604. arc?: number;
  34605. slice?: number;
  34606. sideOrientation?: number;
  34607. frontUVs?: Vector4;
  34608. backUVs?: Vector4;
  34609. }): VertexData;
  34610. /**
  34611. * Creates the VertexData for a cylinder, cone or prism
  34612. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34613. * * height sets the height (y direction) of the cylinder, optional, default 2
  34614. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34615. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34616. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34617. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34618. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34619. * * 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
  34620. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34621. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34622. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34623. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34625. * * 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)
  34626. * * 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)
  34627. * @returns the VertexData of the cylinder, cone or prism
  34628. */
  34629. static CreateCylinder(options: {
  34630. height?: number;
  34631. diameterTop?: number;
  34632. diameterBottom?: number;
  34633. diameter?: number;
  34634. tessellation?: number;
  34635. subdivisions?: number;
  34636. arc?: number;
  34637. faceColors?: Color4[];
  34638. faceUV?: Vector4[];
  34639. hasRings?: boolean;
  34640. enclose?: boolean;
  34641. sideOrientation?: number;
  34642. frontUVs?: Vector4;
  34643. backUVs?: Vector4;
  34644. }): VertexData;
  34645. /**
  34646. * Creates the VertexData for a torus
  34647. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34648. * * diameter the diameter of the torus, optional default 1
  34649. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34650. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34651. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34652. * * 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)
  34653. * * 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)
  34654. * @returns the VertexData of the torus
  34655. */
  34656. static CreateTorus(options: {
  34657. diameter?: number;
  34658. thickness?: number;
  34659. tessellation?: number;
  34660. sideOrientation?: number;
  34661. frontUVs?: Vector4;
  34662. backUVs?: Vector4;
  34663. }): VertexData;
  34664. /**
  34665. * Creates the VertexData of the LineSystem
  34666. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34667. * - lines an array of lines, each line being an array of successive Vector3
  34668. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34669. * @returns the VertexData of the LineSystem
  34670. */
  34671. static CreateLineSystem(options: {
  34672. lines: Vector3[][];
  34673. colors?: Nullable<Color4[][]>;
  34674. }): VertexData;
  34675. /**
  34676. * Create the VertexData for a DashedLines
  34677. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34678. * - points an array successive Vector3
  34679. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34680. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34681. * - dashNb the intended total number of dashes, optional, default 200
  34682. * @returns the VertexData for the DashedLines
  34683. */
  34684. static CreateDashedLines(options: {
  34685. points: Vector3[];
  34686. dashSize?: number;
  34687. gapSize?: number;
  34688. dashNb?: number;
  34689. }): VertexData;
  34690. /**
  34691. * Creates the VertexData for a Ground
  34692. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34693. * - width the width (x direction) of the ground, optional, default 1
  34694. * - height the height (z direction) of the ground, optional, default 1
  34695. * - subdivisions the number of subdivisions per side, optional, default 1
  34696. * @returns the VertexData of the Ground
  34697. */
  34698. static CreateGround(options: {
  34699. width?: number;
  34700. height?: number;
  34701. subdivisions?: number;
  34702. subdivisionsX?: number;
  34703. subdivisionsY?: number;
  34704. }): VertexData;
  34705. /**
  34706. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34707. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34708. * * xmin the ground minimum X coordinate, optional, default -1
  34709. * * zmin the ground minimum Z coordinate, optional, default -1
  34710. * * xmax the ground maximum X coordinate, optional, default 1
  34711. * * zmax the ground maximum Z coordinate, optional, default 1
  34712. * * 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}
  34713. * * 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}
  34714. * @returns the VertexData of the TiledGround
  34715. */
  34716. static CreateTiledGround(options: {
  34717. xmin: number;
  34718. zmin: number;
  34719. xmax: number;
  34720. zmax: number;
  34721. subdivisions?: {
  34722. w: number;
  34723. h: number;
  34724. };
  34725. precision?: {
  34726. w: number;
  34727. h: number;
  34728. };
  34729. }): VertexData;
  34730. /**
  34731. * Creates the VertexData of the Ground designed from a heightmap
  34732. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34733. * * width the width (x direction) of the ground
  34734. * * height the height (z direction) of the ground
  34735. * * subdivisions the number of subdivisions per side
  34736. * * minHeight the minimum altitude on the ground, optional, default 0
  34737. * * maxHeight the maximum altitude on the ground, optional default 1
  34738. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34739. * * buffer the array holding the image color data
  34740. * * bufferWidth the width of image
  34741. * * bufferHeight the height of image
  34742. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34743. * @returns the VertexData of the Ground designed from a heightmap
  34744. */
  34745. static CreateGroundFromHeightMap(options: {
  34746. width: number;
  34747. height: number;
  34748. subdivisions: number;
  34749. minHeight: number;
  34750. maxHeight: number;
  34751. colorFilter: Color3;
  34752. buffer: Uint8Array;
  34753. bufferWidth: number;
  34754. bufferHeight: number;
  34755. alphaFilter: number;
  34756. }): VertexData;
  34757. /**
  34758. * Creates the VertexData for a Plane
  34759. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34760. * * size sets the width and height of the plane to the value of size, optional default 1
  34761. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34762. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34763. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34764. * * 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)
  34765. * * 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)
  34766. * @returns the VertexData of the box
  34767. */
  34768. static CreatePlane(options: {
  34769. size?: number;
  34770. width?: number;
  34771. height?: number;
  34772. sideOrientation?: number;
  34773. frontUVs?: Vector4;
  34774. backUVs?: Vector4;
  34775. }): VertexData;
  34776. /**
  34777. * Creates the VertexData of the Disc or regular Polygon
  34778. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34779. * * radius the radius of the disc, optional default 0.5
  34780. * * tessellation the number of polygon sides, optional, default 64
  34781. * * 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
  34782. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34783. * * 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)
  34784. * * 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)
  34785. * @returns the VertexData of the box
  34786. */
  34787. static CreateDisc(options: {
  34788. radius?: number;
  34789. tessellation?: number;
  34790. arc?: number;
  34791. sideOrientation?: number;
  34792. frontUVs?: Vector4;
  34793. backUVs?: Vector4;
  34794. }): VertexData;
  34795. /**
  34796. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34797. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34798. * @param polygon a mesh built from polygonTriangulation.build()
  34799. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34800. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34801. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34802. * @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)
  34803. * @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)
  34804. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34805. * @returns the VertexData of the Polygon
  34806. */
  34807. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34808. /**
  34809. * Creates the VertexData of the IcoSphere
  34810. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34811. * * radius the radius of the IcoSphere, optional default 1
  34812. * * radiusX allows stretching in the x direction, optional, default radius
  34813. * * radiusY allows stretching in the y direction, optional, default radius
  34814. * * radiusZ allows stretching in the z direction, optional, default radius
  34815. * * flat when true creates a flat shaded mesh, optional, default true
  34816. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34817. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34818. * * 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)
  34819. * * 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)
  34820. * @returns the VertexData of the IcoSphere
  34821. */
  34822. static CreateIcoSphere(options: {
  34823. radius?: number;
  34824. radiusX?: number;
  34825. radiusY?: number;
  34826. radiusZ?: number;
  34827. flat?: boolean;
  34828. subdivisions?: number;
  34829. sideOrientation?: number;
  34830. frontUVs?: Vector4;
  34831. backUVs?: Vector4;
  34832. }): VertexData;
  34833. /**
  34834. * Creates the VertexData for a Polyhedron
  34835. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34836. * * type provided types are:
  34837. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34838. * * 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)
  34839. * * size the size of the IcoSphere, optional default 1
  34840. * * sizeX allows stretching in the x direction, optional, default size
  34841. * * sizeY allows stretching in the y direction, optional, default size
  34842. * * sizeZ allows stretching in the z direction, optional, default size
  34843. * * 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
  34844. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34845. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34846. * * flat when true creates a flat shaded mesh, optional, default true
  34847. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34848. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34849. * * 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)
  34850. * * 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)
  34851. * @returns the VertexData of the Polyhedron
  34852. */
  34853. static CreatePolyhedron(options: {
  34854. type?: number;
  34855. size?: number;
  34856. sizeX?: number;
  34857. sizeY?: number;
  34858. sizeZ?: number;
  34859. custom?: any;
  34860. faceUV?: Vector4[];
  34861. faceColors?: Color4[];
  34862. flat?: boolean;
  34863. sideOrientation?: number;
  34864. frontUVs?: Vector4;
  34865. backUVs?: Vector4;
  34866. }): VertexData;
  34867. /**
  34868. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34869. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34870. * @returns the VertexData of the Capsule
  34871. */
  34872. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34873. /**
  34874. * Creates the VertexData for a TorusKnot
  34875. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34876. * * radius the radius of the torus knot, optional, default 2
  34877. * * tube the thickness of the tube, optional, default 0.5
  34878. * * radialSegments the number of sides on each tube segments, optional, default 32
  34879. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34880. * * p the number of windings around the z axis, optional, default 2
  34881. * * q the number of windings around the x axis, optional, default 3
  34882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34883. * * 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)
  34884. * * 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)
  34885. * @returns the VertexData of the Torus Knot
  34886. */
  34887. static CreateTorusKnot(options: {
  34888. radius?: number;
  34889. tube?: number;
  34890. radialSegments?: number;
  34891. tubularSegments?: number;
  34892. p?: number;
  34893. q?: number;
  34894. sideOrientation?: number;
  34895. frontUVs?: Vector4;
  34896. backUVs?: Vector4;
  34897. }): VertexData;
  34898. /**
  34899. * Compute normals for given positions and indices
  34900. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34901. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34902. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34903. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34904. * * facetNormals : optional array of facet normals (vector3)
  34905. * * facetPositions : optional array of facet positions (vector3)
  34906. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34907. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34908. * * bInfo : optional bounding info, required for facetPartitioning computation
  34909. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34910. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34911. * * useRightHandedSystem: optional boolean to for right handed system computation
  34912. * * depthSort : optional boolean to enable the facet depth sort computation
  34913. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34914. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34915. */
  34916. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34917. facetNormals?: any;
  34918. facetPositions?: any;
  34919. facetPartitioning?: any;
  34920. ratio?: number;
  34921. bInfo?: any;
  34922. bbSize?: Vector3;
  34923. subDiv?: any;
  34924. useRightHandedSystem?: boolean;
  34925. depthSort?: boolean;
  34926. distanceTo?: Vector3;
  34927. depthSortedFacets?: any;
  34928. }): void;
  34929. /** @hidden */
  34930. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34931. /**
  34932. * Applies VertexData created from the imported parameters to the geometry
  34933. * @param parsedVertexData the parsed data from an imported file
  34934. * @param geometry the geometry to apply the VertexData to
  34935. */
  34936. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34937. }
  34938. }
  34939. declare module BABYLON {
  34940. /**
  34941. * Class containing static functions to help procedurally build meshes
  34942. */
  34943. export class DiscBuilder {
  34944. /**
  34945. * Creates a plane polygonal mesh. By default, this is a disc
  34946. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34947. * * 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
  34948. * * 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
  34949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34950. * * 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
  34951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34952. * @param name defines the name of the mesh
  34953. * @param options defines the options used to create the mesh
  34954. * @param scene defines the hosting scene
  34955. * @returns the plane polygonal mesh
  34956. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34957. */
  34958. static CreateDisc(name: string, options: {
  34959. radius?: number;
  34960. tessellation?: number;
  34961. arc?: number;
  34962. updatable?: boolean;
  34963. sideOrientation?: number;
  34964. frontUVs?: Vector4;
  34965. backUVs?: Vector4;
  34966. }, scene?: Nullable<Scene>): Mesh;
  34967. }
  34968. }
  34969. declare module BABYLON {
  34970. /**
  34971. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34972. *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.
  34973. * The SPS is also a particle system. It provides some methods to manage the particles.
  34974. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34975. *
  34976. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34977. */
  34978. export class SolidParticleSystem implements IDisposable {
  34979. /**
  34980. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34981. * Example : var p = SPS.particles[i];
  34982. */
  34983. particles: SolidParticle[];
  34984. /**
  34985. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34986. */
  34987. nbParticles: number;
  34988. /**
  34989. * If the particles must ever face the camera (default false). Useful for planar particles.
  34990. */
  34991. billboard: boolean;
  34992. /**
  34993. * Recompute normals when adding a shape
  34994. */
  34995. recomputeNormals: boolean;
  34996. /**
  34997. * This a counter ofr your own usage. It's not set by any SPS functions.
  34998. */
  34999. counter: number;
  35000. /**
  35001. * The SPS name. This name is also given to the underlying mesh.
  35002. */
  35003. name: string;
  35004. /**
  35005. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35006. */
  35007. mesh: Mesh;
  35008. /**
  35009. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35010. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35011. */
  35012. vars: any;
  35013. /**
  35014. * This array is populated when the SPS is set as 'pickable'.
  35015. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35016. * Each element of this array is an object `{idx: int, faceId: int}`.
  35017. * `idx` is the picked particle index in the `SPS.particles` array
  35018. * `faceId` is the picked face index counted within this particle.
  35019. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35020. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35021. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35022. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35023. */
  35024. pickedParticles: {
  35025. idx: number;
  35026. faceId: number;
  35027. }[];
  35028. /**
  35029. * This array is populated when the SPS is set as 'pickable'
  35030. * Each key of this array is a submesh index.
  35031. * Each element of this array is a second array defined like this :
  35032. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35033. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35034. * `idx` is the picked particle index in the `SPS.particles` array
  35035. * `faceId` is the picked face index counted within this particle.
  35036. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35037. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35038. */
  35039. pickedBySubMesh: {
  35040. idx: number;
  35041. faceId: number;
  35042. }[][];
  35043. /**
  35044. * This array is populated when `enableDepthSort` is set to true.
  35045. * Each element of this array is an instance of the class DepthSortedParticle.
  35046. */
  35047. depthSortedParticles: DepthSortedParticle[];
  35048. /**
  35049. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35050. * @hidden
  35051. */
  35052. _bSphereOnly: boolean;
  35053. /**
  35054. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35055. * @hidden
  35056. */
  35057. _bSphereRadiusFactor: number;
  35058. private _scene;
  35059. private _positions;
  35060. private _indices;
  35061. private _normals;
  35062. private _colors;
  35063. private _uvs;
  35064. private _indices32;
  35065. private _positions32;
  35066. private _normals32;
  35067. private _fixedNormal32;
  35068. private _colors32;
  35069. private _uvs32;
  35070. private _index;
  35071. private _updatable;
  35072. private _pickable;
  35073. private _isVisibilityBoxLocked;
  35074. private _alwaysVisible;
  35075. private _depthSort;
  35076. private _expandable;
  35077. private _shapeCounter;
  35078. private _copy;
  35079. private _color;
  35080. private _computeParticleColor;
  35081. private _computeParticleTexture;
  35082. private _computeParticleRotation;
  35083. private _computeParticleVertex;
  35084. private _computeBoundingBox;
  35085. private _depthSortParticles;
  35086. private _camera;
  35087. private _mustUnrotateFixedNormals;
  35088. private _particlesIntersect;
  35089. private _needs32Bits;
  35090. private _isNotBuilt;
  35091. private _lastParticleId;
  35092. private _idxOfId;
  35093. private _multimaterialEnabled;
  35094. private _useModelMaterial;
  35095. private _indicesByMaterial;
  35096. private _materialIndexes;
  35097. private _depthSortFunction;
  35098. private _materialSortFunction;
  35099. private _materials;
  35100. private _multimaterial;
  35101. private _materialIndexesById;
  35102. private _defaultMaterial;
  35103. private _autoUpdateSubMeshes;
  35104. private _tmpVertex;
  35105. /**
  35106. * Creates a SPS (Solid Particle System) object.
  35107. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35108. * @param scene (Scene) is the scene in which the SPS is added.
  35109. * @param options defines the options of the sps e.g.
  35110. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35111. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35112. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35113. * * 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.
  35114. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35115. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35116. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35117. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35118. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35119. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35120. */
  35121. constructor(name: string, scene: Scene, options?: {
  35122. updatable?: boolean;
  35123. isPickable?: boolean;
  35124. enableDepthSort?: boolean;
  35125. particleIntersection?: boolean;
  35126. boundingSphereOnly?: boolean;
  35127. bSphereRadiusFactor?: number;
  35128. expandable?: boolean;
  35129. useModelMaterial?: boolean;
  35130. enableMultiMaterial?: boolean;
  35131. });
  35132. /**
  35133. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35134. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35135. * @returns the created mesh
  35136. */
  35137. buildMesh(): Mesh;
  35138. /**
  35139. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35140. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35141. * Thus the particles generated from `digest()` have their property `position` set yet.
  35142. * @param mesh ( Mesh ) is the mesh to be digested
  35143. * @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
  35144. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35145. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35146. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35147. * @returns the current SPS
  35148. */
  35149. digest(mesh: Mesh, options?: {
  35150. facetNb?: number;
  35151. number?: number;
  35152. delta?: number;
  35153. storage?: [];
  35154. }): SolidParticleSystem;
  35155. /**
  35156. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35157. * @hidden
  35158. */
  35159. private _unrotateFixedNormals;
  35160. /**
  35161. * Resets the temporary working copy particle
  35162. * @hidden
  35163. */
  35164. private _resetCopy;
  35165. /**
  35166. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35167. * @param p the current index in the positions array to be updated
  35168. * @param ind the current index in the indices array
  35169. * @param shape a Vector3 array, the shape geometry
  35170. * @param positions the positions array to be updated
  35171. * @param meshInd the shape indices array
  35172. * @param indices the indices array to be updated
  35173. * @param meshUV the shape uv array
  35174. * @param uvs the uv array to be updated
  35175. * @param meshCol the shape color array
  35176. * @param colors the color array to be updated
  35177. * @param meshNor the shape normals array
  35178. * @param normals the normals array to be updated
  35179. * @param idx the particle index
  35180. * @param idxInShape the particle index in its shape
  35181. * @param options the addShape() method passed options
  35182. * @model the particle model
  35183. * @hidden
  35184. */
  35185. private _meshBuilder;
  35186. /**
  35187. * Returns a shape Vector3 array from positions float array
  35188. * @param positions float array
  35189. * @returns a vector3 array
  35190. * @hidden
  35191. */
  35192. private _posToShape;
  35193. /**
  35194. * Returns a shapeUV array from a float uvs (array deep copy)
  35195. * @param uvs as a float array
  35196. * @returns a shapeUV array
  35197. * @hidden
  35198. */
  35199. private _uvsToShapeUV;
  35200. /**
  35201. * Adds a new particle object in the particles array
  35202. * @param idx particle index in particles array
  35203. * @param id particle id
  35204. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35205. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35206. * @param model particle ModelShape object
  35207. * @param shapeId model shape identifier
  35208. * @param idxInShape index of the particle in the current model
  35209. * @param bInfo model bounding info object
  35210. * @param storage target storage array, if any
  35211. * @hidden
  35212. */
  35213. private _addParticle;
  35214. /**
  35215. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35216. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35217. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35218. * @param nb (positive integer) the number of particles to be created from this model
  35219. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35220. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35221. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35222. * @returns the number of shapes in the system
  35223. */
  35224. addShape(mesh: Mesh, nb: number, options?: {
  35225. positionFunction?: any;
  35226. vertexFunction?: any;
  35227. storage?: [];
  35228. }): number;
  35229. /**
  35230. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35231. * @hidden
  35232. */
  35233. private _rebuildParticle;
  35234. /**
  35235. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35236. * @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.
  35237. * @returns the SPS.
  35238. */
  35239. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35240. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35241. * Returns an array with the removed particles.
  35242. * 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.
  35243. * The SPS can't be empty so at least one particle needs to remain in place.
  35244. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35245. * @param start index of the first particle to remove
  35246. * @param end index of the last particle to remove (included)
  35247. * @returns an array populated with the removed particles
  35248. */
  35249. removeParticles(start: number, end: number): SolidParticle[];
  35250. /**
  35251. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35252. * @param solidParticleArray an array populated with Solid Particles objects
  35253. * @returns the SPS
  35254. */
  35255. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35256. /**
  35257. * Creates a new particle and modifies the SPS mesh geometry :
  35258. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35259. * - calls _addParticle() to populate the particle array
  35260. * factorized code from addShape() and insertParticlesFromArray()
  35261. * @param idx particle index in the particles array
  35262. * @param i particle index in its shape
  35263. * @param modelShape particle ModelShape object
  35264. * @param shape shape vertex array
  35265. * @param meshInd shape indices array
  35266. * @param meshUV shape uv array
  35267. * @param meshCol shape color array
  35268. * @param meshNor shape normals array
  35269. * @param bbInfo shape bounding info
  35270. * @param storage target particle storage
  35271. * @options addShape() passed options
  35272. * @hidden
  35273. */
  35274. private _insertNewParticle;
  35275. /**
  35276. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35277. * This method calls `updateParticle()` for each particle of the SPS.
  35278. * For an animated SPS, it is usually called within the render loop.
  35279. * 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.
  35280. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35281. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35282. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35283. * @returns the SPS.
  35284. */
  35285. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35286. /**
  35287. * Disposes the SPS.
  35288. */
  35289. dispose(): void;
  35290. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35291. * idx is the particle index in the SPS
  35292. * faceId is the picked face index counted within this particle.
  35293. * Returns null if the pickInfo can't identify a picked particle.
  35294. * @param pickingInfo (PickingInfo object)
  35295. * @returns {idx: number, faceId: number} or null
  35296. */
  35297. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35298. idx: number;
  35299. faceId: number;
  35300. }>;
  35301. /**
  35302. * Returns a SolidParticle object from its identifier : particle.id
  35303. * @param id (integer) the particle Id
  35304. * @returns the searched particle or null if not found in the SPS.
  35305. */
  35306. getParticleById(id: number): Nullable<SolidParticle>;
  35307. /**
  35308. * Returns a new array populated with the particles having the passed shapeId.
  35309. * @param shapeId (integer) the shape identifier
  35310. * @returns a new solid particle array
  35311. */
  35312. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35313. /**
  35314. * Populates the passed array "ref" with the particles having the passed shapeId.
  35315. * @param shapeId the shape identifier
  35316. * @returns the SPS
  35317. * @param ref
  35318. */
  35319. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35320. /**
  35321. * Computes the required SubMeshes according the materials assigned to the particles.
  35322. * @returns the solid particle system.
  35323. * Does nothing if called before the SPS mesh is built.
  35324. */
  35325. computeSubMeshes(): SolidParticleSystem;
  35326. /**
  35327. * Sorts the solid particles by material when MultiMaterial is enabled.
  35328. * Updates the indices32 array.
  35329. * Updates the indicesByMaterial array.
  35330. * Updates the mesh indices array.
  35331. * @returns the SPS
  35332. * @hidden
  35333. */
  35334. private _sortParticlesByMaterial;
  35335. /**
  35336. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35337. * @hidden
  35338. */
  35339. private _setMaterialIndexesById;
  35340. /**
  35341. * Returns an array with unique values of Materials from the passed array
  35342. * @param array the material array to be checked and filtered
  35343. * @hidden
  35344. */
  35345. private _filterUniqueMaterialId;
  35346. /**
  35347. * Sets a new Standard Material as _defaultMaterial if not already set.
  35348. * @hidden
  35349. */
  35350. private _setDefaultMaterial;
  35351. /**
  35352. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35353. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35354. * @returns the SPS.
  35355. */
  35356. refreshVisibleSize(): SolidParticleSystem;
  35357. /**
  35358. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35359. * @param size the size (float) of the visibility box
  35360. * note : this doesn't lock the SPS mesh bounding box.
  35361. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35362. */
  35363. setVisibilityBox(size: number): void;
  35364. /**
  35365. * Gets whether the SPS as always visible or not
  35366. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35367. */
  35368. get isAlwaysVisible(): boolean;
  35369. /**
  35370. * Sets the SPS as always visible or not
  35371. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35372. */
  35373. set isAlwaysVisible(val: boolean);
  35374. /**
  35375. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35376. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35377. */
  35378. set isVisibilityBoxLocked(val: boolean);
  35379. /**
  35380. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35381. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35382. */
  35383. get isVisibilityBoxLocked(): boolean;
  35384. /**
  35385. * Tells to `setParticles()` to compute the particle rotations or not.
  35386. * Default value : true. The SPS is faster when it's set to false.
  35387. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35388. */
  35389. set computeParticleRotation(val: boolean);
  35390. /**
  35391. * Tells to `setParticles()` to compute the particle colors or not.
  35392. * Default value : true. The SPS is faster when it's set to false.
  35393. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35394. */
  35395. set computeParticleColor(val: boolean);
  35396. set computeParticleTexture(val: boolean);
  35397. /**
  35398. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35399. * Default value : false. The SPS is faster when it's set to false.
  35400. * Note : the particle custom vertex positions aren't stored values.
  35401. */
  35402. set computeParticleVertex(val: boolean);
  35403. /**
  35404. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35405. */
  35406. set computeBoundingBox(val: boolean);
  35407. /**
  35408. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35409. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35410. * Default : `true`
  35411. */
  35412. set depthSortParticles(val: boolean);
  35413. /**
  35414. * Gets if `setParticles()` computes the particle rotations or not.
  35415. * Default value : true. The SPS is faster when it's set to false.
  35416. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35417. */
  35418. get computeParticleRotation(): boolean;
  35419. /**
  35420. * Gets if `setParticles()` computes the particle colors or not.
  35421. * Default value : true. The SPS is faster when it's set to false.
  35422. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35423. */
  35424. get computeParticleColor(): boolean;
  35425. /**
  35426. * Gets if `setParticles()` computes the particle textures or not.
  35427. * Default value : true. The SPS is faster when it's set to false.
  35428. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35429. */
  35430. get computeParticleTexture(): boolean;
  35431. /**
  35432. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35433. * Default value : false. The SPS is faster when it's set to false.
  35434. * Note : the particle custom vertex positions aren't stored values.
  35435. */
  35436. get computeParticleVertex(): boolean;
  35437. /**
  35438. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35439. */
  35440. get computeBoundingBox(): boolean;
  35441. /**
  35442. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35443. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35444. * Default : `true`
  35445. */
  35446. get depthSortParticles(): boolean;
  35447. /**
  35448. * Gets if the SPS is created as expandable at construction time.
  35449. * Default : `false`
  35450. */
  35451. get expandable(): boolean;
  35452. /**
  35453. * Gets if the SPS supports the Multi Materials
  35454. */
  35455. get multimaterialEnabled(): boolean;
  35456. /**
  35457. * Gets if the SPS uses the model materials for its own multimaterial.
  35458. */
  35459. get useModelMaterial(): boolean;
  35460. /**
  35461. * The SPS used material array.
  35462. */
  35463. get materials(): Material[];
  35464. /**
  35465. * Sets the SPS MultiMaterial from the passed materials.
  35466. * Note : the passed array is internally copied and not used then by reference.
  35467. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35468. */
  35469. setMultiMaterial(materials: Material[]): void;
  35470. /**
  35471. * The SPS computed multimaterial object
  35472. */
  35473. get multimaterial(): MultiMaterial;
  35474. set multimaterial(mm: MultiMaterial);
  35475. /**
  35476. * If the subMeshes must be updated on the next call to setParticles()
  35477. */
  35478. get autoUpdateSubMeshes(): boolean;
  35479. set autoUpdateSubMeshes(val: boolean);
  35480. /**
  35481. * This function does nothing. It may be overwritten to set all the particle first values.
  35482. * The SPS doesn't call this function, you may have to call it by your own.
  35483. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35484. */
  35485. initParticles(): void;
  35486. /**
  35487. * This function does nothing. It may be overwritten to recycle a particle.
  35488. * The SPS doesn't call this function, you may have to call it by your own.
  35489. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35490. * @param particle The particle to recycle
  35491. * @returns the recycled particle
  35492. */
  35493. recycleParticle(particle: SolidParticle): SolidParticle;
  35494. /**
  35495. * Updates a particle : this function should be overwritten by the user.
  35496. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35497. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35498. * @example : just set a particle position or velocity and recycle conditions
  35499. * @param particle The particle to update
  35500. * @returns the updated particle
  35501. */
  35502. updateParticle(particle: SolidParticle): SolidParticle;
  35503. /**
  35504. * Updates a vertex of a particle : it can be overwritten by the user.
  35505. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35506. * @param particle the current particle
  35507. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35508. * @param pt the index of the current vertex in the particle shape
  35509. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35510. * @example : just set a vertex particle position or color
  35511. * @returns the sps
  35512. */
  35513. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35514. /**
  35515. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35516. * This does nothing and may be overwritten by the user.
  35517. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35518. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35519. * @param update the boolean update value actually passed to setParticles()
  35520. */
  35521. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35522. /**
  35523. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35524. * This will be passed three parameters.
  35525. * This does nothing and may be overwritten by the user.
  35526. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35527. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35528. * @param update the boolean update value actually passed to setParticles()
  35529. */
  35530. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35531. }
  35532. }
  35533. declare module BABYLON {
  35534. /**
  35535. * Represents one particle of a solid particle system.
  35536. */
  35537. export class SolidParticle {
  35538. /**
  35539. * particle global index
  35540. */
  35541. idx: number;
  35542. /**
  35543. * particle identifier
  35544. */
  35545. id: number;
  35546. /**
  35547. * The color of the particle
  35548. */
  35549. color: Nullable<Color4>;
  35550. /**
  35551. * The world space position of the particle.
  35552. */
  35553. position: Vector3;
  35554. /**
  35555. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35556. */
  35557. rotation: Vector3;
  35558. /**
  35559. * The world space rotation quaternion of the particle.
  35560. */
  35561. rotationQuaternion: Nullable<Quaternion>;
  35562. /**
  35563. * The scaling of the particle.
  35564. */
  35565. scaling: Vector3;
  35566. /**
  35567. * The uvs of the particle.
  35568. */
  35569. uvs: Vector4;
  35570. /**
  35571. * The current speed of the particle.
  35572. */
  35573. velocity: Vector3;
  35574. /**
  35575. * The pivot point in the particle local space.
  35576. */
  35577. pivot: Vector3;
  35578. /**
  35579. * Must the particle be translated from its pivot point in its local space ?
  35580. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35581. * Default : false
  35582. */
  35583. translateFromPivot: boolean;
  35584. /**
  35585. * Is the particle active or not ?
  35586. */
  35587. alive: boolean;
  35588. /**
  35589. * Is the particle visible or not ?
  35590. */
  35591. isVisible: boolean;
  35592. /**
  35593. * Index of this particle in the global "positions" array (Internal use)
  35594. * @hidden
  35595. */
  35596. _pos: number;
  35597. /**
  35598. * @hidden Index of this particle in the global "indices" array (Internal use)
  35599. */
  35600. _ind: number;
  35601. /**
  35602. * @hidden ModelShape of this particle (Internal use)
  35603. */
  35604. _model: ModelShape;
  35605. /**
  35606. * ModelShape id of this particle
  35607. */
  35608. shapeId: number;
  35609. /**
  35610. * Index of the particle in its shape id
  35611. */
  35612. idxInShape: number;
  35613. /**
  35614. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35615. */
  35616. _modelBoundingInfo: BoundingInfo;
  35617. /**
  35618. * @hidden Particle BoundingInfo object (Internal use)
  35619. */
  35620. _boundingInfo: BoundingInfo;
  35621. /**
  35622. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35623. */
  35624. _sps: SolidParticleSystem;
  35625. /**
  35626. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35627. */
  35628. _stillInvisible: boolean;
  35629. /**
  35630. * @hidden Last computed particle rotation matrix
  35631. */
  35632. _rotationMatrix: number[];
  35633. /**
  35634. * Parent particle Id, if any.
  35635. * Default null.
  35636. */
  35637. parentId: Nullable<number>;
  35638. /**
  35639. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35640. */
  35641. materialIndex: Nullable<number>;
  35642. /**
  35643. * Custom object or properties.
  35644. */
  35645. props: Nullable<any>;
  35646. /**
  35647. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35648. * The possible values are :
  35649. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35650. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35651. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35652. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35653. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35654. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35655. * */
  35656. cullingStrategy: number;
  35657. /**
  35658. * @hidden Internal global position in the SPS.
  35659. */
  35660. _globalPosition: Vector3;
  35661. /**
  35662. * Creates a Solid Particle object.
  35663. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35664. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35665. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35666. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35667. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35668. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35669. * @param shapeId (integer) is the model shape identifier in the SPS.
  35670. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35671. * @param sps defines the sps it is associated to
  35672. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35673. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35674. */
  35675. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35676. /**
  35677. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35678. * @param target the particle target
  35679. * @returns the current particle
  35680. */
  35681. copyToRef(target: SolidParticle): SolidParticle;
  35682. /**
  35683. * Legacy support, changed scale to scaling
  35684. */
  35685. get scale(): Vector3;
  35686. /**
  35687. * Legacy support, changed scale to scaling
  35688. */
  35689. set scale(scale: Vector3);
  35690. /**
  35691. * Legacy support, changed quaternion to rotationQuaternion
  35692. */
  35693. get quaternion(): Nullable<Quaternion>;
  35694. /**
  35695. * Legacy support, changed quaternion to rotationQuaternion
  35696. */
  35697. set quaternion(q: Nullable<Quaternion>);
  35698. /**
  35699. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35700. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35701. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35702. * @returns true if it intersects
  35703. */
  35704. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35705. /**
  35706. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35707. * A particle is in the frustum if its bounding box intersects the frustum
  35708. * @param frustumPlanes defines the frustum to test
  35709. * @returns true if the particle is in the frustum planes
  35710. */
  35711. isInFrustum(frustumPlanes: Plane[]): boolean;
  35712. /**
  35713. * get the rotation matrix of the particle
  35714. * @hidden
  35715. */
  35716. getRotationMatrix(m: Matrix): void;
  35717. }
  35718. /**
  35719. * Represents the shape of the model used by one particle of a solid particle system.
  35720. * SPS internal tool, don't use it manually.
  35721. */
  35722. export class ModelShape {
  35723. /**
  35724. * The shape id
  35725. * @hidden
  35726. */
  35727. shapeID: number;
  35728. /**
  35729. * flat array of model positions (internal use)
  35730. * @hidden
  35731. */
  35732. _shape: Vector3[];
  35733. /**
  35734. * flat array of model UVs (internal use)
  35735. * @hidden
  35736. */
  35737. _shapeUV: number[];
  35738. /**
  35739. * color array of the model
  35740. * @hidden
  35741. */
  35742. _shapeColors: number[];
  35743. /**
  35744. * indices array of the model
  35745. * @hidden
  35746. */
  35747. _indices: number[];
  35748. /**
  35749. * normals array of the model
  35750. * @hidden
  35751. */
  35752. _normals: number[];
  35753. /**
  35754. * length of the shape in the model indices array (internal use)
  35755. * @hidden
  35756. */
  35757. _indicesLength: number;
  35758. /**
  35759. * Custom position function (internal use)
  35760. * @hidden
  35761. */
  35762. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35763. /**
  35764. * Custom vertex function (internal use)
  35765. * @hidden
  35766. */
  35767. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35768. /**
  35769. * Model material (internal use)
  35770. * @hidden
  35771. */
  35772. _material: Nullable<Material>;
  35773. /**
  35774. * 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.
  35775. * SPS internal tool, don't use it manually.
  35776. * @hidden
  35777. */
  35778. 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>);
  35779. }
  35780. /**
  35781. * Represents a Depth Sorted Particle in the solid particle system.
  35782. * @hidden
  35783. */
  35784. export class DepthSortedParticle {
  35785. /**
  35786. * Particle index
  35787. */
  35788. idx: number;
  35789. /**
  35790. * Index of the particle in the "indices" array
  35791. */
  35792. ind: number;
  35793. /**
  35794. * Length of the particle shape in the "indices" array
  35795. */
  35796. indicesLength: number;
  35797. /**
  35798. * Squared distance from the particle to the camera
  35799. */
  35800. sqDistance: number;
  35801. /**
  35802. * Material index when used with MultiMaterials
  35803. */
  35804. materialIndex: number;
  35805. /**
  35806. * Creates a new sorted particle
  35807. * @param materialIndex
  35808. */
  35809. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35810. }
  35811. /**
  35812. * Represents a solid particle vertex
  35813. */
  35814. export class SolidParticleVertex {
  35815. /**
  35816. * Vertex position
  35817. */
  35818. position: Vector3;
  35819. /**
  35820. * Vertex color
  35821. */
  35822. color: Color4;
  35823. /**
  35824. * Vertex UV
  35825. */
  35826. uv: Vector2;
  35827. /**
  35828. * Creates a new solid particle vertex
  35829. */
  35830. constructor();
  35831. /** Vertex x coordinate */
  35832. get x(): number;
  35833. set x(val: number);
  35834. /** Vertex y coordinate */
  35835. get y(): number;
  35836. set y(val: number);
  35837. /** Vertex z coordinate */
  35838. get z(): number;
  35839. set z(val: number);
  35840. }
  35841. }
  35842. declare module BABYLON {
  35843. /**
  35844. * @hidden
  35845. */
  35846. export class _MeshCollisionData {
  35847. _checkCollisions: boolean;
  35848. _collisionMask: number;
  35849. _collisionGroup: number;
  35850. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35851. _collider: Nullable<Collider>;
  35852. _oldPositionForCollisions: Vector3;
  35853. _diffPositionForCollisions: Vector3;
  35854. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35855. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35856. _collisionResponse: boolean;
  35857. }
  35858. }
  35859. declare module BABYLON {
  35860. /** @hidden */
  35861. class _FacetDataStorage {
  35862. facetPositions: Vector3[];
  35863. facetNormals: Vector3[];
  35864. facetPartitioning: number[][];
  35865. facetNb: number;
  35866. partitioningSubdivisions: number;
  35867. partitioningBBoxRatio: number;
  35868. facetDataEnabled: boolean;
  35869. facetParameters: any;
  35870. bbSize: Vector3;
  35871. subDiv: {
  35872. max: number;
  35873. X: number;
  35874. Y: number;
  35875. Z: number;
  35876. };
  35877. facetDepthSort: boolean;
  35878. facetDepthSortEnabled: boolean;
  35879. depthSortedIndices: IndicesArray;
  35880. depthSortedFacets: {
  35881. ind: number;
  35882. sqDistance: number;
  35883. }[];
  35884. facetDepthSortFunction: (f1: {
  35885. ind: number;
  35886. sqDistance: number;
  35887. }, f2: {
  35888. ind: number;
  35889. sqDistance: number;
  35890. }) => number;
  35891. facetDepthSortFrom: Vector3;
  35892. facetDepthSortOrigin: Vector3;
  35893. invertedMatrix: Matrix;
  35894. }
  35895. /**
  35896. * @hidden
  35897. **/
  35898. class _InternalAbstractMeshDataInfo {
  35899. _hasVertexAlpha: boolean;
  35900. _useVertexColors: boolean;
  35901. _numBoneInfluencers: number;
  35902. _applyFog: boolean;
  35903. _receiveShadows: boolean;
  35904. _facetData: _FacetDataStorage;
  35905. _visibility: number;
  35906. _skeleton: Nullable<Skeleton>;
  35907. _layerMask: number;
  35908. _computeBonesUsingShaders: boolean;
  35909. _isActive: boolean;
  35910. _onlyForInstances: boolean;
  35911. _isActiveIntermediate: boolean;
  35912. _onlyForInstancesIntermediate: boolean;
  35913. _actAsRegularMesh: boolean;
  35914. _currentLOD: Nullable<AbstractMesh>;
  35915. _currentLODIsUpToDate: boolean;
  35916. }
  35917. /**
  35918. * Class used to store all common mesh properties
  35919. */
  35920. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35921. /** No occlusion */
  35922. static OCCLUSION_TYPE_NONE: number;
  35923. /** Occlusion set to optimisitic */
  35924. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35925. /** Occlusion set to strict */
  35926. static OCCLUSION_TYPE_STRICT: number;
  35927. /** Use an accurante occlusion algorithm */
  35928. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35929. /** Use a conservative occlusion algorithm */
  35930. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35931. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35932. * Test order :
  35933. * Is the bounding sphere outside the frustum ?
  35934. * If not, are the bounding box vertices outside the frustum ?
  35935. * It not, then the cullable object is in the frustum.
  35936. */
  35937. static readonly CULLINGSTRATEGY_STANDARD: number;
  35938. /** Culling strategy : Bounding Sphere Only.
  35939. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35940. * It's also less accurate than the standard because some not visible objects can still be selected.
  35941. * Test : is the bounding sphere outside the frustum ?
  35942. * If not, then the cullable object is in the frustum.
  35943. */
  35944. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35945. /** Culling strategy : Optimistic Inclusion.
  35946. * This in an inclusion test first, then the standard exclusion test.
  35947. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35948. * 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.
  35949. * Anyway, it's as accurate as the standard strategy.
  35950. * Test :
  35951. * Is the cullable object bounding sphere center in the frustum ?
  35952. * If not, apply the default culling strategy.
  35953. */
  35954. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35955. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35956. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35957. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35958. * 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.
  35959. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35960. * Test :
  35961. * Is the cullable object bounding sphere center in the frustum ?
  35962. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35963. */
  35964. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35965. /**
  35966. * No billboard
  35967. */
  35968. static get BILLBOARDMODE_NONE(): number;
  35969. /** Billboard on X axis */
  35970. static get BILLBOARDMODE_X(): number;
  35971. /** Billboard on Y axis */
  35972. static get BILLBOARDMODE_Y(): number;
  35973. /** Billboard on Z axis */
  35974. static get BILLBOARDMODE_Z(): number;
  35975. /** Billboard on all axes */
  35976. static get BILLBOARDMODE_ALL(): number;
  35977. /** Billboard on using position instead of orientation */
  35978. static get BILLBOARDMODE_USE_POSITION(): number;
  35979. /** @hidden */
  35980. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35981. /**
  35982. * The culling strategy to use to check whether the mesh must be rendered or not.
  35983. * This value can be changed at any time and will be used on the next render mesh selection.
  35984. * The possible values are :
  35985. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35986. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35987. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35988. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35989. * Please read each static variable documentation to get details about the culling process.
  35990. * */
  35991. cullingStrategy: number;
  35992. /**
  35993. * Gets the number of facets in the mesh
  35994. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35995. */
  35996. get facetNb(): number;
  35997. /**
  35998. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35999. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36000. */
  36001. get partitioningSubdivisions(): number;
  36002. set partitioningSubdivisions(nb: number);
  36003. /**
  36004. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36005. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36006. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36007. */
  36008. get partitioningBBoxRatio(): number;
  36009. set partitioningBBoxRatio(ratio: number);
  36010. /**
  36011. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36012. * Works only for updatable meshes.
  36013. * Doesn't work with multi-materials
  36014. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36015. */
  36016. get mustDepthSortFacets(): boolean;
  36017. set mustDepthSortFacets(sort: boolean);
  36018. /**
  36019. * The location (Vector3) where the facet depth sort must be computed from.
  36020. * By default, the active camera position.
  36021. * Used only when facet depth sort is enabled
  36022. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36023. */
  36024. get facetDepthSortFrom(): Vector3;
  36025. set facetDepthSortFrom(location: Vector3);
  36026. /**
  36027. * gets a boolean indicating if facetData is enabled
  36028. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36029. */
  36030. get isFacetDataEnabled(): boolean;
  36031. /** @hidden */
  36032. _updateNonUniformScalingState(value: boolean): boolean;
  36033. /**
  36034. * An event triggered when this mesh collides with another one
  36035. */
  36036. onCollideObservable: Observable<AbstractMesh>;
  36037. /** Set a function to call when this mesh collides with another one */
  36038. set onCollide(callback: () => void);
  36039. /**
  36040. * An event triggered when the collision's position changes
  36041. */
  36042. onCollisionPositionChangeObservable: Observable<Vector3>;
  36043. /** Set a function to call when the collision's position changes */
  36044. set onCollisionPositionChange(callback: () => void);
  36045. /**
  36046. * An event triggered when material is changed
  36047. */
  36048. onMaterialChangedObservable: Observable<AbstractMesh>;
  36049. /**
  36050. * Gets or sets the orientation for POV movement & rotation
  36051. */
  36052. definedFacingForward: boolean;
  36053. /** @hidden */
  36054. _occlusionQuery: Nullable<WebGLQuery>;
  36055. /** @hidden */
  36056. _renderingGroup: Nullable<RenderingGroup>;
  36057. /**
  36058. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36059. */
  36060. get visibility(): number;
  36061. /**
  36062. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36063. */
  36064. set visibility(value: number);
  36065. /** Gets or sets the alpha index used to sort transparent meshes
  36066. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36067. */
  36068. alphaIndex: number;
  36069. /**
  36070. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36071. */
  36072. isVisible: boolean;
  36073. /**
  36074. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36075. */
  36076. isPickable: boolean;
  36077. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36078. showSubMeshesBoundingBox: boolean;
  36079. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36080. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36081. */
  36082. isBlocker: boolean;
  36083. /**
  36084. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36085. */
  36086. enablePointerMoveEvents: boolean;
  36087. private _renderingGroupId;
  36088. /**
  36089. * Specifies the rendering group id for this mesh (0 by default)
  36090. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36091. */
  36092. get renderingGroupId(): number;
  36093. set renderingGroupId(value: number);
  36094. private _material;
  36095. /** Gets or sets current material */
  36096. get material(): Nullable<Material>;
  36097. set material(value: Nullable<Material>);
  36098. /**
  36099. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36100. * @see https://doc.babylonjs.com/babylon101/shadows
  36101. */
  36102. get receiveShadows(): boolean;
  36103. set receiveShadows(value: boolean);
  36104. /** Defines color to use when rendering outline */
  36105. outlineColor: Color3;
  36106. /** Define width to use when rendering outline */
  36107. outlineWidth: number;
  36108. /** Defines color to use when rendering overlay */
  36109. overlayColor: Color3;
  36110. /** Defines alpha to use when rendering overlay */
  36111. overlayAlpha: number;
  36112. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36113. get hasVertexAlpha(): boolean;
  36114. set hasVertexAlpha(value: boolean);
  36115. /** 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) */
  36116. get useVertexColors(): boolean;
  36117. set useVertexColors(value: boolean);
  36118. /**
  36119. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36120. */
  36121. get computeBonesUsingShaders(): boolean;
  36122. set computeBonesUsingShaders(value: boolean);
  36123. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36124. get numBoneInfluencers(): number;
  36125. set numBoneInfluencers(value: number);
  36126. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36127. get applyFog(): boolean;
  36128. set applyFog(value: boolean);
  36129. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36130. useOctreeForRenderingSelection: boolean;
  36131. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36132. useOctreeForPicking: boolean;
  36133. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36134. useOctreeForCollisions: boolean;
  36135. /**
  36136. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36137. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36138. */
  36139. get layerMask(): number;
  36140. set layerMask(value: number);
  36141. /**
  36142. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36143. */
  36144. alwaysSelectAsActiveMesh: boolean;
  36145. /**
  36146. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36147. */
  36148. doNotSyncBoundingInfo: boolean;
  36149. /**
  36150. * Gets or sets the current action manager
  36151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36152. */
  36153. actionManager: Nullable<AbstractActionManager>;
  36154. private _meshCollisionData;
  36155. /**
  36156. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36157. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36158. */
  36159. ellipsoid: Vector3;
  36160. /**
  36161. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36162. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36163. */
  36164. ellipsoidOffset: Vector3;
  36165. /**
  36166. * Gets or sets a collision mask used to mask collisions (default is -1).
  36167. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36168. */
  36169. get collisionMask(): number;
  36170. set collisionMask(mask: number);
  36171. /**
  36172. * Gets or sets a collision response flag (default is true).
  36173. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36174. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36175. * to respond to the collision.
  36176. */
  36177. get collisionResponse(): boolean;
  36178. set collisionResponse(response: boolean);
  36179. /**
  36180. * Gets or sets the current collision group mask (-1 by default).
  36181. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36182. */
  36183. get collisionGroup(): number;
  36184. set collisionGroup(mask: number);
  36185. /**
  36186. * Gets or sets current surrounding meshes (null by default).
  36187. *
  36188. * By default collision detection is tested against every mesh in the scene.
  36189. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36190. * meshes will be tested for the collision.
  36191. *
  36192. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36193. */
  36194. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36195. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36196. /**
  36197. * Defines edge width used when edgesRenderer is enabled
  36198. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36199. */
  36200. edgesWidth: number;
  36201. /**
  36202. * Defines edge color used when edgesRenderer is enabled
  36203. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36204. */
  36205. edgesColor: Color4;
  36206. /** @hidden */
  36207. _edgesRenderer: Nullable<IEdgesRenderer>;
  36208. /** @hidden */
  36209. _masterMesh: Nullable<AbstractMesh>;
  36210. /** @hidden */
  36211. _boundingInfo: Nullable<BoundingInfo>;
  36212. /** @hidden */
  36213. _renderId: number;
  36214. /**
  36215. * Gets or sets the list of subMeshes
  36216. * @see https://doc.babylonjs.com/how_to/multi_materials
  36217. */
  36218. subMeshes: SubMesh[];
  36219. /** @hidden */
  36220. _intersectionsInProgress: AbstractMesh[];
  36221. /** @hidden */
  36222. _unIndexed: boolean;
  36223. /** @hidden */
  36224. _lightSources: Light[];
  36225. /** Gets the list of lights affecting that mesh */
  36226. get lightSources(): Light[];
  36227. /** @hidden */
  36228. get _positions(): Nullable<Vector3[]>;
  36229. /** @hidden */
  36230. _waitingData: {
  36231. lods: Nullable<any>;
  36232. actions: Nullable<any>;
  36233. freezeWorldMatrix: Nullable<boolean>;
  36234. };
  36235. /** @hidden */
  36236. _bonesTransformMatrices: Nullable<Float32Array>;
  36237. /** @hidden */
  36238. _transformMatrixTexture: Nullable<RawTexture>;
  36239. /**
  36240. * Gets or sets a skeleton to apply skining transformations
  36241. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36242. */
  36243. set skeleton(value: Nullable<Skeleton>);
  36244. get skeleton(): Nullable<Skeleton>;
  36245. /**
  36246. * An event triggered when the mesh is rebuilt.
  36247. */
  36248. onRebuildObservable: Observable<AbstractMesh>;
  36249. /**
  36250. * The current mesh unifom buffer.
  36251. * @hidden Internal use only.
  36252. */
  36253. _uniformBuffer: UniformBuffer;
  36254. /**
  36255. * Creates a new AbstractMesh
  36256. * @param name defines the name of the mesh
  36257. * @param scene defines the hosting scene
  36258. */
  36259. constructor(name: string, scene?: Nullable<Scene>);
  36260. protected _buildUniformLayout(): void;
  36261. /**
  36262. * Transfer the mesh values to its UBO.
  36263. * @param world The world matrix associated with the mesh
  36264. */
  36265. transferToEffect(world: Matrix): void;
  36266. /**
  36267. * Gets the mesh uniform buffer.
  36268. * @return the uniform buffer of the mesh.
  36269. */
  36270. getMeshUniformBuffer(): UniformBuffer;
  36271. /**
  36272. * Returns the string "AbstractMesh"
  36273. * @returns "AbstractMesh"
  36274. */
  36275. getClassName(): string;
  36276. /**
  36277. * Gets a string representation of the current mesh
  36278. * @param fullDetails defines a boolean indicating if full details must be included
  36279. * @returns a string representation of the current mesh
  36280. */
  36281. toString(fullDetails?: boolean): string;
  36282. /**
  36283. * @hidden
  36284. */
  36285. protected _getEffectiveParent(): Nullable<Node>;
  36286. /** @hidden */
  36287. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36288. /** @hidden */
  36289. _rebuild(): void;
  36290. /** @hidden */
  36291. _resyncLightSources(): void;
  36292. /** @hidden */
  36293. _resyncLightSource(light: Light): void;
  36294. /** @hidden */
  36295. _unBindEffect(): void;
  36296. /** @hidden */
  36297. _removeLightSource(light: Light, dispose: boolean): void;
  36298. private _markSubMeshesAsDirty;
  36299. /** @hidden */
  36300. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36301. /** @hidden */
  36302. _markSubMeshesAsAttributesDirty(): void;
  36303. /** @hidden */
  36304. _markSubMeshesAsMiscDirty(): void;
  36305. /**
  36306. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36307. */
  36308. get scaling(): Vector3;
  36309. set scaling(newScaling: Vector3);
  36310. /**
  36311. * Returns true if the mesh is blocked. Implemented by child classes
  36312. */
  36313. get isBlocked(): boolean;
  36314. /**
  36315. * Returns the mesh itself by default. Implemented by child classes
  36316. * @param camera defines the camera to use to pick the right LOD level
  36317. * @returns the currentAbstractMesh
  36318. */
  36319. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36320. /**
  36321. * Returns 0 by default. Implemented by child classes
  36322. * @returns an integer
  36323. */
  36324. getTotalVertices(): number;
  36325. /**
  36326. * Returns a positive integer : the total number of indices in this mesh geometry.
  36327. * @returns the numner of indices or zero if the mesh has no geometry.
  36328. */
  36329. getTotalIndices(): number;
  36330. /**
  36331. * Returns null by default. Implemented by child classes
  36332. * @returns null
  36333. */
  36334. getIndices(): Nullable<IndicesArray>;
  36335. /**
  36336. * Returns the array of the requested vertex data kind. Implemented by child classes
  36337. * @param kind defines the vertex data kind to use
  36338. * @returns null
  36339. */
  36340. getVerticesData(kind: string): Nullable<FloatArray>;
  36341. /**
  36342. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36343. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36344. * Note that a new underlying VertexBuffer object is created each call.
  36345. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36346. * @param kind defines vertex data kind:
  36347. * * VertexBuffer.PositionKind
  36348. * * VertexBuffer.UVKind
  36349. * * VertexBuffer.UV2Kind
  36350. * * VertexBuffer.UV3Kind
  36351. * * VertexBuffer.UV4Kind
  36352. * * VertexBuffer.UV5Kind
  36353. * * VertexBuffer.UV6Kind
  36354. * * VertexBuffer.ColorKind
  36355. * * VertexBuffer.MatricesIndicesKind
  36356. * * VertexBuffer.MatricesIndicesExtraKind
  36357. * * VertexBuffer.MatricesWeightsKind
  36358. * * VertexBuffer.MatricesWeightsExtraKind
  36359. * @param data defines the data source
  36360. * @param updatable defines if the data must be flagged as updatable (or static)
  36361. * @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
  36362. * @returns the current mesh
  36363. */
  36364. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36365. /**
  36366. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36367. * If the mesh has no geometry, it is simply returned as it is.
  36368. * @param kind defines vertex data kind:
  36369. * * VertexBuffer.PositionKind
  36370. * * VertexBuffer.UVKind
  36371. * * VertexBuffer.UV2Kind
  36372. * * VertexBuffer.UV3Kind
  36373. * * VertexBuffer.UV4Kind
  36374. * * VertexBuffer.UV5Kind
  36375. * * VertexBuffer.UV6Kind
  36376. * * VertexBuffer.ColorKind
  36377. * * VertexBuffer.MatricesIndicesKind
  36378. * * VertexBuffer.MatricesIndicesExtraKind
  36379. * * VertexBuffer.MatricesWeightsKind
  36380. * * VertexBuffer.MatricesWeightsExtraKind
  36381. * @param data defines the data source
  36382. * @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
  36383. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36384. * @returns the current mesh
  36385. */
  36386. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36387. /**
  36388. * Sets the mesh indices,
  36389. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36390. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36391. * @param totalVertices Defines the total number of vertices
  36392. * @returns the current mesh
  36393. */
  36394. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36395. /**
  36396. * Gets a boolean indicating if specific vertex data is present
  36397. * @param kind defines the vertex data kind to use
  36398. * @returns true is data kind is present
  36399. */
  36400. isVerticesDataPresent(kind: string): boolean;
  36401. /**
  36402. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36403. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36404. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36405. * @returns a BoundingInfo
  36406. */
  36407. getBoundingInfo(): BoundingInfo;
  36408. /**
  36409. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36410. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36411. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36412. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36413. * @returns the current mesh
  36414. */
  36415. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36416. /**
  36417. * Overwrite the current bounding info
  36418. * @param boundingInfo defines the new bounding info
  36419. * @returns the current mesh
  36420. */
  36421. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36422. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36423. get useBones(): boolean;
  36424. /** @hidden */
  36425. _preActivate(): void;
  36426. /** @hidden */
  36427. _preActivateForIntermediateRendering(renderId: number): void;
  36428. /** @hidden */
  36429. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36430. /** @hidden */
  36431. _postActivate(): void;
  36432. /** @hidden */
  36433. _freeze(): void;
  36434. /** @hidden */
  36435. _unFreeze(): void;
  36436. /**
  36437. * Gets the current world matrix
  36438. * @returns a Matrix
  36439. */
  36440. getWorldMatrix(): Matrix;
  36441. /** @hidden */
  36442. _getWorldMatrixDeterminant(): number;
  36443. /**
  36444. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36445. */
  36446. get isAnInstance(): boolean;
  36447. /**
  36448. * Gets a boolean indicating if this mesh has instances
  36449. */
  36450. get hasInstances(): boolean;
  36451. /**
  36452. * Gets a boolean indicating if this mesh has thin instances
  36453. */
  36454. get hasThinInstances(): boolean;
  36455. /**
  36456. * Perform relative position change from the point of view of behind the front of the mesh.
  36457. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36458. * Supports definition of mesh facing forward or backward
  36459. * @param amountRight defines the distance on the right axis
  36460. * @param amountUp defines the distance on the up axis
  36461. * @param amountForward defines the distance on the forward axis
  36462. * @returns the current mesh
  36463. */
  36464. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36465. /**
  36466. * Calculate relative position change from the point of view of behind the front of the mesh.
  36467. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36468. * Supports definition of mesh facing forward or backward
  36469. * @param amountRight defines the distance on the right axis
  36470. * @param amountUp defines the distance on the up axis
  36471. * @param amountForward defines the distance on the forward axis
  36472. * @returns the new displacement vector
  36473. */
  36474. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36475. /**
  36476. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36477. * Supports definition of mesh facing forward or backward
  36478. * @param flipBack defines the flip
  36479. * @param twirlClockwise defines the twirl
  36480. * @param tiltRight defines the tilt
  36481. * @returns the current mesh
  36482. */
  36483. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36484. /**
  36485. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36486. * Supports definition of mesh facing forward or backward.
  36487. * @param flipBack defines the flip
  36488. * @param twirlClockwise defines the twirl
  36489. * @param tiltRight defines the tilt
  36490. * @returns the new rotation vector
  36491. */
  36492. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36493. /**
  36494. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36495. * This means the mesh underlying bounding box and sphere are recomputed.
  36496. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36497. * @returns the current mesh
  36498. */
  36499. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36500. /** @hidden */
  36501. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36502. /** @hidden */
  36503. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36504. /** @hidden */
  36505. _updateBoundingInfo(): AbstractMesh;
  36506. /** @hidden */
  36507. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36508. /** @hidden */
  36509. protected _afterComputeWorldMatrix(): void;
  36510. /** @hidden */
  36511. get _effectiveMesh(): AbstractMesh;
  36512. /**
  36513. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36514. * A mesh is in the frustum if its bounding box intersects the frustum
  36515. * @param frustumPlanes defines the frustum to test
  36516. * @returns true if the mesh is in the frustum planes
  36517. */
  36518. isInFrustum(frustumPlanes: Plane[]): boolean;
  36519. /**
  36520. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36521. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36522. * @param frustumPlanes defines the frustum to test
  36523. * @returns true if the mesh is completely in the frustum planes
  36524. */
  36525. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36526. /**
  36527. * True if the mesh intersects another mesh or a SolidParticle object
  36528. * @param mesh defines a target mesh or SolidParticle to test
  36529. * @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)
  36530. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36531. * @returns true if there is an intersection
  36532. */
  36533. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36534. /**
  36535. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36536. * @param point defines the point to test
  36537. * @returns true if there is an intersection
  36538. */
  36539. intersectsPoint(point: Vector3): boolean;
  36540. /**
  36541. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36542. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36543. */
  36544. get checkCollisions(): boolean;
  36545. set checkCollisions(collisionEnabled: boolean);
  36546. /**
  36547. * Gets Collider object used to compute collisions (not physics)
  36548. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36549. */
  36550. get collider(): Nullable<Collider>;
  36551. /**
  36552. * Move the mesh using collision engine
  36553. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36554. * @param displacement defines the requested displacement vector
  36555. * @returns the current mesh
  36556. */
  36557. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36558. private _onCollisionPositionChange;
  36559. /** @hidden */
  36560. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36561. /** @hidden */
  36562. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36563. /** @hidden */
  36564. _checkCollision(collider: Collider): AbstractMesh;
  36565. /** @hidden */
  36566. _generatePointsArray(): boolean;
  36567. /**
  36568. * Checks if the passed Ray intersects with the mesh
  36569. * @param ray defines the ray to use
  36570. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36571. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36572. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36573. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36574. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36575. * @returns the picking info
  36576. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36577. */
  36578. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36579. /**
  36580. * Clones the current mesh
  36581. * @param name defines the mesh name
  36582. * @param newParent defines the new mesh parent
  36583. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36584. * @returns the new mesh
  36585. */
  36586. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36587. /**
  36588. * Disposes all the submeshes of the current meshnp
  36589. * @returns the current mesh
  36590. */
  36591. releaseSubMeshes(): AbstractMesh;
  36592. /**
  36593. * Releases resources associated with this abstract mesh.
  36594. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36595. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36596. */
  36597. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36598. /**
  36599. * Adds the passed mesh as a child to the current mesh
  36600. * @param mesh defines the child mesh
  36601. * @returns the current mesh
  36602. */
  36603. addChild(mesh: AbstractMesh): AbstractMesh;
  36604. /**
  36605. * Removes the passed mesh from the current mesh children list
  36606. * @param mesh defines the child mesh
  36607. * @returns the current mesh
  36608. */
  36609. removeChild(mesh: AbstractMesh): AbstractMesh;
  36610. /** @hidden */
  36611. private _initFacetData;
  36612. /**
  36613. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36614. * This method can be called within the render loop.
  36615. * 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
  36616. * @returns the current mesh
  36617. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36618. */
  36619. updateFacetData(): AbstractMesh;
  36620. /**
  36621. * Returns the facetLocalNormals array.
  36622. * The normals are expressed in the mesh local spac
  36623. * @returns an array of Vector3
  36624. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36625. */
  36626. getFacetLocalNormals(): Vector3[];
  36627. /**
  36628. * Returns the facetLocalPositions array.
  36629. * The facet positions are expressed in the mesh local space
  36630. * @returns an array of Vector3
  36631. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36632. */
  36633. getFacetLocalPositions(): Vector3[];
  36634. /**
  36635. * Returns the facetLocalPartioning array
  36636. * @returns an array of array of numbers
  36637. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36638. */
  36639. getFacetLocalPartitioning(): number[][];
  36640. /**
  36641. * Returns the i-th facet position in the world system.
  36642. * This method allocates a new Vector3 per call
  36643. * @param i defines the facet index
  36644. * @returns a new Vector3
  36645. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36646. */
  36647. getFacetPosition(i: number): Vector3;
  36648. /**
  36649. * Sets the reference Vector3 with the i-th facet position in the world system
  36650. * @param i defines the facet index
  36651. * @param ref defines the target vector
  36652. * @returns the current mesh
  36653. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36654. */
  36655. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36656. /**
  36657. * Returns the i-th facet normal in the world system.
  36658. * This method allocates a new Vector3 per call
  36659. * @param i defines the facet index
  36660. * @returns a new Vector3
  36661. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36662. */
  36663. getFacetNormal(i: number): Vector3;
  36664. /**
  36665. * Sets the reference Vector3 with the i-th facet normal in the world system
  36666. * @param i defines the facet index
  36667. * @param ref defines the target vector
  36668. * @returns the current mesh
  36669. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36670. */
  36671. getFacetNormalToRef(i: number, ref: Vector3): this;
  36672. /**
  36673. * 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)
  36674. * @param x defines x coordinate
  36675. * @param y defines y coordinate
  36676. * @param z defines z coordinate
  36677. * @returns the array of facet indexes
  36678. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36679. */
  36680. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36681. /**
  36682. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36683. * @param projected sets as the (x,y,z) world projection on the facet
  36684. * @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
  36685. * @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
  36686. * @param x defines x coordinate
  36687. * @param y defines y coordinate
  36688. * @param z defines z coordinate
  36689. * @returns the face index if found (or null instead)
  36690. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36691. */
  36692. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36693. /**
  36694. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36695. * @param projected sets as the (x,y,z) local projection on the facet
  36696. * @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
  36697. * @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
  36698. * @param x defines x coordinate
  36699. * @param y defines y coordinate
  36700. * @param z defines z coordinate
  36701. * @returns the face index if found (or null instead)
  36702. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36703. */
  36704. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36705. /**
  36706. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36707. * @returns the parameters
  36708. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36709. */
  36710. getFacetDataParameters(): any;
  36711. /**
  36712. * Disables the feature FacetData and frees the related memory
  36713. * @returns the current mesh
  36714. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36715. */
  36716. disableFacetData(): AbstractMesh;
  36717. /**
  36718. * Updates the AbstractMesh indices array
  36719. * @param indices defines the data source
  36720. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36721. * @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)
  36722. * @returns the current mesh
  36723. */
  36724. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36725. /**
  36726. * Creates new normals data for the mesh
  36727. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36728. * @returns the current mesh
  36729. */
  36730. createNormals(updatable: boolean): AbstractMesh;
  36731. /**
  36732. * Align the mesh with a normal
  36733. * @param normal defines the normal to use
  36734. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36735. * @returns the current mesh
  36736. */
  36737. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36738. /** @hidden */
  36739. _checkOcclusionQuery(): boolean;
  36740. /**
  36741. * Disables the mesh edge rendering mode
  36742. * @returns the currentAbstractMesh
  36743. */
  36744. disableEdgesRendering(): AbstractMesh;
  36745. /**
  36746. * Enables the edge rendering mode on the mesh.
  36747. * This mode makes the mesh edges visible
  36748. * @param epsilon defines the maximal distance between two angles to detect a face
  36749. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36750. * @param options options to the edge renderer
  36751. * @returns the currentAbstractMesh
  36752. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36753. */
  36754. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36755. /**
  36756. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36757. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36758. */
  36759. getConnectedParticleSystems(): IParticleSystem[];
  36760. }
  36761. }
  36762. declare module BABYLON {
  36763. /**
  36764. * Interface used to define ActionEvent
  36765. */
  36766. export interface IActionEvent {
  36767. /** The mesh or sprite that triggered the action */
  36768. source: any;
  36769. /** The X mouse cursor position at the time of the event */
  36770. pointerX: number;
  36771. /** The Y mouse cursor position at the time of the event */
  36772. pointerY: number;
  36773. /** The mesh that is currently pointed at (can be null) */
  36774. meshUnderPointer: Nullable<AbstractMesh>;
  36775. /** the original (browser) event that triggered the ActionEvent */
  36776. sourceEvent?: any;
  36777. /** additional data for the event */
  36778. additionalData?: any;
  36779. }
  36780. /**
  36781. * ActionEvent is the event being sent when an action is triggered.
  36782. */
  36783. export class ActionEvent implements IActionEvent {
  36784. /** The mesh or sprite that triggered the action */
  36785. source: any;
  36786. /** The X mouse cursor position at the time of the event */
  36787. pointerX: number;
  36788. /** The Y mouse cursor position at the time of the event */
  36789. pointerY: number;
  36790. /** The mesh that is currently pointed at (can be null) */
  36791. meshUnderPointer: Nullable<AbstractMesh>;
  36792. /** the original (browser) event that triggered the ActionEvent */
  36793. sourceEvent?: any;
  36794. /** additional data for the event */
  36795. additionalData?: any;
  36796. /**
  36797. * Creates a new ActionEvent
  36798. * @param source The mesh or sprite that triggered the action
  36799. * @param pointerX The X mouse cursor position at the time of the event
  36800. * @param pointerY The Y mouse cursor position at the time of the event
  36801. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36802. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36803. * @param additionalData additional data for the event
  36804. */
  36805. constructor(
  36806. /** The mesh or sprite that triggered the action */
  36807. source: any,
  36808. /** The X mouse cursor position at the time of the event */
  36809. pointerX: number,
  36810. /** The Y mouse cursor position at the time of the event */
  36811. pointerY: number,
  36812. /** The mesh that is currently pointed at (can be null) */
  36813. meshUnderPointer: Nullable<AbstractMesh>,
  36814. /** the original (browser) event that triggered the ActionEvent */
  36815. sourceEvent?: any,
  36816. /** additional data for the event */
  36817. additionalData?: any);
  36818. /**
  36819. * Helper function to auto-create an ActionEvent from a source mesh.
  36820. * @param source The source mesh that triggered the event
  36821. * @param evt The original (browser) event
  36822. * @param additionalData additional data for the event
  36823. * @returns the new ActionEvent
  36824. */
  36825. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36826. /**
  36827. * Helper function to auto-create an ActionEvent from a source sprite
  36828. * @param source The source sprite that triggered the event
  36829. * @param scene Scene associated with the sprite
  36830. * @param evt The original (browser) event
  36831. * @param additionalData additional data for the event
  36832. * @returns the new ActionEvent
  36833. */
  36834. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36835. /**
  36836. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36837. * @param scene the scene where the event occurred
  36838. * @param evt The original (browser) event
  36839. * @returns the new ActionEvent
  36840. */
  36841. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36842. /**
  36843. * Helper function to auto-create an ActionEvent from a primitive
  36844. * @param prim defines the target primitive
  36845. * @param pointerPos defines the pointer position
  36846. * @param evt The original (browser) event
  36847. * @param additionalData additional data for the event
  36848. * @returns the new ActionEvent
  36849. */
  36850. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36851. }
  36852. }
  36853. declare module BABYLON {
  36854. /**
  36855. * Abstract class used to decouple action Manager from scene and meshes.
  36856. * Do not instantiate.
  36857. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36858. */
  36859. export abstract class AbstractActionManager implements IDisposable {
  36860. /** Gets the list of active triggers */
  36861. static Triggers: {
  36862. [key: string]: number;
  36863. };
  36864. /** Gets the cursor to use when hovering items */
  36865. hoverCursor: string;
  36866. /** Gets the list of actions */
  36867. actions: IAction[];
  36868. /**
  36869. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36870. */
  36871. isRecursive: boolean;
  36872. /**
  36873. * Releases all associated resources
  36874. */
  36875. abstract dispose(): void;
  36876. /**
  36877. * Does this action manager has pointer triggers
  36878. */
  36879. abstract get hasPointerTriggers(): boolean;
  36880. /**
  36881. * Does this action manager has pick triggers
  36882. */
  36883. abstract get hasPickTriggers(): boolean;
  36884. /**
  36885. * Process a specific trigger
  36886. * @param trigger defines the trigger to process
  36887. * @param evt defines the event details to be processed
  36888. */
  36889. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36890. /**
  36891. * Does this action manager handles actions of any of the given triggers
  36892. * @param triggers defines the triggers to be tested
  36893. * @return a boolean indicating whether one (or more) of the triggers is handled
  36894. */
  36895. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36896. /**
  36897. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36898. * speed.
  36899. * @param triggerA defines the trigger to be tested
  36900. * @param triggerB defines the trigger to be tested
  36901. * @return a boolean indicating whether one (or more) of the triggers is handled
  36902. */
  36903. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36904. /**
  36905. * Does this action manager handles actions of a given trigger
  36906. * @param trigger defines the trigger to be tested
  36907. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36908. * @return whether the trigger is handled
  36909. */
  36910. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36911. /**
  36912. * Serialize this manager to a JSON object
  36913. * @param name defines the property name to store this manager
  36914. * @returns a JSON representation of this manager
  36915. */
  36916. abstract serialize(name: string): any;
  36917. /**
  36918. * Registers an action to this action manager
  36919. * @param action defines the action to be registered
  36920. * @return the action amended (prepared) after registration
  36921. */
  36922. abstract registerAction(action: IAction): Nullable<IAction>;
  36923. /**
  36924. * Unregisters an action to this action manager
  36925. * @param action defines the action to be unregistered
  36926. * @return a boolean indicating whether the action has been unregistered
  36927. */
  36928. abstract unregisterAction(action: IAction): Boolean;
  36929. /**
  36930. * Does exist one action manager with at least one trigger
  36931. **/
  36932. static get HasTriggers(): boolean;
  36933. /**
  36934. * Does exist one action manager with at least one pick trigger
  36935. **/
  36936. static get HasPickTriggers(): boolean;
  36937. /**
  36938. * Does exist one action manager that handles actions of a given trigger
  36939. * @param trigger defines the trigger to be tested
  36940. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36941. **/
  36942. static HasSpecificTrigger(trigger: number): boolean;
  36943. }
  36944. }
  36945. declare module BABYLON {
  36946. /**
  36947. * Defines how a node can be built from a string name.
  36948. */
  36949. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36950. /**
  36951. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36952. */
  36953. export class Node implements IBehaviorAware<Node> {
  36954. /** @hidden */
  36955. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36956. private static _NodeConstructors;
  36957. /**
  36958. * Add a new node constructor
  36959. * @param type defines the type name of the node to construct
  36960. * @param constructorFunc defines the constructor function
  36961. */
  36962. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36963. /**
  36964. * Returns a node constructor based on type name
  36965. * @param type defines the type name
  36966. * @param name defines the new node name
  36967. * @param scene defines the hosting scene
  36968. * @param options defines optional options to transmit to constructors
  36969. * @returns the new constructor or null
  36970. */
  36971. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36972. /**
  36973. * Gets or sets the name of the node
  36974. */
  36975. name: string;
  36976. /**
  36977. * Gets or sets the id of the node
  36978. */
  36979. id: string;
  36980. /**
  36981. * Gets or sets the unique id of the node
  36982. */
  36983. uniqueId: number;
  36984. /**
  36985. * Gets or sets a string used to store user defined state for the node
  36986. */
  36987. state: string;
  36988. /**
  36989. * Gets or sets an object used to store user defined information for the node
  36990. */
  36991. metadata: any;
  36992. /**
  36993. * For internal use only. Please do not use.
  36994. */
  36995. reservedDataStore: any;
  36996. /**
  36997. * List of inspectable custom properties (used by the Inspector)
  36998. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36999. */
  37000. inspectableCustomProperties: IInspectable[];
  37001. private _doNotSerialize;
  37002. /**
  37003. * Gets or sets a boolean used to define if the node must be serialized
  37004. */
  37005. get doNotSerialize(): boolean;
  37006. set doNotSerialize(value: boolean);
  37007. /** @hidden */
  37008. _isDisposed: boolean;
  37009. /**
  37010. * Gets a list of Animations associated with the node
  37011. */
  37012. animations: Animation[];
  37013. protected _ranges: {
  37014. [name: string]: Nullable<AnimationRange>;
  37015. };
  37016. /**
  37017. * Callback raised when the node is ready to be used
  37018. */
  37019. onReady: Nullable<(node: Node) => void>;
  37020. private _isEnabled;
  37021. private _isParentEnabled;
  37022. private _isReady;
  37023. /** @hidden */
  37024. _currentRenderId: number;
  37025. private _parentUpdateId;
  37026. /** @hidden */
  37027. _childUpdateId: number;
  37028. /** @hidden */
  37029. _waitingParentId: Nullable<string>;
  37030. /** @hidden */
  37031. _scene: Scene;
  37032. /** @hidden */
  37033. _cache: any;
  37034. private _parentNode;
  37035. private _children;
  37036. /** @hidden */
  37037. _worldMatrix: Matrix;
  37038. /** @hidden */
  37039. _worldMatrixDeterminant: number;
  37040. /** @hidden */
  37041. _worldMatrixDeterminantIsDirty: boolean;
  37042. /** @hidden */
  37043. private _sceneRootNodesIndex;
  37044. /**
  37045. * Gets a boolean indicating if the node has been disposed
  37046. * @returns true if the node was disposed
  37047. */
  37048. isDisposed(): boolean;
  37049. /**
  37050. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37051. * @see https://doc.babylonjs.com/how_to/parenting
  37052. */
  37053. set parent(parent: Nullable<Node>);
  37054. get parent(): Nullable<Node>;
  37055. /** @hidden */
  37056. _addToSceneRootNodes(): void;
  37057. /** @hidden */
  37058. _removeFromSceneRootNodes(): void;
  37059. private _animationPropertiesOverride;
  37060. /**
  37061. * Gets or sets the animation properties override
  37062. */
  37063. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37064. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37065. /**
  37066. * Gets a string identifying the name of the class
  37067. * @returns "Node" string
  37068. */
  37069. getClassName(): string;
  37070. /** @hidden */
  37071. readonly _isNode: boolean;
  37072. /**
  37073. * An event triggered when the mesh is disposed
  37074. */
  37075. onDisposeObservable: Observable<Node>;
  37076. private _onDisposeObserver;
  37077. /**
  37078. * Sets a callback that will be raised when the node will be disposed
  37079. */
  37080. set onDispose(callback: () => void);
  37081. /**
  37082. * Creates a new Node
  37083. * @param name the name and id to be given to this node
  37084. * @param scene the scene this node will be added to
  37085. */
  37086. constructor(name: string, scene?: Nullable<Scene>);
  37087. /**
  37088. * Gets the scene of the node
  37089. * @returns a scene
  37090. */
  37091. getScene(): Scene;
  37092. /**
  37093. * Gets the engine of the node
  37094. * @returns a Engine
  37095. */
  37096. getEngine(): Engine;
  37097. private _behaviors;
  37098. /**
  37099. * Attach a behavior to the node
  37100. * @see https://doc.babylonjs.com/features/behaviour
  37101. * @param behavior defines the behavior to attach
  37102. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37103. * @returns the current Node
  37104. */
  37105. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37106. /**
  37107. * Remove an attached behavior
  37108. * @see https://doc.babylonjs.com/features/behaviour
  37109. * @param behavior defines the behavior to attach
  37110. * @returns the current Node
  37111. */
  37112. removeBehavior(behavior: Behavior<Node>): Node;
  37113. /**
  37114. * Gets the list of attached behaviors
  37115. * @see https://doc.babylonjs.com/features/behaviour
  37116. */
  37117. get behaviors(): Behavior<Node>[];
  37118. /**
  37119. * Gets an attached behavior by name
  37120. * @param name defines the name of the behavior to look for
  37121. * @see https://doc.babylonjs.com/features/behaviour
  37122. * @returns null if behavior was not found else the requested behavior
  37123. */
  37124. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37125. /**
  37126. * Returns the latest update of the World matrix
  37127. * @returns a Matrix
  37128. */
  37129. getWorldMatrix(): Matrix;
  37130. /** @hidden */
  37131. _getWorldMatrixDeterminant(): number;
  37132. /**
  37133. * Returns directly the latest state of the mesh World matrix.
  37134. * A Matrix is returned.
  37135. */
  37136. get worldMatrixFromCache(): Matrix;
  37137. /** @hidden */
  37138. _initCache(): void;
  37139. /** @hidden */
  37140. updateCache(force?: boolean): void;
  37141. /** @hidden */
  37142. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37143. /** @hidden */
  37144. _updateCache(ignoreParentClass?: boolean): void;
  37145. /** @hidden */
  37146. _isSynchronized(): boolean;
  37147. /** @hidden */
  37148. _markSyncedWithParent(): void;
  37149. /** @hidden */
  37150. isSynchronizedWithParent(): boolean;
  37151. /** @hidden */
  37152. isSynchronized(): boolean;
  37153. /**
  37154. * Is this node ready to be used/rendered
  37155. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37156. * @return true if the node is ready
  37157. */
  37158. isReady(completeCheck?: boolean): boolean;
  37159. /**
  37160. * Is this node enabled?
  37161. * 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
  37162. * @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
  37163. * @return whether this node (and its parent) is enabled
  37164. */
  37165. isEnabled(checkAncestors?: boolean): boolean;
  37166. /** @hidden */
  37167. protected _syncParentEnabledState(): void;
  37168. /**
  37169. * Set the enabled state of this node
  37170. * @param value defines the new enabled state
  37171. */
  37172. setEnabled(value: boolean): void;
  37173. /**
  37174. * Is this node a descendant of the given node?
  37175. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37176. * @param ancestor defines the parent node to inspect
  37177. * @returns a boolean indicating if this node is a descendant of the given node
  37178. */
  37179. isDescendantOf(ancestor: Node): boolean;
  37180. /** @hidden */
  37181. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37182. /**
  37183. * Will return all nodes that have this node as ascendant
  37184. * @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
  37185. * @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
  37186. * @return all children nodes of all types
  37187. */
  37188. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37189. /**
  37190. * Get all child-meshes of this node
  37191. * @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)
  37192. * @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
  37193. * @returns an array of AbstractMesh
  37194. */
  37195. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37196. /**
  37197. * Get all direct children of this node
  37198. * @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
  37199. * @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)
  37200. * @returns an array of Node
  37201. */
  37202. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37203. /** @hidden */
  37204. _setReady(state: boolean): void;
  37205. /**
  37206. * Get an animation by name
  37207. * @param name defines the name of the animation to look for
  37208. * @returns null if not found else the requested animation
  37209. */
  37210. getAnimationByName(name: string): Nullable<Animation>;
  37211. /**
  37212. * Creates an animation range for this node
  37213. * @param name defines the name of the range
  37214. * @param from defines the starting key
  37215. * @param to defines the end key
  37216. */
  37217. createAnimationRange(name: string, from: number, to: number): void;
  37218. /**
  37219. * Delete a specific animation range
  37220. * @param name defines the name of the range to delete
  37221. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37222. */
  37223. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37224. /**
  37225. * Get an animation range by name
  37226. * @param name defines the name of the animation range to look for
  37227. * @returns null if not found else the requested animation range
  37228. */
  37229. getAnimationRange(name: string): Nullable<AnimationRange>;
  37230. /**
  37231. * Gets the list of all animation ranges defined on this node
  37232. * @returns an array
  37233. */
  37234. getAnimationRanges(): Nullable<AnimationRange>[];
  37235. /**
  37236. * Will start the animation sequence
  37237. * @param name defines the range frames for animation sequence
  37238. * @param loop defines if the animation should loop (false by default)
  37239. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37240. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37241. * @returns the object created for this animation. If range does not exist, it will return null
  37242. */
  37243. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37244. /**
  37245. * Serialize animation ranges into a JSON compatible object
  37246. * @returns serialization object
  37247. */
  37248. serializeAnimationRanges(): any;
  37249. /**
  37250. * Computes the world matrix of the node
  37251. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37252. * @returns the world matrix
  37253. */
  37254. computeWorldMatrix(force?: boolean): Matrix;
  37255. /**
  37256. * Releases resources associated with this node.
  37257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37259. */
  37260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37261. /**
  37262. * Parse animation range data from a serialization object and store them into a given node
  37263. * @param node defines where to store the animation ranges
  37264. * @param parsedNode defines the serialization object to read data from
  37265. * @param scene defines the hosting scene
  37266. */
  37267. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37268. /**
  37269. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37270. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37271. * @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
  37272. * @returns the new bounding vectors
  37273. */
  37274. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37275. min: Vector3;
  37276. max: Vector3;
  37277. };
  37278. }
  37279. }
  37280. declare module BABYLON {
  37281. /**
  37282. * @hidden
  37283. */
  37284. export class _IAnimationState {
  37285. key: number;
  37286. repeatCount: number;
  37287. workValue?: any;
  37288. loopMode?: number;
  37289. offsetValue?: any;
  37290. highLimitValue?: any;
  37291. }
  37292. /**
  37293. * Class used to store any kind of animation
  37294. */
  37295. export class Animation {
  37296. /**Name of the animation */
  37297. name: string;
  37298. /**Property to animate */
  37299. targetProperty: string;
  37300. /**The frames per second of the animation */
  37301. framePerSecond: number;
  37302. /**The data type of the animation */
  37303. dataType: number;
  37304. /**The loop mode of the animation */
  37305. loopMode?: number | undefined;
  37306. /**Specifies if blending should be enabled */
  37307. enableBlending?: boolean | undefined;
  37308. /**
  37309. * Use matrix interpolation instead of using direct key value when animating matrices
  37310. */
  37311. static AllowMatricesInterpolation: boolean;
  37312. /**
  37313. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37314. */
  37315. static AllowMatrixDecomposeForInterpolation: boolean;
  37316. /** Define the Url to load snippets */
  37317. static SnippetUrl: string;
  37318. /** Snippet ID if the animation was created from the snippet server */
  37319. snippetId: string;
  37320. /**
  37321. * Stores the key frames of the animation
  37322. */
  37323. private _keys;
  37324. /**
  37325. * Stores the easing function of the animation
  37326. */
  37327. private _easingFunction;
  37328. /**
  37329. * @hidden Internal use only
  37330. */
  37331. _runtimeAnimations: RuntimeAnimation[];
  37332. /**
  37333. * The set of event that will be linked to this animation
  37334. */
  37335. private _events;
  37336. /**
  37337. * Stores an array of target property paths
  37338. */
  37339. targetPropertyPath: string[];
  37340. /**
  37341. * Stores the blending speed of the animation
  37342. */
  37343. blendingSpeed: number;
  37344. /**
  37345. * Stores the animation ranges for the animation
  37346. */
  37347. private _ranges;
  37348. /**
  37349. * @hidden Internal use
  37350. */
  37351. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37352. /**
  37353. * Sets up an animation
  37354. * @param property The property to animate
  37355. * @param animationType The animation type to apply
  37356. * @param framePerSecond The frames per second of the animation
  37357. * @param easingFunction The easing function used in the animation
  37358. * @returns The created animation
  37359. */
  37360. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37361. /**
  37362. * Create and start an animation on a node
  37363. * @param name defines the name of the global animation that will be run on all nodes
  37364. * @param node defines the root node where the animation will take place
  37365. * @param targetProperty defines property to animate
  37366. * @param framePerSecond defines the number of frame per second yo use
  37367. * @param totalFrame defines the number of frames in total
  37368. * @param from defines the initial value
  37369. * @param to defines the final value
  37370. * @param loopMode defines which loop mode you want to use (off by default)
  37371. * @param easingFunction defines the easing function to use (linear by default)
  37372. * @param onAnimationEnd defines the callback to call when animation end
  37373. * @returns the animatable created for this animation
  37374. */
  37375. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37376. /**
  37377. * Create and start an animation on a node and its descendants
  37378. * @param name defines the name of the global animation that will be run on all nodes
  37379. * @param node defines the root node where the animation will take place
  37380. * @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
  37381. * @param targetProperty defines property to animate
  37382. * @param framePerSecond defines the number of frame per second to use
  37383. * @param totalFrame defines the number of frames in total
  37384. * @param from defines the initial value
  37385. * @param to defines the final value
  37386. * @param loopMode defines which loop mode you want to use (off by default)
  37387. * @param easingFunction defines the easing function to use (linear by default)
  37388. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37389. * @returns the list of animatables created for all nodes
  37390. * @example https://www.babylonjs-playground.com/#MH0VLI
  37391. */
  37392. 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[]>;
  37393. /**
  37394. * Creates a new animation, merges it with the existing animations and starts it
  37395. * @param name Name of the animation
  37396. * @param node Node which contains the scene that begins the animations
  37397. * @param targetProperty Specifies which property to animate
  37398. * @param framePerSecond The frames per second of the animation
  37399. * @param totalFrame The total number of frames
  37400. * @param from The frame at the beginning of the animation
  37401. * @param to The frame at the end of the animation
  37402. * @param loopMode Specifies the loop mode of the animation
  37403. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37404. * @param onAnimationEnd Callback to run once the animation is complete
  37405. * @returns Nullable animation
  37406. */
  37407. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37408. /**
  37409. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37410. * @param sourceAnimation defines the Animation containing keyframes to convert
  37411. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37412. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37413. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37414. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37415. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37416. */
  37417. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37418. /**
  37419. * Transition property of an host to the target Value
  37420. * @param property The property to transition
  37421. * @param targetValue The target Value of the property
  37422. * @param host The object where the property to animate belongs
  37423. * @param scene Scene used to run the animation
  37424. * @param frameRate Framerate (in frame/s) to use
  37425. * @param transition The transition type we want to use
  37426. * @param duration The duration of the animation, in milliseconds
  37427. * @param onAnimationEnd Callback trigger at the end of the animation
  37428. * @returns Nullable animation
  37429. */
  37430. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37431. /**
  37432. * Return the array of runtime animations currently using this animation
  37433. */
  37434. get runtimeAnimations(): RuntimeAnimation[];
  37435. /**
  37436. * Specifies if any of the runtime animations are currently running
  37437. */
  37438. get hasRunningRuntimeAnimations(): boolean;
  37439. /**
  37440. * Initializes the animation
  37441. * @param name Name of the animation
  37442. * @param targetProperty Property to animate
  37443. * @param framePerSecond The frames per second of the animation
  37444. * @param dataType The data type of the animation
  37445. * @param loopMode The loop mode of the animation
  37446. * @param enableBlending Specifies if blending should be enabled
  37447. */
  37448. constructor(
  37449. /**Name of the animation */
  37450. name: string,
  37451. /**Property to animate */
  37452. targetProperty: string,
  37453. /**The frames per second of the animation */
  37454. framePerSecond: number,
  37455. /**The data type of the animation */
  37456. dataType: number,
  37457. /**The loop mode of the animation */
  37458. loopMode?: number | undefined,
  37459. /**Specifies if blending should be enabled */
  37460. enableBlending?: boolean | undefined);
  37461. /**
  37462. * Converts the animation to a string
  37463. * @param fullDetails support for multiple levels of logging within scene loading
  37464. * @returns String form of the animation
  37465. */
  37466. toString(fullDetails?: boolean): string;
  37467. /**
  37468. * Add an event to this animation
  37469. * @param event Event to add
  37470. */
  37471. addEvent(event: AnimationEvent): void;
  37472. /**
  37473. * Remove all events found at the given frame
  37474. * @param frame The frame to remove events from
  37475. */
  37476. removeEvents(frame: number): void;
  37477. /**
  37478. * Retrieves all the events from the animation
  37479. * @returns Events from the animation
  37480. */
  37481. getEvents(): AnimationEvent[];
  37482. /**
  37483. * Creates an animation range
  37484. * @param name Name of the animation range
  37485. * @param from Starting frame of the animation range
  37486. * @param to Ending frame of the animation
  37487. */
  37488. createRange(name: string, from: number, to: number): void;
  37489. /**
  37490. * Deletes an animation range by name
  37491. * @param name Name of the animation range to delete
  37492. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37493. */
  37494. deleteRange(name: string, deleteFrames?: boolean): void;
  37495. /**
  37496. * Gets the animation range by name, or null if not defined
  37497. * @param name Name of the animation range
  37498. * @returns Nullable animation range
  37499. */
  37500. getRange(name: string): Nullable<AnimationRange>;
  37501. /**
  37502. * Gets the key frames from the animation
  37503. * @returns The key frames of the animation
  37504. */
  37505. getKeys(): Array<IAnimationKey>;
  37506. /**
  37507. * Gets the highest frame rate of the animation
  37508. * @returns Highest frame rate of the animation
  37509. */
  37510. getHighestFrame(): number;
  37511. /**
  37512. * Gets the easing function of the animation
  37513. * @returns Easing function of the animation
  37514. */
  37515. getEasingFunction(): IEasingFunction;
  37516. /**
  37517. * Sets the easing function of the animation
  37518. * @param easingFunction A custom mathematical formula for animation
  37519. */
  37520. setEasingFunction(easingFunction: EasingFunction): void;
  37521. /**
  37522. * Interpolates a scalar linearly
  37523. * @param startValue Start value of the animation curve
  37524. * @param endValue End value of the animation curve
  37525. * @param gradient Scalar amount to interpolate
  37526. * @returns Interpolated scalar value
  37527. */
  37528. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37529. /**
  37530. * Interpolates a scalar cubically
  37531. * @param startValue Start value of the animation curve
  37532. * @param outTangent End tangent of the animation
  37533. * @param endValue End value of the animation curve
  37534. * @param inTangent Start tangent of the animation curve
  37535. * @param gradient Scalar amount to interpolate
  37536. * @returns Interpolated scalar value
  37537. */
  37538. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37539. /**
  37540. * Interpolates a quaternion using a spherical linear interpolation
  37541. * @param startValue Start value of the animation curve
  37542. * @param endValue End value of the animation curve
  37543. * @param gradient Scalar amount to interpolate
  37544. * @returns Interpolated quaternion value
  37545. */
  37546. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37547. /**
  37548. * Interpolates a quaternion cubically
  37549. * @param startValue Start value of the animation curve
  37550. * @param outTangent End tangent of the animation curve
  37551. * @param endValue End value of the animation curve
  37552. * @param inTangent Start tangent of the animation curve
  37553. * @param gradient Scalar amount to interpolate
  37554. * @returns Interpolated quaternion value
  37555. */
  37556. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37557. /**
  37558. * Interpolates a Vector3 linearl
  37559. * @param startValue Start value of the animation curve
  37560. * @param endValue End value of the animation curve
  37561. * @param gradient Scalar amount to interpolate
  37562. * @returns Interpolated scalar value
  37563. */
  37564. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37565. /**
  37566. * Interpolates a Vector3 cubically
  37567. * @param startValue Start value of the animation curve
  37568. * @param outTangent End tangent of the animation
  37569. * @param endValue End value of the animation curve
  37570. * @param inTangent Start tangent of the animation curve
  37571. * @param gradient Scalar amount to interpolate
  37572. * @returns InterpolatedVector3 value
  37573. */
  37574. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37575. /**
  37576. * Interpolates a Vector2 linearly
  37577. * @param startValue Start value of the animation curve
  37578. * @param endValue End value of the animation curve
  37579. * @param gradient Scalar amount to interpolate
  37580. * @returns Interpolated Vector2 value
  37581. */
  37582. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37583. /**
  37584. * Interpolates a Vector2 cubically
  37585. * @param startValue Start value of the animation curve
  37586. * @param outTangent End tangent of the animation
  37587. * @param endValue End value of the animation curve
  37588. * @param inTangent Start tangent of the animation curve
  37589. * @param gradient Scalar amount to interpolate
  37590. * @returns Interpolated Vector2 value
  37591. */
  37592. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37593. /**
  37594. * Interpolates a size linearly
  37595. * @param startValue Start value of the animation curve
  37596. * @param endValue End value of the animation curve
  37597. * @param gradient Scalar amount to interpolate
  37598. * @returns Interpolated Size value
  37599. */
  37600. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37601. /**
  37602. * Interpolates a Color3 linearly
  37603. * @param startValue Start value of the animation curve
  37604. * @param endValue End value of the animation curve
  37605. * @param gradient Scalar amount to interpolate
  37606. * @returns Interpolated Color3 value
  37607. */
  37608. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37609. /**
  37610. * Interpolates a Color4 linearly
  37611. * @param startValue Start value of the animation curve
  37612. * @param endValue End value of the animation curve
  37613. * @param gradient Scalar amount to interpolate
  37614. * @returns Interpolated Color3 value
  37615. */
  37616. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37617. /**
  37618. * @hidden Internal use only
  37619. */
  37620. _getKeyValue(value: any): any;
  37621. /**
  37622. * @hidden Internal use only
  37623. */
  37624. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37625. /**
  37626. * Defines the function to use to interpolate matrices
  37627. * @param startValue defines the start matrix
  37628. * @param endValue defines the end matrix
  37629. * @param gradient defines the gradient between both matrices
  37630. * @param result defines an optional target matrix where to store the interpolation
  37631. * @returns the interpolated matrix
  37632. */
  37633. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37634. /**
  37635. * Makes a copy of the animation
  37636. * @returns Cloned animation
  37637. */
  37638. clone(): Animation;
  37639. /**
  37640. * Sets the key frames of the animation
  37641. * @param values The animation key frames to set
  37642. */
  37643. setKeys(values: Array<IAnimationKey>): void;
  37644. /**
  37645. * Serializes the animation to an object
  37646. * @returns Serialized object
  37647. */
  37648. serialize(): any;
  37649. /**
  37650. * Float animation type
  37651. */
  37652. static readonly ANIMATIONTYPE_FLOAT: number;
  37653. /**
  37654. * Vector3 animation type
  37655. */
  37656. static readonly ANIMATIONTYPE_VECTOR3: number;
  37657. /**
  37658. * Quaternion animation type
  37659. */
  37660. static readonly ANIMATIONTYPE_QUATERNION: number;
  37661. /**
  37662. * Matrix animation type
  37663. */
  37664. static readonly ANIMATIONTYPE_MATRIX: number;
  37665. /**
  37666. * Color3 animation type
  37667. */
  37668. static readonly ANIMATIONTYPE_COLOR3: number;
  37669. /**
  37670. * Color3 animation type
  37671. */
  37672. static readonly ANIMATIONTYPE_COLOR4: number;
  37673. /**
  37674. * Vector2 animation type
  37675. */
  37676. static readonly ANIMATIONTYPE_VECTOR2: number;
  37677. /**
  37678. * Size animation type
  37679. */
  37680. static readonly ANIMATIONTYPE_SIZE: number;
  37681. /**
  37682. * Relative Loop Mode
  37683. */
  37684. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37685. /**
  37686. * Cycle Loop Mode
  37687. */
  37688. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37689. /**
  37690. * Constant Loop Mode
  37691. */
  37692. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37693. /** @hidden */
  37694. static _UniversalLerp(left: any, right: any, amount: number): any;
  37695. /**
  37696. * Parses an animation object and creates an animation
  37697. * @param parsedAnimation Parsed animation object
  37698. * @returns Animation object
  37699. */
  37700. static Parse(parsedAnimation: any): Animation;
  37701. /**
  37702. * Appends the serialized animations from the source animations
  37703. * @param source Source containing the animations
  37704. * @param destination Target to store the animations
  37705. */
  37706. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37707. /**
  37708. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37709. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37710. * @param url defines the url to load from
  37711. * @returns a promise that will resolve to the new animation or an array of animations
  37712. */
  37713. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37714. /**
  37715. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37716. * @param snippetId defines the snippet to load
  37717. * @returns a promise that will resolve to the new animation or a new array of animations
  37718. */
  37719. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37720. }
  37721. }
  37722. declare module BABYLON {
  37723. /**
  37724. * Interface containing an array of animations
  37725. */
  37726. export interface IAnimatable {
  37727. /**
  37728. * Array of animations
  37729. */
  37730. animations: Nullable<Array<Animation>>;
  37731. }
  37732. }
  37733. declare module BABYLON {
  37734. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37735. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37736. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37737. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37738. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37739. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37740. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37741. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37742. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37743. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37744. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37745. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37746. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37747. /**
  37748. * Decorator used to define property that can be serialized as reference to a camera
  37749. * @param sourceName defines the name of the property to decorate
  37750. */
  37751. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37752. /**
  37753. * Class used to help serialization objects
  37754. */
  37755. export class SerializationHelper {
  37756. /** @hidden */
  37757. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37758. /** @hidden */
  37759. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37760. /** @hidden */
  37761. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37762. /** @hidden */
  37763. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37764. /**
  37765. * Appends the serialized animations from the source animations
  37766. * @param source Source containing the animations
  37767. * @param destination Target to store the animations
  37768. */
  37769. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37770. /**
  37771. * Static function used to serialized a specific entity
  37772. * @param entity defines the entity to serialize
  37773. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37774. * @returns a JSON compatible object representing the serialization of the entity
  37775. */
  37776. static Serialize<T>(entity: T, serializationObject?: any): any;
  37777. /**
  37778. * Creates a new entity from a serialization data object
  37779. * @param creationFunction defines a function used to instanciated the new entity
  37780. * @param source defines the source serialization data
  37781. * @param scene defines the hosting scene
  37782. * @param rootUrl defines the root url for resources
  37783. * @returns a new entity
  37784. */
  37785. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37786. /**
  37787. * Clones an object
  37788. * @param creationFunction defines the function used to instanciate the new object
  37789. * @param source defines the source object
  37790. * @returns the cloned object
  37791. */
  37792. static Clone<T>(creationFunction: () => T, source: T): T;
  37793. /**
  37794. * Instanciates a new object based on a source one (some data will be shared between both object)
  37795. * @param creationFunction defines the function used to instanciate the new object
  37796. * @param source defines the source object
  37797. * @returns the new object
  37798. */
  37799. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37800. }
  37801. }
  37802. declare module BABYLON {
  37803. /**
  37804. * This is the base class of all the camera used in the application.
  37805. * @see https://doc.babylonjs.com/features/cameras
  37806. */
  37807. export class Camera extends Node {
  37808. /** @hidden */
  37809. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37810. /**
  37811. * This is the default projection mode used by the cameras.
  37812. * It helps recreating a feeling of perspective and better appreciate depth.
  37813. * This is the best way to simulate real life cameras.
  37814. */
  37815. static readonly PERSPECTIVE_CAMERA: number;
  37816. /**
  37817. * This helps creating camera with an orthographic mode.
  37818. * 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.
  37819. */
  37820. static readonly ORTHOGRAPHIC_CAMERA: number;
  37821. /**
  37822. * This is the default FOV mode for perspective cameras.
  37823. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37824. */
  37825. static readonly FOVMODE_VERTICAL_FIXED: number;
  37826. /**
  37827. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37828. */
  37829. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37830. /**
  37831. * This specifies ther is no need for a camera rig.
  37832. * Basically only one eye is rendered corresponding to the camera.
  37833. */
  37834. static readonly RIG_MODE_NONE: number;
  37835. /**
  37836. * Simulates a camera Rig with one blue eye and one red eye.
  37837. * This can be use with 3d blue and red glasses.
  37838. */
  37839. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37840. /**
  37841. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37842. */
  37843. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37844. /**
  37845. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37846. */
  37847. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37848. /**
  37849. * Defines that both eyes of the camera will be rendered over under each other.
  37850. */
  37851. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37852. /**
  37853. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37854. */
  37855. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37856. /**
  37857. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37858. */
  37859. static readonly RIG_MODE_VR: number;
  37860. /**
  37861. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37862. */
  37863. static readonly RIG_MODE_WEBVR: number;
  37864. /**
  37865. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37866. */
  37867. static readonly RIG_MODE_CUSTOM: number;
  37868. /**
  37869. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37870. */
  37871. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37872. /**
  37873. * Define the input manager associated with the camera.
  37874. */
  37875. inputs: CameraInputsManager<Camera>;
  37876. /** @hidden */
  37877. _position: Vector3;
  37878. /**
  37879. * Define the current local position of the camera in the scene
  37880. */
  37881. get position(): Vector3;
  37882. set position(newPosition: Vector3);
  37883. protected _upVector: Vector3;
  37884. /**
  37885. * The vector the camera should consider as up.
  37886. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37887. */
  37888. set upVector(vec: Vector3);
  37889. get upVector(): Vector3;
  37890. /**
  37891. * Define the current limit on the left side for an orthographic camera
  37892. * In scene unit
  37893. */
  37894. orthoLeft: Nullable<number>;
  37895. /**
  37896. * Define the current limit on the right side for an orthographic camera
  37897. * In scene unit
  37898. */
  37899. orthoRight: Nullable<number>;
  37900. /**
  37901. * Define the current limit on the bottom side for an orthographic camera
  37902. * In scene unit
  37903. */
  37904. orthoBottom: Nullable<number>;
  37905. /**
  37906. * Define the current limit on the top side for an orthographic camera
  37907. * In scene unit
  37908. */
  37909. orthoTop: Nullable<number>;
  37910. /**
  37911. * Field Of View is set in Radians. (default is 0.8)
  37912. */
  37913. fov: number;
  37914. /**
  37915. * Define the minimum distance the camera can see from.
  37916. * This is important to note that the depth buffer are not infinite and the closer it starts
  37917. * the more your scene might encounter depth fighting issue.
  37918. */
  37919. minZ: number;
  37920. /**
  37921. * Define the maximum distance the camera can see to.
  37922. * This is important to note that the depth buffer are not infinite and the further it end
  37923. * the more your scene might encounter depth fighting issue.
  37924. */
  37925. maxZ: number;
  37926. /**
  37927. * Define the default inertia of the camera.
  37928. * This helps giving a smooth feeling to the camera movement.
  37929. */
  37930. inertia: number;
  37931. /**
  37932. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37933. */
  37934. mode: number;
  37935. /**
  37936. * Define whether the camera is intermediate.
  37937. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37938. */
  37939. isIntermediate: boolean;
  37940. /**
  37941. * Define the viewport of the camera.
  37942. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37943. */
  37944. viewport: Viewport;
  37945. /**
  37946. * Restricts the camera to viewing objects with the same layerMask.
  37947. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37948. */
  37949. layerMask: number;
  37950. /**
  37951. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37952. */
  37953. fovMode: number;
  37954. /**
  37955. * Rig mode of the camera.
  37956. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37957. * This is normally controlled byt the camera themselves as internal use.
  37958. */
  37959. cameraRigMode: number;
  37960. /**
  37961. * Defines the distance between both "eyes" in case of a RIG
  37962. */
  37963. interaxialDistance: number;
  37964. /**
  37965. * Defines if stereoscopic rendering is done side by side or over under.
  37966. */
  37967. isStereoscopicSideBySide: boolean;
  37968. /**
  37969. * 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
  37970. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37971. * else in the scene. (Eg. security camera)
  37972. *
  37973. * 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)
  37974. */
  37975. customRenderTargets: RenderTargetTexture[];
  37976. /**
  37977. * When set, the camera will render to this render target instead of the default canvas
  37978. *
  37979. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37980. */
  37981. outputRenderTarget: Nullable<RenderTargetTexture>;
  37982. /**
  37983. * Observable triggered when the camera view matrix has changed.
  37984. */
  37985. onViewMatrixChangedObservable: Observable<Camera>;
  37986. /**
  37987. * Observable triggered when the camera Projection matrix has changed.
  37988. */
  37989. onProjectionMatrixChangedObservable: Observable<Camera>;
  37990. /**
  37991. * Observable triggered when the inputs have been processed.
  37992. */
  37993. onAfterCheckInputsObservable: Observable<Camera>;
  37994. /**
  37995. * Observable triggered when reset has been called and applied to the camera.
  37996. */
  37997. onRestoreStateObservable: Observable<Camera>;
  37998. /**
  37999. * Is this camera a part of a rig system?
  38000. */
  38001. isRigCamera: boolean;
  38002. /**
  38003. * If isRigCamera set to true this will be set with the parent camera.
  38004. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38005. */
  38006. rigParent?: Camera;
  38007. /** @hidden */
  38008. _cameraRigParams: any;
  38009. /** @hidden */
  38010. _rigCameras: Camera[];
  38011. /** @hidden */
  38012. _rigPostProcess: Nullable<PostProcess>;
  38013. protected _webvrViewMatrix: Matrix;
  38014. /** @hidden */
  38015. _skipRendering: boolean;
  38016. /** @hidden */
  38017. _projectionMatrix: Matrix;
  38018. /** @hidden */
  38019. _postProcesses: Nullable<PostProcess>[];
  38020. /** @hidden */
  38021. _activeMeshes: SmartArray<AbstractMesh>;
  38022. protected _globalPosition: Vector3;
  38023. /** @hidden */
  38024. _computedViewMatrix: Matrix;
  38025. private _doNotComputeProjectionMatrix;
  38026. private _transformMatrix;
  38027. private _frustumPlanes;
  38028. private _refreshFrustumPlanes;
  38029. private _storedFov;
  38030. private _stateStored;
  38031. /**
  38032. * Instantiates a new camera object.
  38033. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38034. * @see https://doc.babylonjs.com/features/cameras
  38035. * @param name Defines the name of the camera in the scene
  38036. * @param position Defines the position of the camera
  38037. * @param scene Defines the scene the camera belongs too
  38038. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38039. */
  38040. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38041. /**
  38042. * Store current camera state (fov, position, etc..)
  38043. * @returns the camera
  38044. */
  38045. storeState(): Camera;
  38046. /**
  38047. * Restores the camera state values if it has been stored. You must call storeState() first
  38048. */
  38049. protected _restoreStateValues(): boolean;
  38050. /**
  38051. * Restored camera state. You must call storeState() first.
  38052. * @returns true if restored and false otherwise
  38053. */
  38054. restoreState(): boolean;
  38055. /**
  38056. * Gets the class name of the camera.
  38057. * @returns the class name
  38058. */
  38059. getClassName(): string;
  38060. /** @hidden */
  38061. readonly _isCamera: boolean;
  38062. /**
  38063. * Gets a string representation of the camera useful for debug purpose.
  38064. * @param fullDetails Defines that a more verboe level of logging is required
  38065. * @returns the string representation
  38066. */
  38067. toString(fullDetails?: boolean): string;
  38068. /**
  38069. * Gets the current world space position of the camera.
  38070. */
  38071. get globalPosition(): Vector3;
  38072. /**
  38073. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38074. * @returns the active meshe list
  38075. */
  38076. getActiveMeshes(): SmartArray<AbstractMesh>;
  38077. /**
  38078. * Check whether a mesh is part of the current active mesh list of the camera
  38079. * @param mesh Defines the mesh to check
  38080. * @returns true if active, false otherwise
  38081. */
  38082. isActiveMesh(mesh: Mesh): boolean;
  38083. /**
  38084. * Is this camera ready to be used/rendered
  38085. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38086. * @return true if the camera is ready
  38087. */
  38088. isReady(completeCheck?: boolean): boolean;
  38089. /** @hidden */
  38090. _initCache(): void;
  38091. /** @hidden */
  38092. _updateCache(ignoreParentClass?: boolean): void;
  38093. /** @hidden */
  38094. _isSynchronized(): boolean;
  38095. /** @hidden */
  38096. _isSynchronizedViewMatrix(): boolean;
  38097. /** @hidden */
  38098. _isSynchronizedProjectionMatrix(): boolean;
  38099. /**
  38100. * Attach the input controls to a specific dom element to get the input from.
  38101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38102. */
  38103. attachControl(noPreventDefault?: boolean): void;
  38104. /**
  38105. * Attach the input controls to a specific dom element to get the input from.
  38106. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38108. * BACK COMPAT SIGNATURE ONLY.
  38109. */
  38110. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38111. /**
  38112. * Detach the current controls from the specified dom element.
  38113. */
  38114. detachControl(): void;
  38115. /**
  38116. * Detach the current controls from the specified dom element.
  38117. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38118. */
  38119. detachControl(ignored: any): void;
  38120. /**
  38121. * Update the camera state according to the different inputs gathered during the frame.
  38122. */
  38123. update(): void;
  38124. /** @hidden */
  38125. _checkInputs(): void;
  38126. /** @hidden */
  38127. get rigCameras(): Camera[];
  38128. /**
  38129. * Gets the post process used by the rig cameras
  38130. */
  38131. get rigPostProcess(): Nullable<PostProcess>;
  38132. /**
  38133. * Internal, gets the first post proces.
  38134. * @returns the first post process to be run on this camera.
  38135. */
  38136. _getFirstPostProcess(): Nullable<PostProcess>;
  38137. private _cascadePostProcessesToRigCams;
  38138. /**
  38139. * Attach a post process to the camera.
  38140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38141. * @param postProcess The post process to attach to the camera
  38142. * @param insertAt The position of the post process in case several of them are in use in the scene
  38143. * @returns the position the post process has been inserted at
  38144. */
  38145. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38146. /**
  38147. * Detach a post process to the camera.
  38148. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38149. * @param postProcess The post process to detach from the camera
  38150. */
  38151. detachPostProcess(postProcess: PostProcess): void;
  38152. /**
  38153. * Gets the current world matrix of the camera
  38154. */
  38155. getWorldMatrix(): Matrix;
  38156. /** @hidden */
  38157. _getViewMatrix(): Matrix;
  38158. /**
  38159. * Gets the current view matrix of the camera.
  38160. * @param force forces the camera to recompute the matrix without looking at the cached state
  38161. * @returns the view matrix
  38162. */
  38163. getViewMatrix(force?: boolean): Matrix;
  38164. /**
  38165. * Freeze the projection matrix.
  38166. * It will prevent the cache check of the camera projection compute and can speed up perf
  38167. * if no parameter of the camera are meant to change
  38168. * @param projection Defines manually a projection if necessary
  38169. */
  38170. freezeProjectionMatrix(projection?: Matrix): void;
  38171. /**
  38172. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38173. */
  38174. unfreezeProjectionMatrix(): void;
  38175. /**
  38176. * Gets the current projection matrix of the camera.
  38177. * @param force forces the camera to recompute the matrix without looking at the cached state
  38178. * @returns the projection matrix
  38179. */
  38180. getProjectionMatrix(force?: boolean): Matrix;
  38181. /**
  38182. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38183. * @returns a Matrix
  38184. */
  38185. getTransformationMatrix(): Matrix;
  38186. private _updateFrustumPlanes;
  38187. /**
  38188. * Checks if a cullable object (mesh...) is in the camera frustum
  38189. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38190. * @param target The object to check
  38191. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38192. * @returns true if the object is in frustum otherwise false
  38193. */
  38194. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38195. /**
  38196. * Checks if a cullable object (mesh...) is in the camera frustum
  38197. * Unlike isInFrustum this cheks the full bounding box
  38198. * @param target The object to check
  38199. * @returns true if the object is in frustum otherwise false
  38200. */
  38201. isCompletelyInFrustum(target: ICullable): boolean;
  38202. /**
  38203. * Gets a ray in the forward direction from the camera.
  38204. * @param length Defines the length of the ray to create
  38205. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38206. * @param origin Defines the start point of the ray which defaults to the camera position
  38207. * @returns the forward ray
  38208. */
  38209. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38210. /**
  38211. * Gets a ray in the forward direction from the camera.
  38212. * @param refRay the ray to (re)use when setting the values
  38213. * @param length Defines the length of the ray to create
  38214. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38215. * @param origin Defines the start point of the ray which defaults to the camera position
  38216. * @returns the forward ray
  38217. */
  38218. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38219. /**
  38220. * Releases resources associated with this node.
  38221. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38222. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38223. */
  38224. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38225. /** @hidden */
  38226. _isLeftCamera: boolean;
  38227. /**
  38228. * Gets the left camera of a rig setup in case of Rigged Camera
  38229. */
  38230. get isLeftCamera(): boolean;
  38231. /** @hidden */
  38232. _isRightCamera: boolean;
  38233. /**
  38234. * Gets the right camera of a rig setup in case of Rigged Camera
  38235. */
  38236. get isRightCamera(): boolean;
  38237. /**
  38238. * Gets the left camera of a rig setup in case of Rigged Camera
  38239. */
  38240. get leftCamera(): Nullable<FreeCamera>;
  38241. /**
  38242. * Gets the right camera of a rig setup in case of Rigged Camera
  38243. */
  38244. get rightCamera(): Nullable<FreeCamera>;
  38245. /**
  38246. * Gets the left camera target of a rig setup in case of Rigged Camera
  38247. * @returns the target position
  38248. */
  38249. getLeftTarget(): Nullable<Vector3>;
  38250. /**
  38251. * Gets the right camera target of a rig setup in case of Rigged Camera
  38252. * @returns the target position
  38253. */
  38254. getRightTarget(): Nullable<Vector3>;
  38255. /**
  38256. * @hidden
  38257. */
  38258. setCameraRigMode(mode: number, rigParams: any): void;
  38259. /** @hidden */
  38260. static _setStereoscopicRigMode(camera: Camera): void;
  38261. /** @hidden */
  38262. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38263. /** @hidden */
  38264. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38265. /** @hidden */
  38266. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38267. /** @hidden */
  38268. _getVRProjectionMatrix(): Matrix;
  38269. protected _updateCameraRotationMatrix(): void;
  38270. protected _updateWebVRCameraRotationMatrix(): void;
  38271. /**
  38272. * This function MUST be overwritten by the different WebVR cameras available.
  38273. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38274. * @hidden
  38275. */
  38276. _getWebVRProjectionMatrix(): Matrix;
  38277. /**
  38278. * This function MUST be overwritten by the different WebVR cameras available.
  38279. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38280. * @hidden
  38281. */
  38282. _getWebVRViewMatrix(): Matrix;
  38283. /** @hidden */
  38284. setCameraRigParameter(name: string, value: any): void;
  38285. /**
  38286. * needs to be overridden by children so sub has required properties to be copied
  38287. * @hidden
  38288. */
  38289. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38290. /**
  38291. * May need to be overridden by children
  38292. * @hidden
  38293. */
  38294. _updateRigCameras(): void;
  38295. /** @hidden */
  38296. _setupInputs(): void;
  38297. /**
  38298. * Serialiaze the camera setup to a json represention
  38299. * @returns the JSON representation
  38300. */
  38301. serialize(): any;
  38302. /**
  38303. * Clones the current camera.
  38304. * @param name The cloned camera name
  38305. * @returns the cloned camera
  38306. */
  38307. clone(name: string): Camera;
  38308. /**
  38309. * Gets the direction of the camera relative to a given local axis.
  38310. * @param localAxis Defines the reference axis to provide a relative direction.
  38311. * @return the direction
  38312. */
  38313. getDirection(localAxis: Vector3): Vector3;
  38314. /**
  38315. * Returns the current camera absolute rotation
  38316. */
  38317. get absoluteRotation(): Quaternion;
  38318. /**
  38319. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38320. * @param localAxis Defines the reference axis to provide a relative direction.
  38321. * @param result Defines the vector to store the result in
  38322. */
  38323. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38324. /**
  38325. * Gets a camera constructor for a given camera type
  38326. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38327. * @param name The name of the camera the result will be able to instantiate
  38328. * @param scene The scene the result will construct the camera in
  38329. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38330. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38331. * @returns a factory method to construc the camera
  38332. */
  38333. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38334. /**
  38335. * Compute the world matrix of the camera.
  38336. * @returns the camera world matrix
  38337. */
  38338. computeWorldMatrix(): Matrix;
  38339. /**
  38340. * Parse a JSON and creates the camera from the parsed information
  38341. * @param parsedCamera The JSON to parse
  38342. * @param scene The scene to instantiate the camera in
  38343. * @returns the newly constructed camera
  38344. */
  38345. static Parse(parsedCamera: any, scene: Scene): Camera;
  38346. }
  38347. }
  38348. declare module BABYLON {
  38349. /**
  38350. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38351. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38352. */
  38353. export class PostProcessManager {
  38354. private _scene;
  38355. private _indexBuffer;
  38356. private _vertexBuffers;
  38357. /**
  38358. * Creates a new instance PostProcess
  38359. * @param scene The scene that the post process is associated with.
  38360. */
  38361. constructor(scene: Scene);
  38362. private _prepareBuffers;
  38363. private _buildIndexBuffer;
  38364. /**
  38365. * Rebuilds the vertex buffers of the manager.
  38366. * @hidden
  38367. */
  38368. _rebuild(): void;
  38369. /**
  38370. * Prepares a frame to be run through a post process.
  38371. * @param sourceTexture The input texture to the post procesess. (default: null)
  38372. * @param postProcesses An array of post processes to be run. (default: null)
  38373. * @returns True if the post processes were able to be run.
  38374. * @hidden
  38375. */
  38376. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38377. /**
  38378. * Manually render a set of post processes to a texture.
  38379. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38380. * @param postProcesses An array of post processes to be run.
  38381. * @param targetTexture The target texture to render to.
  38382. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38383. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38384. * @param lodLevel defines which lod of the texture to render to
  38385. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38386. */
  38387. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38388. /**
  38389. * Finalize the result of the output of the postprocesses.
  38390. * @param doNotPresent If true the result will not be displayed to the screen.
  38391. * @param targetTexture The target texture to render to.
  38392. * @param faceIndex The index of the face to bind the target texture to.
  38393. * @param postProcesses The array of post processes to render.
  38394. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38395. * @hidden
  38396. */
  38397. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38398. /**
  38399. * Disposes of the post process manager.
  38400. */
  38401. dispose(): void;
  38402. }
  38403. }
  38404. declare module BABYLON {
  38405. /**
  38406. * This Helps creating a texture that will be created from a camera in your scene.
  38407. * It is basically a dynamic texture that could be used to create special effects for instance.
  38408. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38409. */
  38410. export class RenderTargetTexture extends Texture {
  38411. /**
  38412. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38413. */
  38414. static readonly REFRESHRATE_RENDER_ONCE: number;
  38415. /**
  38416. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38417. */
  38418. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38419. /**
  38420. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38421. * the central point of your effect and can save a lot of performances.
  38422. */
  38423. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38424. /**
  38425. * Use this predicate to dynamically define the list of mesh you want to render.
  38426. * If set, the renderList property will be overwritten.
  38427. */
  38428. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38429. private _renderList;
  38430. /**
  38431. * Use this list to define the list of mesh you want to render.
  38432. */
  38433. get renderList(): Nullable<Array<AbstractMesh>>;
  38434. set renderList(value: Nullable<Array<AbstractMesh>>);
  38435. /**
  38436. * Use this function to overload the renderList array at rendering time.
  38437. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38438. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38439. * the cube (if the RTT is a cube, else layerOrFace=0).
  38440. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38441. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38442. * hold dummy elements!
  38443. */
  38444. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38445. private _hookArray;
  38446. /**
  38447. * Define if particles should be rendered in your texture.
  38448. */
  38449. renderParticles: boolean;
  38450. /**
  38451. * Define if sprites should be rendered in your texture.
  38452. */
  38453. renderSprites: boolean;
  38454. /**
  38455. * Define the camera used to render the texture.
  38456. */
  38457. activeCamera: Nullable<Camera>;
  38458. /**
  38459. * Override the mesh isReady function with your own one.
  38460. */
  38461. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38462. /**
  38463. * Override the render function of the texture with your own one.
  38464. */
  38465. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38466. /**
  38467. * Define if camera post processes should be use while rendering the texture.
  38468. */
  38469. useCameraPostProcesses: boolean;
  38470. /**
  38471. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38472. */
  38473. ignoreCameraViewport: boolean;
  38474. private _postProcessManager;
  38475. private _postProcesses;
  38476. private _resizeObserver;
  38477. /**
  38478. * An event triggered when the texture is unbind.
  38479. */
  38480. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38481. /**
  38482. * An event triggered when the texture is unbind.
  38483. */
  38484. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38485. private _onAfterUnbindObserver;
  38486. /**
  38487. * Set a after unbind callback in the texture.
  38488. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38489. */
  38490. set onAfterUnbind(callback: () => void);
  38491. /**
  38492. * An event triggered before rendering the texture
  38493. */
  38494. onBeforeRenderObservable: Observable<number>;
  38495. private _onBeforeRenderObserver;
  38496. /**
  38497. * Set a before render callback in the texture.
  38498. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38499. */
  38500. set onBeforeRender(callback: (faceIndex: number) => void);
  38501. /**
  38502. * An event triggered after rendering the texture
  38503. */
  38504. onAfterRenderObservable: Observable<number>;
  38505. private _onAfterRenderObserver;
  38506. /**
  38507. * Set a after render callback in the texture.
  38508. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38509. */
  38510. set onAfterRender(callback: (faceIndex: number) => void);
  38511. /**
  38512. * An event triggered after the texture clear
  38513. */
  38514. onClearObservable: Observable<Engine>;
  38515. private _onClearObserver;
  38516. /**
  38517. * Set a clear callback in the texture.
  38518. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38519. */
  38520. set onClear(callback: (Engine: Engine) => void);
  38521. /**
  38522. * An event triggered when the texture is resized.
  38523. */
  38524. onResizeObservable: Observable<RenderTargetTexture>;
  38525. /**
  38526. * Define the clear color of the Render Target if it should be different from the scene.
  38527. */
  38528. clearColor: Color4;
  38529. protected _size: number | {
  38530. width: number;
  38531. height: number;
  38532. layers?: number;
  38533. };
  38534. protected _initialSizeParameter: number | {
  38535. width: number;
  38536. height: number;
  38537. } | {
  38538. ratio: number;
  38539. };
  38540. protected _sizeRatio: Nullable<number>;
  38541. /** @hidden */
  38542. _generateMipMaps: boolean;
  38543. protected _renderingManager: RenderingManager;
  38544. /** @hidden */
  38545. _waitingRenderList?: string[];
  38546. protected _doNotChangeAspectRatio: boolean;
  38547. protected _currentRefreshId: number;
  38548. protected _refreshRate: number;
  38549. protected _textureMatrix: Matrix;
  38550. protected _samples: number;
  38551. protected _renderTargetOptions: RenderTargetCreationOptions;
  38552. /**
  38553. * Gets render target creation options that were used.
  38554. */
  38555. get renderTargetOptions(): RenderTargetCreationOptions;
  38556. protected _onRatioRescale(): void;
  38557. /**
  38558. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38559. * It must define where the camera used to render the texture is set
  38560. */
  38561. boundingBoxPosition: Vector3;
  38562. private _boundingBoxSize;
  38563. /**
  38564. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38565. * When defined, the cubemap will switch to local mode
  38566. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38567. * @example https://www.babylonjs-playground.com/#RNASML
  38568. */
  38569. set boundingBoxSize(value: Vector3);
  38570. get boundingBoxSize(): Vector3;
  38571. /**
  38572. * In case the RTT has been created with a depth texture, get the associated
  38573. * depth texture.
  38574. * Otherwise, return null.
  38575. */
  38576. get depthStencilTexture(): Nullable<InternalTexture>;
  38577. /**
  38578. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38579. * or used a shadow, depth texture...
  38580. * @param name The friendly name of the texture
  38581. * @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)
  38582. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38583. * @param generateMipMaps True if mip maps need to be generated after render.
  38584. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38585. * @param type The type of the buffer in the RTT (int, half float, float...)
  38586. * @param isCube True if a cube texture needs to be created
  38587. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38588. * @param generateDepthBuffer True to generate a depth buffer
  38589. * @param generateStencilBuffer True to generate a stencil buffer
  38590. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38591. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38592. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38593. * @param samples sample count to use when creating the RTT
  38594. */
  38595. constructor(name: string, size: number | {
  38596. width: number;
  38597. height: number;
  38598. layers?: number;
  38599. } | {
  38600. ratio: number;
  38601. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean, samples?: number);
  38602. /**
  38603. * Creates a depth stencil texture.
  38604. * This is only available in WebGL 2 or with the depth texture extension available.
  38605. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38606. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38607. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38608. * @param samples sample count of the depth/stencil texture
  38609. */
  38610. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38611. private _processSizeParameter;
  38612. /**
  38613. * Define the number of samples to use in case of MSAA.
  38614. * It defaults to one meaning no MSAA has been enabled.
  38615. */
  38616. get samples(): number;
  38617. set samples(value: number);
  38618. /**
  38619. * Resets the refresh counter of the texture and start bak from scratch.
  38620. * Could be useful to regenerate the texture if it is setup to render only once.
  38621. */
  38622. resetRefreshCounter(): void;
  38623. /**
  38624. * Define the refresh rate of the texture or the rendering frequency.
  38625. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38626. */
  38627. get refreshRate(): number;
  38628. set refreshRate(value: number);
  38629. /**
  38630. * Adds a post process to the render target rendering passes.
  38631. * @param postProcess define the post process to add
  38632. */
  38633. addPostProcess(postProcess: PostProcess): void;
  38634. /**
  38635. * Clear all the post processes attached to the render target
  38636. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38637. */
  38638. clearPostProcesses(dispose?: boolean): void;
  38639. /**
  38640. * Remove one of the post process from the list of attached post processes to the texture
  38641. * @param postProcess define the post process to remove from the list
  38642. */
  38643. removePostProcess(postProcess: PostProcess): void;
  38644. /** @hidden */
  38645. _shouldRender(): boolean;
  38646. /**
  38647. * Gets the actual render size of the texture.
  38648. * @returns the width of the render size
  38649. */
  38650. getRenderSize(): number;
  38651. /**
  38652. * Gets the actual render width of the texture.
  38653. * @returns the width of the render size
  38654. */
  38655. getRenderWidth(): number;
  38656. /**
  38657. * Gets the actual render height of the texture.
  38658. * @returns the height of the render size
  38659. */
  38660. getRenderHeight(): number;
  38661. /**
  38662. * Gets the actual number of layers of the texture.
  38663. * @returns the number of layers
  38664. */
  38665. getRenderLayers(): number;
  38666. /**
  38667. * Get if the texture can be rescaled or not.
  38668. */
  38669. get canRescale(): boolean;
  38670. /**
  38671. * Resize the texture using a ratio.
  38672. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38673. */
  38674. scale(ratio: number): void;
  38675. /**
  38676. * Get the texture reflection matrix used to rotate/transform the reflection.
  38677. * @returns the reflection matrix
  38678. */
  38679. getReflectionTextureMatrix(): Matrix;
  38680. /**
  38681. * Resize the texture to a new desired size.
  38682. * Be carrefull as it will recreate all the data in the new texture.
  38683. * @param size Define the new size. It can be:
  38684. * - a number for squared texture,
  38685. * - an object containing { width: number, height: number }
  38686. * - or an object containing a ratio { ratio: number }
  38687. */
  38688. resize(size: number | {
  38689. width: number;
  38690. height: number;
  38691. } | {
  38692. ratio: number;
  38693. }): void;
  38694. private _defaultRenderListPrepared;
  38695. /**
  38696. * Renders all the objects from the render list into the texture.
  38697. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38698. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38699. */
  38700. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38701. private _bestReflectionRenderTargetDimension;
  38702. private _prepareRenderingManager;
  38703. /**
  38704. * @hidden
  38705. * @param faceIndex face index to bind to if this is a cubetexture
  38706. * @param layer defines the index of the texture to bind in the array
  38707. */
  38708. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38709. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38710. private renderToTarget;
  38711. /**
  38712. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38713. * This allowed control for front to back rendering or reversly depending of the special needs.
  38714. *
  38715. * @param renderingGroupId The rendering group id corresponding to its index
  38716. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38717. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38718. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38719. */
  38720. 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;
  38721. /**
  38722. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38723. *
  38724. * @param renderingGroupId The rendering group id corresponding to its index
  38725. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38726. */
  38727. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38728. /**
  38729. * Clones the texture.
  38730. * @returns the cloned texture
  38731. */
  38732. clone(): RenderTargetTexture;
  38733. /**
  38734. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38735. * @returns The JSON representation of the texture
  38736. */
  38737. serialize(): any;
  38738. /**
  38739. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38740. */
  38741. disposeFramebufferObjects(): void;
  38742. /**
  38743. * Dispose the texture and release its associated resources.
  38744. */
  38745. dispose(): void;
  38746. /** @hidden */
  38747. _rebuild(): void;
  38748. /**
  38749. * Clear the info related to rendering groups preventing retention point in material dispose.
  38750. */
  38751. freeRenderingGroups(): void;
  38752. /**
  38753. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38754. * @returns the view count
  38755. */
  38756. getViewCount(): number;
  38757. }
  38758. }
  38759. declare module BABYLON {
  38760. /**
  38761. * Options to be used when creating an effect.
  38762. */
  38763. export interface IEffectCreationOptions {
  38764. /**
  38765. * Atrributes that will be used in the shader.
  38766. */
  38767. attributes: string[];
  38768. /**
  38769. * Uniform varible names that will be set in the shader.
  38770. */
  38771. uniformsNames: string[];
  38772. /**
  38773. * Uniform buffer variable names that will be set in the shader.
  38774. */
  38775. uniformBuffersNames: string[];
  38776. /**
  38777. * Sampler texture variable names that will be set in the shader.
  38778. */
  38779. samplers: string[];
  38780. /**
  38781. * Define statements that will be set in the shader.
  38782. */
  38783. defines: any;
  38784. /**
  38785. * Possible fallbacks for this effect to improve performance when needed.
  38786. */
  38787. fallbacks: Nullable<IEffectFallbacks>;
  38788. /**
  38789. * Callback that will be called when the shader is compiled.
  38790. */
  38791. onCompiled: Nullable<(effect: Effect) => void>;
  38792. /**
  38793. * Callback that will be called if an error occurs during shader compilation.
  38794. */
  38795. onError: Nullable<(effect: Effect, errors: string) => void>;
  38796. /**
  38797. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38798. */
  38799. indexParameters?: any;
  38800. /**
  38801. * Max number of lights that can be used in the shader.
  38802. */
  38803. maxSimultaneousLights?: number;
  38804. /**
  38805. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38806. */
  38807. transformFeedbackVaryings?: Nullable<string[]>;
  38808. /**
  38809. * 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
  38810. */
  38811. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38812. /**
  38813. * Is this effect rendering to several color attachments ?
  38814. */
  38815. multiTarget?: boolean;
  38816. }
  38817. /**
  38818. * Effect containing vertex and fragment shader that can be executed on an object.
  38819. */
  38820. export class Effect implements IDisposable {
  38821. /**
  38822. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38823. */
  38824. static ShadersRepository: string;
  38825. /**
  38826. * Enable logging of the shader code when a compilation error occurs
  38827. */
  38828. static LogShaderCodeOnCompilationError: boolean;
  38829. /**
  38830. * Name of the effect.
  38831. */
  38832. name: any;
  38833. /**
  38834. * String container all the define statements that should be set on the shader.
  38835. */
  38836. defines: string;
  38837. /**
  38838. * Callback that will be called when the shader is compiled.
  38839. */
  38840. onCompiled: Nullable<(effect: Effect) => void>;
  38841. /**
  38842. * Callback that will be called if an error occurs during shader compilation.
  38843. */
  38844. onError: Nullable<(effect: Effect, errors: string) => void>;
  38845. /**
  38846. * Callback that will be called when effect is bound.
  38847. */
  38848. onBind: Nullable<(effect: Effect) => void>;
  38849. /**
  38850. * Unique ID of the effect.
  38851. */
  38852. uniqueId: number;
  38853. /**
  38854. * Observable that will be called when the shader is compiled.
  38855. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38856. */
  38857. onCompileObservable: Observable<Effect>;
  38858. /**
  38859. * Observable that will be called if an error occurs during shader compilation.
  38860. */
  38861. onErrorObservable: Observable<Effect>;
  38862. /** @hidden */
  38863. _onBindObservable: Nullable<Observable<Effect>>;
  38864. /**
  38865. * @hidden
  38866. * Specifies if the effect was previously ready
  38867. */
  38868. _wasPreviouslyReady: boolean;
  38869. /**
  38870. * Observable that will be called when effect is bound.
  38871. */
  38872. get onBindObservable(): Observable<Effect>;
  38873. /** @hidden */
  38874. _bonesComputationForcedToCPU: boolean;
  38875. /** @hidden */
  38876. _uniformBuffersNames: {
  38877. [key: string]: number;
  38878. };
  38879. /** @hidden */
  38880. _samplerList: string[];
  38881. /** @hidden */
  38882. _multiTarget: boolean;
  38883. private static _uniqueIdSeed;
  38884. private _engine;
  38885. private _uniformBuffersNamesList;
  38886. private _uniformsNames;
  38887. private _samplers;
  38888. private _isReady;
  38889. private _compilationError;
  38890. private _allFallbacksProcessed;
  38891. private _attributesNames;
  38892. private _attributes;
  38893. private _attributeLocationByName;
  38894. private _uniforms;
  38895. /**
  38896. * Key for the effect.
  38897. * @hidden
  38898. */
  38899. _key: string;
  38900. private _indexParameters;
  38901. private _fallbacks;
  38902. private _vertexSourceCodeOverride;
  38903. private _fragmentSourceCodeOverride;
  38904. private _transformFeedbackVaryings;
  38905. /**
  38906. * Compiled shader to webGL program.
  38907. * @hidden
  38908. */
  38909. _pipelineContext: Nullable<IPipelineContext>;
  38910. /** @hidden */
  38911. _vertexSourceCode: string;
  38912. /** @hidden */
  38913. _fragmentSourceCode: string;
  38914. /** @hidden */
  38915. private _rawVertexSourceCode;
  38916. /** @hidden */
  38917. private _rawFragmentSourceCode;
  38918. private static _baseCache;
  38919. private _processingContext;
  38920. /**
  38921. * Instantiates an effect.
  38922. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38923. * @param baseName Name of the effect.
  38924. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38925. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38926. * @param samplers List of sampler variables that will be passed to the shader.
  38927. * @param engine Engine to be used to render the effect
  38928. * @param defines Define statements to be added to the shader.
  38929. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38930. * @param onCompiled Callback that will be called when the shader is compiled.
  38931. * @param onError Callback that will be called if an error occurs during shader compilation.
  38932. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38933. * @param key Effect Key identifying uniquely compiled shader variants
  38934. */
  38935. 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, key?: string);
  38936. private _useFinalCode;
  38937. /**
  38938. * Unique key for this effect
  38939. */
  38940. get key(): string;
  38941. /**
  38942. * If the effect has been compiled and prepared.
  38943. * @returns if the effect is compiled and prepared.
  38944. */
  38945. isReady(): boolean;
  38946. private _isReadyInternal;
  38947. /**
  38948. * The engine the effect was initialized with.
  38949. * @returns the engine.
  38950. */
  38951. getEngine(): Engine;
  38952. /**
  38953. * The pipeline context for this effect
  38954. * @returns the associated pipeline context
  38955. */
  38956. getPipelineContext(): Nullable<IPipelineContext>;
  38957. /**
  38958. * The set of names of attribute variables for the shader.
  38959. * @returns An array of attribute names.
  38960. */
  38961. getAttributesNames(): string[];
  38962. /**
  38963. * Returns the attribute at the given index.
  38964. * @param index The index of the attribute.
  38965. * @returns The location of the attribute.
  38966. */
  38967. getAttributeLocation(index: number): number;
  38968. /**
  38969. * Returns the attribute based on the name of the variable.
  38970. * @param name of the attribute to look up.
  38971. * @returns the attribute location.
  38972. */
  38973. getAttributeLocationByName(name: string): number;
  38974. /**
  38975. * The number of attributes.
  38976. * @returns the numnber of attributes.
  38977. */
  38978. getAttributesCount(): number;
  38979. /**
  38980. * Gets the index of a uniform variable.
  38981. * @param uniformName of the uniform to look up.
  38982. * @returns the index.
  38983. */
  38984. getUniformIndex(uniformName: string): number;
  38985. /**
  38986. * Returns the attribute based on the name of the variable.
  38987. * @param uniformName of the uniform to look up.
  38988. * @returns the location of the uniform.
  38989. */
  38990. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38991. /**
  38992. * Returns an array of sampler variable names
  38993. * @returns The array of sampler variable names.
  38994. */
  38995. getSamplers(): string[];
  38996. /**
  38997. * Returns an array of uniform variable names
  38998. * @returns The array of uniform variable names.
  38999. */
  39000. getUniformNames(): string[];
  39001. /**
  39002. * Returns an array of uniform buffer variable names
  39003. * @returns The array of uniform buffer variable names.
  39004. */
  39005. getUniformBuffersNames(): string[];
  39006. /**
  39007. * Returns the index parameters used to create the effect
  39008. * @returns The index parameters object
  39009. */
  39010. getIndexParameters(): any;
  39011. /**
  39012. * The error from the last compilation.
  39013. * @returns the error string.
  39014. */
  39015. getCompilationError(): string;
  39016. /**
  39017. * Gets a boolean indicating that all fallbacks were used during compilation
  39018. * @returns true if all fallbacks were used
  39019. */
  39020. allFallbacksProcessed(): boolean;
  39021. /**
  39022. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39023. * @param func The callback to be used.
  39024. */
  39025. executeWhenCompiled(func: (effect: Effect) => void): void;
  39026. private _checkIsReady;
  39027. private _loadShader;
  39028. /**
  39029. * Gets the vertex shader source code of this effect
  39030. */
  39031. get vertexSourceCode(): string;
  39032. /**
  39033. * Gets the fragment shader source code of this effect
  39034. */
  39035. get fragmentSourceCode(): string;
  39036. /**
  39037. * Gets the vertex shader source code before it has been processed by the preprocessor
  39038. */
  39039. get rawVertexSourceCode(): string;
  39040. /**
  39041. * Gets the fragment shader source code before it has been processed by the preprocessor
  39042. */
  39043. get rawFragmentSourceCode(): string;
  39044. /**
  39045. * Recompiles the webGL program
  39046. * @param vertexSourceCode The source code for the vertex shader.
  39047. * @param fragmentSourceCode The source code for the fragment shader.
  39048. * @param onCompiled Callback called when completed.
  39049. * @param onError Callback called on error.
  39050. * @hidden
  39051. */
  39052. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39053. /**
  39054. * Prepares the effect
  39055. * @hidden
  39056. */
  39057. _prepareEffect(): void;
  39058. private _getShaderCodeAndErrorLine;
  39059. private _processCompilationErrors;
  39060. /**
  39061. * Checks if the effect is supported. (Must be called after compilation)
  39062. */
  39063. get isSupported(): boolean;
  39064. /**
  39065. * Binds a texture to the engine to be used as output of the shader.
  39066. * @param channel Name of the output variable.
  39067. * @param texture Texture to bind.
  39068. * @hidden
  39069. */
  39070. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39071. /**
  39072. * Sets a texture on the engine to be used in the shader.
  39073. * @param channel Name of the sampler variable.
  39074. * @param texture Texture to set.
  39075. */
  39076. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39077. /**
  39078. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39079. * @param channel Name of the sampler variable.
  39080. * @param texture Texture to set.
  39081. */
  39082. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39083. /**
  39084. * Sets an array of textures on the engine to be used in the shader.
  39085. * @param channel Name of the variable.
  39086. * @param textures Textures to set.
  39087. */
  39088. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39089. /**
  39090. * 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)
  39091. * @param channel Name of the sampler variable.
  39092. * @param postProcess Post process to get the input texture from.
  39093. */
  39094. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39095. /**
  39096. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39097. * 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)
  39098. * @param channel Name of the sampler variable.
  39099. * @param postProcess Post process to get the output texture from.
  39100. */
  39101. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39102. /**
  39103. * Binds a buffer to a uniform.
  39104. * @param buffer Buffer to bind.
  39105. * @param name Name of the uniform variable to bind to.
  39106. */
  39107. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39108. /**
  39109. * Binds block to a uniform.
  39110. * @param blockName Name of the block to bind.
  39111. * @param index Index to bind.
  39112. */
  39113. bindUniformBlock(blockName: string, index: number): void;
  39114. /**
  39115. * Sets an interger value on a uniform variable.
  39116. * @param uniformName Name of the variable.
  39117. * @param value Value to be set.
  39118. * @returns this effect.
  39119. */
  39120. setInt(uniformName: string, value: number): Effect;
  39121. /**
  39122. * Sets an int2 value on a uniform variable.
  39123. * @param uniformName Name of the variable.
  39124. * @param x First int in int2.
  39125. * @param y Second int in int2.
  39126. * @returns this effect.
  39127. */
  39128. setInt2(uniformName: string, x: number, y: number): Effect;
  39129. /**
  39130. * Sets an int3 value on a uniform variable.
  39131. * @param uniformName Name of the variable.
  39132. * @param x First int in int3.
  39133. * @param y Second int in int3.
  39134. * @param z Third int in int3.
  39135. * @returns this effect.
  39136. */
  39137. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39138. /**
  39139. * Sets an int4 value on a uniform variable.
  39140. * @param uniformName Name of the variable.
  39141. * @param x First int in int4.
  39142. * @param y Second int in int4.
  39143. * @param z Third int in int4.
  39144. * @param w Fourth int in int4.
  39145. * @returns this effect.
  39146. */
  39147. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39148. /**
  39149. * Sets an int array on a uniform variable.
  39150. * @param uniformName Name of the variable.
  39151. * @param array array to be set.
  39152. * @returns this effect.
  39153. */
  39154. setIntArray(uniformName: string, array: Int32Array): Effect;
  39155. /**
  39156. * 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)
  39157. * @param uniformName Name of the variable.
  39158. * @param array array to be set.
  39159. * @returns this effect.
  39160. */
  39161. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39162. /**
  39163. * 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)
  39164. * @param uniformName Name of the variable.
  39165. * @param array array to be set.
  39166. * @returns this effect.
  39167. */
  39168. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39169. /**
  39170. * 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)
  39171. * @param uniformName Name of the variable.
  39172. * @param array array to be set.
  39173. * @returns this effect.
  39174. */
  39175. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39176. /**
  39177. * Sets an float array on a uniform variable.
  39178. * @param uniformName Name of the variable.
  39179. * @param array array to be set.
  39180. * @returns this effect.
  39181. */
  39182. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39183. /**
  39184. * 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)
  39185. * @param uniformName Name of the variable.
  39186. * @param array array to be set.
  39187. * @returns this effect.
  39188. */
  39189. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39190. /**
  39191. * 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)
  39192. * @param uniformName Name of the variable.
  39193. * @param array array to be set.
  39194. * @returns this effect.
  39195. */
  39196. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39197. /**
  39198. * 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)
  39199. * @param uniformName Name of the variable.
  39200. * @param array array to be set.
  39201. * @returns this effect.
  39202. */
  39203. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39204. /**
  39205. * Sets an array on a uniform variable.
  39206. * @param uniformName Name of the variable.
  39207. * @param array array to be set.
  39208. * @returns this effect.
  39209. */
  39210. setArray(uniformName: string, array: number[]): Effect;
  39211. /**
  39212. * 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)
  39213. * @param uniformName Name of the variable.
  39214. * @param array array to be set.
  39215. * @returns this effect.
  39216. */
  39217. setArray2(uniformName: string, array: number[]): Effect;
  39218. /**
  39219. * 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)
  39220. * @param uniformName Name of the variable.
  39221. * @param array array to be set.
  39222. * @returns this effect.
  39223. */
  39224. setArray3(uniformName: string, array: number[]): Effect;
  39225. /**
  39226. * 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)
  39227. * @param uniformName Name of the variable.
  39228. * @param array array to be set.
  39229. * @returns this effect.
  39230. */
  39231. setArray4(uniformName: string, array: number[]): Effect;
  39232. /**
  39233. * Sets matrices on a uniform variable.
  39234. * @param uniformName Name of the variable.
  39235. * @param matrices matrices to be set.
  39236. * @returns this effect.
  39237. */
  39238. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39239. /**
  39240. * Sets matrix on a uniform variable.
  39241. * @param uniformName Name of the variable.
  39242. * @param matrix matrix to be set.
  39243. * @returns this effect.
  39244. */
  39245. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39246. /**
  39247. * 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)
  39248. * @param uniformName Name of the variable.
  39249. * @param matrix matrix to be set.
  39250. * @returns this effect.
  39251. */
  39252. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39253. /**
  39254. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39255. * @param uniformName Name of the variable.
  39256. * @param matrix matrix to be set.
  39257. * @returns this effect.
  39258. */
  39259. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39260. /**
  39261. * Sets a float on a uniform variable.
  39262. * @param uniformName Name of the variable.
  39263. * @param value value to be set.
  39264. * @returns this effect.
  39265. */
  39266. setFloat(uniformName: string, value: number): Effect;
  39267. /**
  39268. * Sets a boolean on a uniform variable.
  39269. * @param uniformName Name of the variable.
  39270. * @param bool value to be set.
  39271. * @returns this effect.
  39272. */
  39273. setBool(uniformName: string, bool: boolean): Effect;
  39274. /**
  39275. * Sets a Vector2 on a uniform variable.
  39276. * @param uniformName Name of the variable.
  39277. * @param vector2 vector2 to be set.
  39278. * @returns this effect.
  39279. */
  39280. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39281. /**
  39282. * Sets a float2 on a uniform variable.
  39283. * @param uniformName Name of the variable.
  39284. * @param x First float in float2.
  39285. * @param y Second float in float2.
  39286. * @returns this effect.
  39287. */
  39288. setFloat2(uniformName: string, x: number, y: number): Effect;
  39289. /**
  39290. * Sets a Vector3 on a uniform variable.
  39291. * @param uniformName Name of the variable.
  39292. * @param vector3 Value to be set.
  39293. * @returns this effect.
  39294. */
  39295. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39296. /**
  39297. * Sets a float3 on a uniform variable.
  39298. * @param uniformName Name of the variable.
  39299. * @param x First float in float3.
  39300. * @param y Second float in float3.
  39301. * @param z Third float in float3.
  39302. * @returns this effect.
  39303. */
  39304. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39305. /**
  39306. * Sets a Vector4 on a uniform variable.
  39307. * @param uniformName Name of the variable.
  39308. * @param vector4 Value to be set.
  39309. * @returns this effect.
  39310. */
  39311. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39312. /**
  39313. * Sets a float4 on a uniform variable.
  39314. * @param uniformName Name of the variable.
  39315. * @param x First float in float4.
  39316. * @param y Second float in float4.
  39317. * @param z Third float in float4.
  39318. * @param w Fourth float in float4.
  39319. * @returns this effect.
  39320. */
  39321. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39322. /**
  39323. * Sets a Color3 on a uniform variable.
  39324. * @param uniformName Name of the variable.
  39325. * @param color3 Value to be set.
  39326. * @returns this effect.
  39327. */
  39328. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39329. /**
  39330. * Sets a Color4 on a uniform variable.
  39331. * @param uniformName Name of the variable.
  39332. * @param color3 Value to be set.
  39333. * @param alpha Alpha value to be set.
  39334. * @returns this effect.
  39335. */
  39336. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39337. /**
  39338. * Sets a Color4 on a uniform variable
  39339. * @param uniformName defines the name of the variable
  39340. * @param color4 defines the value to be set
  39341. * @returns this effect.
  39342. */
  39343. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39344. /**
  39345. * Release all associated resources.
  39346. **/
  39347. dispose(): void;
  39348. /**
  39349. * This function will add a new shader to the shader store
  39350. * @param name the name of the shader
  39351. * @param pixelShader optional pixel shader content
  39352. * @param vertexShader optional vertex shader content
  39353. */
  39354. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39355. /**
  39356. * Store of each shader (The can be looked up using effect.key)
  39357. */
  39358. static ShadersStore: {
  39359. [key: string]: string;
  39360. };
  39361. /**
  39362. * Store of each included file for a shader (The can be looked up using effect.key)
  39363. */
  39364. static IncludesShadersStore: {
  39365. [key: string]: string;
  39366. };
  39367. /**
  39368. * Resets the cache of effects.
  39369. */
  39370. static ResetCache(): void;
  39371. }
  39372. }
  39373. declare module BABYLON {
  39374. /**
  39375. * Interface used to describe the capabilities of the engine relatively to the current browser
  39376. */
  39377. export interface EngineCapabilities {
  39378. /** Maximum textures units per fragment shader */
  39379. maxTexturesImageUnits: number;
  39380. /** Maximum texture units per vertex shader */
  39381. maxVertexTextureImageUnits: number;
  39382. /** Maximum textures units in the entire pipeline */
  39383. maxCombinedTexturesImageUnits: number;
  39384. /** Maximum texture size */
  39385. maxTextureSize: number;
  39386. /** Maximum texture samples */
  39387. maxSamples?: number;
  39388. /** Maximum cube texture size */
  39389. maxCubemapTextureSize: number;
  39390. /** Maximum render texture size */
  39391. maxRenderTextureSize: number;
  39392. /** Maximum number of vertex attributes */
  39393. maxVertexAttribs: number;
  39394. /** Maximum number of varyings */
  39395. maxVaryingVectors: number;
  39396. /** Maximum number of uniforms per vertex shader */
  39397. maxVertexUniformVectors: number;
  39398. /** Maximum number of uniforms per fragment shader */
  39399. maxFragmentUniformVectors: number;
  39400. /** Defines if standard derivates (dx/dy) are supported */
  39401. standardDerivatives: boolean;
  39402. /** Defines if s3tc texture compression is supported */
  39403. s3tc?: WEBGL_compressed_texture_s3tc;
  39404. /** Defines if pvrtc texture compression is supported */
  39405. pvrtc: any;
  39406. /** Defines if etc1 texture compression is supported */
  39407. etc1: any;
  39408. /** Defines if etc2 texture compression is supported */
  39409. etc2: any;
  39410. /** Defines if astc texture compression is supported */
  39411. astc: any;
  39412. /** Defines if bptc texture compression is supported */
  39413. bptc: any;
  39414. /** Defines if float textures are supported */
  39415. textureFloat: boolean;
  39416. /** Defines if vertex array objects are supported */
  39417. vertexArrayObject: boolean;
  39418. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39419. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39420. /** Gets the maximum level of anisotropy supported */
  39421. maxAnisotropy: number;
  39422. /** Defines if instancing is supported */
  39423. instancedArrays: boolean;
  39424. /** Defines if 32 bits indices are supported */
  39425. uintIndices: boolean;
  39426. /** Defines if high precision shaders are supported */
  39427. highPrecisionShaderSupported: boolean;
  39428. /** Defines if depth reading in the fragment shader is supported */
  39429. fragmentDepthSupported: boolean;
  39430. /** Defines if float texture linear filtering is supported*/
  39431. textureFloatLinearFiltering: boolean;
  39432. /** Defines if rendering to float textures is supported */
  39433. textureFloatRender: boolean;
  39434. /** Defines if half float textures are supported*/
  39435. textureHalfFloat: boolean;
  39436. /** Defines if half float texture linear filtering is supported*/
  39437. textureHalfFloatLinearFiltering: boolean;
  39438. /** Defines if rendering to half float textures is supported */
  39439. textureHalfFloatRender: boolean;
  39440. /** Defines if textureLOD shader command is supported */
  39441. textureLOD: boolean;
  39442. /** Defines if draw buffers extension is supported */
  39443. drawBuffersExtension: boolean;
  39444. /** Defines if depth textures are supported */
  39445. depthTextureExtension: boolean;
  39446. /** Defines if float color buffer are supported */
  39447. colorBufferFloat: boolean;
  39448. /** Gets disjoint timer query extension (null if not supported) */
  39449. timerQuery?: EXT_disjoint_timer_query;
  39450. /** Defines if timestamp can be used with timer query */
  39451. canUseTimestampForTimerQuery: boolean;
  39452. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39453. multiview?: any;
  39454. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39455. oculusMultiview?: any;
  39456. /** Function used to let the system compiles shaders in background */
  39457. parallelShaderCompile?: {
  39458. COMPLETION_STATUS_KHR: number;
  39459. };
  39460. /** Max number of texture samples for MSAA */
  39461. maxMSAASamples: number;
  39462. /** Defines if the blend min max extension is supported */
  39463. blendMinMax: boolean;
  39464. /** In some iOS + WebGL1, gl_InstanceID (and gl_InstanceIDEXT) is undefined even if instancedArrays is true. So don't use gl_InstanceID in those cases */
  39465. canUseGLInstanceID: boolean;
  39466. }
  39467. }
  39468. declare module BABYLON {
  39469. /**
  39470. * @hidden
  39471. **/
  39472. export class DepthCullingState {
  39473. private _isDepthTestDirty;
  39474. private _isDepthMaskDirty;
  39475. private _isDepthFuncDirty;
  39476. private _isCullFaceDirty;
  39477. private _isCullDirty;
  39478. private _isZOffsetDirty;
  39479. private _isFrontFaceDirty;
  39480. private _depthTest;
  39481. private _depthMask;
  39482. private _depthFunc;
  39483. private _cull;
  39484. private _cullFace;
  39485. private _zOffset;
  39486. private _frontFace;
  39487. /**
  39488. * Initializes the state.
  39489. */
  39490. constructor();
  39491. get isDirty(): boolean;
  39492. get zOffset(): number;
  39493. set zOffset(value: number);
  39494. get cullFace(): Nullable<number>;
  39495. set cullFace(value: Nullable<number>);
  39496. get cull(): Nullable<boolean>;
  39497. set cull(value: Nullable<boolean>);
  39498. get depthFunc(): Nullable<number>;
  39499. set depthFunc(value: Nullable<number>);
  39500. get depthMask(): boolean;
  39501. set depthMask(value: boolean);
  39502. get depthTest(): boolean;
  39503. set depthTest(value: boolean);
  39504. get frontFace(): Nullable<number>;
  39505. set frontFace(value: Nullable<number>);
  39506. reset(): void;
  39507. apply(gl: WebGLRenderingContext): void;
  39508. }
  39509. }
  39510. declare module BABYLON {
  39511. /**
  39512. * @hidden
  39513. **/
  39514. export class StencilState {
  39515. /** 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 */
  39516. static readonly ALWAYS: number;
  39517. /** Passed to stencilOperation to specify that stencil value must be kept */
  39518. static readonly KEEP: number;
  39519. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39520. static readonly REPLACE: number;
  39521. private _isStencilTestDirty;
  39522. private _isStencilMaskDirty;
  39523. private _isStencilFuncDirty;
  39524. private _isStencilOpDirty;
  39525. private _stencilTest;
  39526. private _stencilMask;
  39527. private _stencilFunc;
  39528. private _stencilFuncRef;
  39529. private _stencilFuncMask;
  39530. private _stencilOpStencilFail;
  39531. private _stencilOpDepthFail;
  39532. private _stencilOpStencilDepthPass;
  39533. get isDirty(): boolean;
  39534. get stencilFunc(): number;
  39535. set stencilFunc(value: number);
  39536. get stencilFuncRef(): number;
  39537. set stencilFuncRef(value: number);
  39538. get stencilFuncMask(): number;
  39539. set stencilFuncMask(value: number);
  39540. get stencilOpStencilFail(): number;
  39541. set stencilOpStencilFail(value: number);
  39542. get stencilOpDepthFail(): number;
  39543. set stencilOpDepthFail(value: number);
  39544. get stencilOpStencilDepthPass(): number;
  39545. set stencilOpStencilDepthPass(value: number);
  39546. get stencilMask(): number;
  39547. set stencilMask(value: number);
  39548. get stencilTest(): boolean;
  39549. set stencilTest(value: boolean);
  39550. constructor();
  39551. reset(): void;
  39552. apply(gl: WebGLRenderingContext): void;
  39553. }
  39554. }
  39555. declare module BABYLON {
  39556. /**
  39557. * @hidden
  39558. **/
  39559. export class AlphaState {
  39560. _blendFunctionParameters: Nullable<number>[];
  39561. _blendEquationParameters: Nullable<number>[];
  39562. _blendConstants: Nullable<number>[];
  39563. _isBlendConstantsDirty: boolean;
  39564. private _alphaBlend;
  39565. private _isAlphaBlendDirty;
  39566. private _isBlendFunctionParametersDirty;
  39567. private _isBlendEquationParametersDirty;
  39568. /**
  39569. * Initializes the state.
  39570. */
  39571. constructor();
  39572. get isDirty(): boolean;
  39573. get alphaBlend(): boolean;
  39574. set alphaBlend(value: boolean);
  39575. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39576. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39577. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39578. reset(): void;
  39579. apply(gl: WebGLRenderingContext): void;
  39580. }
  39581. }
  39582. declare module BABYLON {
  39583. /** @hidden */
  39584. export class WebGLShaderProcessor implements IShaderProcessor {
  39585. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39586. }
  39587. }
  39588. declare module BABYLON {
  39589. /** @hidden */
  39590. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39591. attributeProcessor(attribute: string): string;
  39592. varyingProcessor(varying: string, isFragment: boolean): string;
  39593. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39594. }
  39595. }
  39596. declare module BABYLON {
  39597. /**
  39598. * Interface for attribute information associated with buffer instanciation
  39599. */
  39600. export interface InstancingAttributeInfo {
  39601. /**
  39602. * Name of the GLSL attribute
  39603. * if attribute index is not specified, this is used to retrieve the index from the effect
  39604. */
  39605. attributeName: string;
  39606. /**
  39607. * Index/offset of the attribute in the vertex shader
  39608. * if not specified, this will be computes from the name.
  39609. */
  39610. index?: number;
  39611. /**
  39612. * size of the attribute, 1, 2, 3 or 4
  39613. */
  39614. attributeSize: number;
  39615. /**
  39616. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39617. */
  39618. offset: number;
  39619. /**
  39620. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39621. * default to 1
  39622. */
  39623. divisor?: number;
  39624. /**
  39625. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39626. * default is FLOAT
  39627. */
  39628. attributeType?: number;
  39629. /**
  39630. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39631. */
  39632. normalized?: boolean;
  39633. }
  39634. }
  39635. declare module BABYLON {
  39636. /** @hidden */
  39637. export interface EngineFeatures {
  39638. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39639. forceBitmapOverHTMLImageElement: boolean;
  39640. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39641. supportRenderAndCopyToLodForFloatTextures: boolean;
  39642. /** Indicates that the engine support handling depth/stencil textures */
  39643. supportDepthStencilTexture: boolean;
  39644. /** Indicates that the engine support shadow samplers */
  39645. supportShadowSamplers: boolean;
  39646. /** Indicates to check the matrix bytes per bytes to know if it has changed or not. If false, only the updateFlag of the matrix is checked */
  39647. uniformBufferHardCheckMatrix: boolean;
  39648. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39649. allowTexturePrefiltering: boolean;
  39650. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39651. trackUbosInFrame: boolean;
  39652. /** Indicates that the Cascaded Shadow Map technic is supported */
  39653. supportCSM: boolean;
  39654. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39655. basisNeedsPOT: boolean;
  39656. /** Indicates that the engine supports 3D textures */
  39657. support3DTextures: boolean;
  39658. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39659. needTypeSuffixInShaderConstants: boolean;
  39660. /** Indicates that MSAA is supported */
  39661. supportMSAA: boolean;
  39662. /** Indicates that SSAO2 is supported */
  39663. supportSSAO2: boolean;
  39664. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39665. supportExtendedTextureFormats: boolean;
  39666. /** Indicates that the switch/case construct is supported in shaders */
  39667. supportSwitchCaseInShader: boolean;
  39668. /** @hidden */
  39669. _collectUbosUpdatedInFrame: boolean;
  39670. }
  39671. }
  39672. declare module BABYLON {
  39673. /** @hidden */
  39674. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39675. private _webGLTexture;
  39676. private _context;
  39677. get underlyingResource(): Nullable<WebGLTexture>;
  39678. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39679. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39680. set(hardwareTexture: WebGLTexture): void;
  39681. reset(): void;
  39682. release(): void;
  39683. }
  39684. }
  39685. declare module BABYLON {
  39686. interface ThinEngine {
  39687. /**
  39688. * Update a video texture
  39689. * @param texture defines the texture to update
  39690. * @param video defines the video element to use
  39691. * @param invertY defines if data must be stored with Y axis inverted
  39692. */
  39693. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39694. }
  39695. }
  39696. declare module BABYLON {
  39697. interface ThinEngine {
  39698. /**
  39699. * Creates a dynamic texture
  39700. * @param width defines the width of the texture
  39701. * @param height defines the height of the texture
  39702. * @param generateMipMaps defines if the engine should generate the mip levels
  39703. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39704. * @returns the dynamic texture inside an InternalTexture
  39705. */
  39706. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39707. /**
  39708. * Update the content of a dynamic texture
  39709. * @param texture defines the texture to update
  39710. * @param source defines the source containing the data
  39711. * @param invertY defines if data must be stored with Y axis inverted
  39712. * @param premulAlpha defines if alpha is stored as premultiplied
  39713. * @param format defines the format of the data
  39714. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39715. */
  39716. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39717. }
  39718. }
  39719. declare module BABYLON {
  39720. /**
  39721. * Settings for finer control over video usage
  39722. */
  39723. export interface VideoTextureSettings {
  39724. /**
  39725. * Applies `autoplay` to video, if specified
  39726. */
  39727. autoPlay?: boolean;
  39728. /**
  39729. * Applies `muted` to video, if specified
  39730. */
  39731. muted?: boolean;
  39732. /**
  39733. * Applies `loop` to video, if specified
  39734. */
  39735. loop?: boolean;
  39736. /**
  39737. * Automatically updates internal texture from video at every frame in the render loop
  39738. */
  39739. autoUpdateTexture: boolean;
  39740. /**
  39741. * Image src displayed during the video loading or until the user interacts with the video.
  39742. */
  39743. poster?: string;
  39744. }
  39745. /**
  39746. * If you want to display a video in your scene, this is the special texture for that.
  39747. * This special texture works similar to other textures, with the exception of a few parameters.
  39748. * @see https://doc.babylonjs.com/how_to/video_texture
  39749. */
  39750. export class VideoTexture extends Texture {
  39751. /**
  39752. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39753. */
  39754. readonly autoUpdateTexture: boolean;
  39755. /**
  39756. * The video instance used by the texture internally
  39757. */
  39758. readonly video: HTMLVideoElement;
  39759. private _onUserActionRequestedObservable;
  39760. /**
  39761. * Event triggerd when a dom action is required by the user to play the video.
  39762. * This happens due to recent changes in browser policies preventing video to auto start.
  39763. */
  39764. get onUserActionRequestedObservable(): Observable<Texture>;
  39765. private _generateMipMaps;
  39766. private _stillImageCaptured;
  39767. private _displayingPosterTexture;
  39768. private _settings;
  39769. private _createInternalTextureOnEvent;
  39770. private _frameId;
  39771. private _currentSrc;
  39772. /**
  39773. * Creates a video texture.
  39774. * If you want to display a video in your scene, this is the special texture for that.
  39775. * This special texture works similar to other textures, with the exception of a few parameters.
  39776. * @see https://doc.babylonjs.com/how_to/video_texture
  39777. * @param name optional name, will detect from video source, if not defined
  39778. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39779. * @param scene is obviously the current scene.
  39780. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39781. * @param invertY is false by default but can be used to invert video on Y axis
  39782. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39783. * @param settings allows finer control over video usage
  39784. */
  39785. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39786. private _getName;
  39787. private _getVideo;
  39788. private _createInternalTexture;
  39789. private reset;
  39790. /**
  39791. * @hidden Internal method to initiate `update`.
  39792. */
  39793. _rebuild(): void;
  39794. /**
  39795. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39796. */
  39797. update(): void;
  39798. /**
  39799. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39800. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39801. */
  39802. updateTexture(isVisible: boolean): void;
  39803. protected _updateInternalTexture: () => void;
  39804. /**
  39805. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39806. * @param url New url.
  39807. */
  39808. updateURL(url: string): void;
  39809. /**
  39810. * Clones the texture.
  39811. * @returns the cloned texture
  39812. */
  39813. clone(): VideoTexture;
  39814. /**
  39815. * Dispose the texture and release its associated resources.
  39816. */
  39817. dispose(): void;
  39818. /**
  39819. * Creates a video texture straight from a stream.
  39820. * @param scene Define the scene the texture should be created in
  39821. * @param stream Define the stream the texture should be created from
  39822. * @returns The created video texture as a promise
  39823. */
  39824. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39825. /**
  39826. * Creates a video texture straight from your WebCam video feed.
  39827. * @param scene Define the scene the texture should be created in
  39828. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39829. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39830. * @returns The created video texture as a promise
  39831. */
  39832. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39833. minWidth: number;
  39834. maxWidth: number;
  39835. minHeight: number;
  39836. maxHeight: number;
  39837. deviceId: string;
  39838. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39839. /**
  39840. * Creates a video texture straight from your WebCam video feed.
  39841. * @param scene Define the scene the texture should be created in
  39842. * @param onReady Define a callback to triggered once the texture will be ready
  39843. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39844. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39845. */
  39846. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39847. minWidth: number;
  39848. maxWidth: number;
  39849. minHeight: number;
  39850. maxHeight: number;
  39851. deviceId: string;
  39852. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39853. }
  39854. }
  39855. declare module BABYLON {
  39856. /**
  39857. * Defines the interface used by objects working like Scene
  39858. * @hidden
  39859. */
  39860. export interface ISceneLike {
  39861. _addPendingData(data: any): void;
  39862. _removePendingData(data: any): void;
  39863. offlineProvider: IOfflineProvider;
  39864. }
  39865. /**
  39866. * Information about the current host
  39867. */
  39868. export interface HostInformation {
  39869. /**
  39870. * Defines if the current host is a mobile
  39871. */
  39872. isMobile: boolean;
  39873. }
  39874. /** Interface defining initialization parameters for Engine class */
  39875. export interface EngineOptions extends WebGLContextAttributes {
  39876. /**
  39877. * Defines if the engine should no exceed a specified device ratio
  39878. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39879. */
  39880. limitDeviceRatio?: number;
  39881. /**
  39882. * Defines if webvr should be enabled automatically
  39883. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39884. */
  39885. autoEnableWebVR?: boolean;
  39886. /**
  39887. * Defines if webgl2 should be turned off even if supported
  39888. * @see https://doc.babylonjs.com/features/webgl2
  39889. */
  39890. disableWebGL2Support?: boolean;
  39891. /**
  39892. * Defines if webaudio should be initialized as well
  39893. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39894. */
  39895. audioEngine?: boolean;
  39896. /**
  39897. * Defines if animations should run using a deterministic lock step
  39898. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39899. */
  39900. deterministicLockstep?: boolean;
  39901. /** Defines the maximum steps to use with deterministic lock step mode */
  39902. lockstepMaxSteps?: number;
  39903. /** Defines the seconds between each deterministic lock step */
  39904. timeStep?: number;
  39905. /**
  39906. * Defines that engine should ignore context lost events
  39907. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39908. */
  39909. doNotHandleContextLost?: boolean;
  39910. /**
  39911. * Defines that engine should ignore modifying touch action attribute and style
  39912. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39913. */
  39914. doNotHandleTouchAction?: boolean;
  39915. /**
  39916. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39917. */
  39918. useHighPrecisionFloats?: boolean;
  39919. /**
  39920. * Make the canvas XR Compatible for XR sessions
  39921. */
  39922. xrCompatible?: boolean;
  39923. /**
  39924. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39925. */
  39926. useHighPrecisionMatrix?: boolean;
  39927. /**
  39928. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39929. */
  39930. failIfMajorPerformanceCaveat?: boolean;
  39931. /**
  39932. * Defines whether to adapt to the device's viewport characteristics (default: false)
  39933. */
  39934. adaptToDeviceRatio?: boolean;
  39935. }
  39936. /**
  39937. * The base engine class (root of all engines)
  39938. */
  39939. export class ThinEngine {
  39940. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39941. static ExceptionList: ({
  39942. key: string;
  39943. capture: string;
  39944. captureConstraint: number;
  39945. targets: string[];
  39946. } | {
  39947. key: string;
  39948. capture: null;
  39949. captureConstraint: null;
  39950. targets: string[];
  39951. })[];
  39952. /** @hidden */
  39953. static _TextureLoaders: IInternalTextureLoader[];
  39954. /**
  39955. * Returns the current npm package of the sdk
  39956. */
  39957. static get NpmPackage(): string;
  39958. /**
  39959. * Returns the current version of the framework
  39960. */
  39961. static get Version(): string;
  39962. /**
  39963. * Returns a string describing the current engine
  39964. */
  39965. get description(): string;
  39966. /**
  39967. * Returns the name of the engine
  39968. */
  39969. get name(): string;
  39970. /**
  39971. * Returns the version of the engine
  39972. */
  39973. get version(): number;
  39974. /**
  39975. * Gets or sets the epsilon value used by collision engine
  39976. */
  39977. static CollisionsEpsilon: number;
  39978. /**
  39979. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39980. */
  39981. static get ShadersRepository(): string;
  39982. static set ShadersRepository(value: string);
  39983. /** @hidden */
  39984. _shaderProcessor: Nullable<IShaderProcessor>;
  39985. /**
  39986. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39987. */
  39988. forcePOTTextures: boolean;
  39989. /**
  39990. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39991. */
  39992. isFullscreen: boolean;
  39993. /**
  39994. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39995. */
  39996. cullBackFaces: boolean;
  39997. /**
  39998. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39999. */
  40000. renderEvenInBackground: boolean;
  40001. /**
  40002. * Gets or sets a boolean indicating that cache can be kept between frames
  40003. */
  40004. preventCacheWipeBetweenFrames: boolean;
  40005. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40006. validateShaderPrograms: boolean;
  40007. /**
  40008. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40009. * This can provide greater z depth for distant objects.
  40010. */
  40011. useReverseDepthBuffer: boolean;
  40012. /**
  40013. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40014. */
  40015. disableUniformBuffers: boolean;
  40016. private _frameId;
  40017. /**
  40018. * Gets the current frame id
  40019. */
  40020. get frameId(): number;
  40021. /** @hidden */
  40022. _uniformBuffers: UniformBuffer[];
  40023. /**
  40024. * Gets a boolean indicating that the engine supports uniform buffers
  40025. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40026. */
  40027. get supportsUniformBuffers(): boolean;
  40028. /** @hidden */
  40029. _gl: WebGLRenderingContext;
  40030. /** @hidden */
  40031. _webGLVersion: number;
  40032. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40033. protected _windowIsBackground: boolean;
  40034. protected _creationOptions: EngineOptions;
  40035. protected _highPrecisionShadersAllowed: boolean;
  40036. /** @hidden */
  40037. get _shouldUseHighPrecisionShader(): boolean;
  40038. /**
  40039. * Gets a boolean indicating that only power of 2 textures are supported
  40040. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40041. */
  40042. get needPOTTextures(): boolean;
  40043. /** @hidden */
  40044. _badOS: boolean;
  40045. /** @hidden */
  40046. _badDesktopOS: boolean;
  40047. protected _hardwareScalingLevel: number;
  40048. /** @hidden */
  40049. _caps: EngineCapabilities;
  40050. /** @hidden */
  40051. _features: EngineFeatures;
  40052. protected _isStencilEnable: boolean;
  40053. private _glVersion;
  40054. private _glRenderer;
  40055. private _glVendor;
  40056. /** @hidden */
  40057. _videoTextureSupported: boolean;
  40058. protected _renderingQueueLaunched: boolean;
  40059. protected _activeRenderLoops: (() => void)[];
  40060. /**
  40061. * Observable signaled when a context lost event is raised
  40062. */
  40063. onContextLostObservable: Observable<ThinEngine>;
  40064. /**
  40065. * Observable signaled when a context restored event is raised
  40066. */
  40067. onContextRestoredObservable: Observable<ThinEngine>;
  40068. private _onContextLost;
  40069. private _onContextRestored;
  40070. protected _contextWasLost: boolean;
  40071. /** @hidden */
  40072. _doNotHandleContextLost: boolean;
  40073. /**
  40074. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40075. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40076. */
  40077. get doNotHandleContextLost(): boolean;
  40078. set doNotHandleContextLost(value: boolean);
  40079. /**
  40080. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40081. */
  40082. disableVertexArrayObjects: boolean;
  40083. /** @hidden */
  40084. protected _colorWrite: boolean;
  40085. /** @hidden */
  40086. protected _colorWriteChanged: boolean;
  40087. /** @hidden */
  40088. protected _depthCullingState: DepthCullingState;
  40089. /** @hidden */
  40090. protected _stencilState: StencilState;
  40091. /** @hidden */
  40092. _alphaState: AlphaState;
  40093. /** @hidden */
  40094. _alphaMode: number;
  40095. /** @hidden */
  40096. _alphaEquation: number;
  40097. /** @hidden */
  40098. _internalTexturesCache: InternalTexture[];
  40099. /** @hidden */
  40100. protected _activeChannel: number;
  40101. private _currentTextureChannel;
  40102. /** @hidden */
  40103. protected _boundTexturesCache: {
  40104. [key: string]: Nullable<InternalTexture>;
  40105. };
  40106. /** @hidden */
  40107. protected _currentEffect: Nullable<Effect>;
  40108. /** @hidden */
  40109. protected _currentProgram: Nullable<WebGLProgram>;
  40110. protected _compiledEffects: {
  40111. [key: string]: Effect;
  40112. };
  40113. private _vertexAttribArraysEnabled;
  40114. /** @hidden */
  40115. protected _cachedViewport: Nullable<IViewportLike>;
  40116. private _cachedVertexArrayObject;
  40117. /** @hidden */
  40118. protected _cachedVertexBuffers: any;
  40119. /** @hidden */
  40120. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40121. /** @hidden */
  40122. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40123. /** @hidden */
  40124. _currentRenderTarget: Nullable<InternalTexture>;
  40125. private _uintIndicesCurrentlySet;
  40126. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40127. /** @hidden */
  40128. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40129. /** @hidden */
  40130. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40131. private _currentBufferPointers;
  40132. private _currentInstanceLocations;
  40133. private _currentInstanceBuffers;
  40134. private _textureUnits;
  40135. /** @hidden */
  40136. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40137. /** @hidden */
  40138. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40139. /** @hidden */
  40140. _boundRenderFunction: any;
  40141. private _vaoRecordInProgress;
  40142. private _mustWipeVertexAttributes;
  40143. private _emptyTexture;
  40144. private _emptyCubeTexture;
  40145. private _emptyTexture3D;
  40146. private _emptyTexture2DArray;
  40147. /** @hidden */
  40148. _frameHandler: number;
  40149. private _nextFreeTextureSlots;
  40150. private _maxSimultaneousTextures;
  40151. private _activeRequests;
  40152. /** @hidden */
  40153. _transformTextureUrl: Nullable<(url: string) => string>;
  40154. /**
  40155. * Gets information about the current host
  40156. */
  40157. hostInformation: HostInformation;
  40158. protected get _supportsHardwareTextureRescaling(): boolean;
  40159. private _framebufferDimensionsObject;
  40160. /**
  40161. * sets the object from which width and height will be taken from when getting render width and height
  40162. * Will fallback to the gl object
  40163. * @param dimensions the framebuffer width and height that will be used.
  40164. */
  40165. set framebufferDimensionsObject(dimensions: Nullable<{
  40166. framebufferWidth: number;
  40167. framebufferHeight: number;
  40168. }>);
  40169. /**
  40170. * Gets the current viewport
  40171. */
  40172. get currentViewport(): Nullable<IViewportLike>;
  40173. /**
  40174. * Gets the default empty texture
  40175. */
  40176. get emptyTexture(): InternalTexture;
  40177. /**
  40178. * Gets the default empty 3D texture
  40179. */
  40180. get emptyTexture3D(): InternalTexture;
  40181. /**
  40182. * Gets the default empty 2D array texture
  40183. */
  40184. get emptyTexture2DArray(): InternalTexture;
  40185. /**
  40186. * Gets the default empty cube texture
  40187. */
  40188. get emptyCubeTexture(): InternalTexture;
  40189. /**
  40190. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40191. */
  40192. premultipliedAlpha: boolean;
  40193. /**
  40194. * Observable event triggered before each texture is initialized
  40195. */
  40196. onBeforeTextureInitObservable: Observable<Texture>;
  40197. /** @hidden */
  40198. protected _isWebGPU: boolean;
  40199. /**
  40200. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40201. */
  40202. get isWebGPU(): boolean;
  40203. /** @hidden */
  40204. protected _shaderPlatformName: string;
  40205. /**
  40206. * Gets the shader platfrom name used by the effects.
  40207. */
  40208. get shaderPlatformName(): string;
  40209. /**
  40210. * Creates a new engine
  40211. * @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
  40212. * @param antialias defines enable antialiasing (default: false)
  40213. * @param options defines further options to be sent to the getContext() function
  40214. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40215. */
  40216. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40217. /**
  40218. * @hidden
  40219. */
  40220. _debugPushGroup(groupName: string, targetObject?: number): void;
  40221. /**
  40222. * @hidden
  40223. */
  40224. _debugPopGroup(targetObject?: number): void;
  40225. /**
  40226. * @hidden
  40227. */
  40228. _debugInsertMarker(text: string, targetObject?: number): void;
  40229. /**
  40230. * Shared initialization across engines types.
  40231. * @param canvas The canvas associated with this instance of the engine.
  40232. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40233. * @param audioEngine Defines if an audio engine should be created by default
  40234. */
  40235. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40236. /**
  40237. * Gets a shader processor implementation fitting with the current engine type.
  40238. * @returns The shader processor implementation.
  40239. */
  40240. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40241. /** @hidden */
  40242. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40243. private _rebuildInternalTextures;
  40244. private _rebuildEffects;
  40245. /**
  40246. * Gets a boolean indicating if all created effects are ready
  40247. * @returns true if all effects are ready
  40248. */
  40249. areAllEffectsReady(): boolean;
  40250. protected _rebuildBuffers(): void;
  40251. protected _initGLContext(): void;
  40252. protected _initFeatures(): void;
  40253. /**
  40254. * Gets version of the current webGL context
  40255. * Keep it for back compat - use version instead
  40256. */
  40257. get webGLVersion(): number;
  40258. /**
  40259. * Gets a string identifying the name of the class
  40260. * @returns "Engine" string
  40261. */
  40262. getClassName(): string;
  40263. /**
  40264. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40265. */
  40266. get isStencilEnable(): boolean;
  40267. /** @hidden */
  40268. _prepareWorkingCanvas(): void;
  40269. /**
  40270. * Reset the texture cache to empty state
  40271. */
  40272. resetTextureCache(): void;
  40273. /**
  40274. * Gets an object containing information about the current webGL context
  40275. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40276. */
  40277. getGlInfo(): {
  40278. vendor: string;
  40279. renderer: string;
  40280. version: string;
  40281. };
  40282. /**
  40283. * Defines the hardware scaling level.
  40284. * By default the hardware scaling level is computed from the window device ratio.
  40285. * 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.
  40286. * @param level defines the level to use
  40287. */
  40288. setHardwareScalingLevel(level: number): void;
  40289. /**
  40290. * Gets the current hardware scaling level.
  40291. * By default the hardware scaling level is computed from the window device ratio.
  40292. * 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.
  40293. * @returns a number indicating the current hardware scaling level
  40294. */
  40295. getHardwareScalingLevel(): number;
  40296. /**
  40297. * Gets the list of loaded textures
  40298. * @returns an array containing all loaded textures
  40299. */
  40300. getLoadedTexturesCache(): InternalTexture[];
  40301. /**
  40302. * Gets the object containing all engine capabilities
  40303. * @returns the EngineCapabilities object
  40304. */
  40305. getCaps(): EngineCapabilities;
  40306. /**
  40307. * stop executing a render loop function and remove it from the execution array
  40308. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40309. */
  40310. stopRenderLoop(renderFunction?: () => void): void;
  40311. /** @hidden */
  40312. _renderLoop(): void;
  40313. /**
  40314. * Gets the HTML canvas attached with the current webGL context
  40315. * @returns a HTML canvas
  40316. */
  40317. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40318. /**
  40319. * Gets host window
  40320. * @returns the host window object
  40321. */
  40322. getHostWindow(): Nullable<Window>;
  40323. /**
  40324. * Gets the current render width
  40325. * @param useScreen defines if screen size must be used (or the current render target if any)
  40326. * @returns a number defining the current render width
  40327. */
  40328. getRenderWidth(useScreen?: boolean): number;
  40329. /**
  40330. * Gets the current render height
  40331. * @param useScreen defines if screen size must be used (or the current render target if any)
  40332. * @returns a number defining the current render height
  40333. */
  40334. getRenderHeight(useScreen?: boolean): number;
  40335. /**
  40336. * Can be used to override the current requestAnimationFrame requester.
  40337. * @hidden
  40338. */
  40339. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40340. /**
  40341. * Register and execute a render loop. The engine can have more than one render function
  40342. * @param renderFunction defines the function to continuously execute
  40343. */
  40344. runRenderLoop(renderFunction: () => void): void;
  40345. /**
  40346. * Clear the current render buffer or the current render target (if any is set up)
  40347. * @param color defines the color to use
  40348. * @param backBuffer defines if the back buffer must be cleared
  40349. * @param depth defines if the depth buffer must be cleared
  40350. * @param stencil defines if the stencil buffer must be cleared
  40351. */
  40352. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40353. protected _viewportCached: {
  40354. x: number;
  40355. y: number;
  40356. z: number;
  40357. w: number;
  40358. };
  40359. /** @hidden */
  40360. _viewport(x: number, y: number, width: number, height: number): void;
  40361. /**
  40362. * Set the WebGL's viewport
  40363. * @param viewport defines the viewport element to be used
  40364. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40365. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40366. */
  40367. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40368. /**
  40369. * Begin a new frame
  40370. */
  40371. beginFrame(): void;
  40372. /**
  40373. * Enf the current frame
  40374. */
  40375. endFrame(): void;
  40376. /**
  40377. * Resize the view according to the canvas' size
  40378. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40379. */
  40380. resize(forceSetSize?: boolean): void;
  40381. /**
  40382. * Force a specific size of the canvas
  40383. * @param width defines the new canvas' width
  40384. * @param height defines the new canvas' height
  40385. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40386. * @returns true if the size was changed
  40387. */
  40388. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40389. /**
  40390. * Binds the frame buffer to the specified texture.
  40391. * @param texture The texture to render to or null for the default canvas
  40392. * @param faceIndex The face of the texture to render to in case of cube texture
  40393. * @param requiredWidth The width of the target to render to
  40394. * @param requiredHeight The height of the target to render to
  40395. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40396. * @param lodLevel defines the lod level to bind to the frame buffer
  40397. * @param layer defines the 2d array index to bind to frame buffer to
  40398. */
  40399. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40400. /** @hidden */
  40401. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40402. /**
  40403. * Unbind the current render target texture from the webGL context
  40404. * @param texture defines the render target texture to unbind
  40405. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40406. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40407. */
  40408. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40409. /**
  40410. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40411. */
  40412. flushFramebuffer(): void;
  40413. /**
  40414. * Unbind the current render target and bind the default framebuffer
  40415. */
  40416. restoreDefaultFramebuffer(): void;
  40417. /** @hidden */
  40418. protected _resetVertexBufferBinding(): void;
  40419. /**
  40420. * Creates a vertex buffer
  40421. * @param data the data for the vertex buffer
  40422. * @returns the new WebGL static buffer
  40423. */
  40424. createVertexBuffer(data: DataArray): DataBuffer;
  40425. private _createVertexBuffer;
  40426. /**
  40427. * Creates a dynamic vertex buffer
  40428. * @param data the data for the dynamic vertex buffer
  40429. * @returns the new WebGL dynamic buffer
  40430. */
  40431. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40432. protected _resetIndexBufferBinding(): void;
  40433. /**
  40434. * Creates a new index buffer
  40435. * @param indices defines the content of the index buffer
  40436. * @param updatable defines if the index buffer must be updatable
  40437. * @returns a new webGL buffer
  40438. */
  40439. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40440. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40441. /**
  40442. * Bind a webGL buffer to the webGL context
  40443. * @param buffer defines the buffer to bind
  40444. */
  40445. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40446. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40447. private bindBuffer;
  40448. /**
  40449. * update the bound buffer with the given data
  40450. * @param data defines the data to update
  40451. */
  40452. updateArrayBuffer(data: Float32Array): void;
  40453. private _vertexAttribPointer;
  40454. /** @hidden */
  40455. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40456. private _bindVertexBuffersAttributes;
  40457. /**
  40458. * Records a vertex array object
  40459. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40460. * @param vertexBuffers defines the list of vertex buffers to store
  40461. * @param indexBuffer defines the index buffer to store
  40462. * @param effect defines the effect to store
  40463. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40464. * @returns the new vertex array object
  40465. */
  40466. recordVertexArrayObject(vertexBuffers: {
  40467. [key: string]: VertexBuffer;
  40468. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40469. [kind: string]: Nullable<VertexBuffer>;
  40470. }): WebGLVertexArrayObject;
  40471. /**
  40472. * Bind a specific vertex array object
  40473. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40474. * @param vertexArrayObject defines the vertex array object to bind
  40475. * @param indexBuffer defines the index buffer to bind
  40476. */
  40477. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40478. /**
  40479. * Bind webGl buffers directly to the webGL context
  40480. * @param vertexBuffer defines the vertex buffer to bind
  40481. * @param indexBuffer defines the index buffer to bind
  40482. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40483. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40484. * @param effect defines the effect associated with the vertex buffer
  40485. */
  40486. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40487. private _unbindVertexArrayObject;
  40488. /**
  40489. * Bind a list of vertex buffers to the webGL context
  40490. * @param vertexBuffers defines the list of vertex buffers to bind
  40491. * @param indexBuffer defines the index buffer to bind
  40492. * @param effect defines the effect associated with the vertex buffers
  40493. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40494. */
  40495. bindBuffers(vertexBuffers: {
  40496. [key: string]: Nullable<VertexBuffer>;
  40497. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40498. [kind: string]: Nullable<VertexBuffer>;
  40499. }): void;
  40500. /**
  40501. * Unbind all instance attributes
  40502. */
  40503. unbindInstanceAttributes(): void;
  40504. /**
  40505. * Release and free the memory of a vertex array object
  40506. * @param vao defines the vertex array object to delete
  40507. */
  40508. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40509. /** @hidden */
  40510. _releaseBuffer(buffer: DataBuffer): boolean;
  40511. protected _deleteBuffer(buffer: DataBuffer): void;
  40512. /**
  40513. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40514. * @param instancesBuffer defines the webGL buffer to update and bind
  40515. * @param data defines the data to store in the buffer
  40516. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40517. */
  40518. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40519. /**
  40520. * Bind the content of a webGL buffer used with instantiation
  40521. * @param instancesBuffer defines the webGL buffer to bind
  40522. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40523. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40524. */
  40525. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40526. /**
  40527. * Disable the instance attribute corresponding to the name in parameter
  40528. * @param name defines the name of the attribute to disable
  40529. */
  40530. disableInstanceAttributeByName(name: string): void;
  40531. /**
  40532. * Disable the instance attribute corresponding to the location in parameter
  40533. * @param attributeLocation defines the attribute location of the attribute to disable
  40534. */
  40535. disableInstanceAttribute(attributeLocation: number): void;
  40536. /**
  40537. * Disable the attribute corresponding to the location in parameter
  40538. * @param attributeLocation defines the attribute location of the attribute to disable
  40539. */
  40540. disableAttributeByIndex(attributeLocation: number): void;
  40541. /**
  40542. * Send a draw order
  40543. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40544. * @param indexStart defines the starting index
  40545. * @param indexCount defines the number of index to draw
  40546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40547. */
  40548. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40549. /**
  40550. * Draw a list of points
  40551. * @param verticesStart defines the index of first vertex to draw
  40552. * @param verticesCount defines the count of vertices to draw
  40553. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40554. */
  40555. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40556. /**
  40557. * Draw a list of unindexed primitives
  40558. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40559. * @param verticesStart defines the index of first vertex to draw
  40560. * @param verticesCount defines the count of vertices to draw
  40561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40562. */
  40563. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40564. /**
  40565. * Draw a list of indexed primitives
  40566. * @param fillMode defines the primitive to use
  40567. * @param indexStart defines the starting index
  40568. * @param indexCount defines the number of index to draw
  40569. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40570. */
  40571. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40572. /**
  40573. * Draw a list of unindexed primitives
  40574. * @param fillMode defines the primitive to use
  40575. * @param verticesStart defines the index of first vertex to draw
  40576. * @param verticesCount defines the count of vertices to draw
  40577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40578. */
  40579. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40580. private _drawMode;
  40581. /** @hidden */
  40582. protected _reportDrawCall(): void;
  40583. /** @hidden */
  40584. _releaseEffect(effect: Effect): void;
  40585. /** @hidden */
  40586. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40587. /**
  40588. * Create a new effect (used to store vertex/fragment shaders)
  40589. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40590. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40591. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40592. * @param samplers defines an array of string used to represent textures
  40593. * @param defines defines the string containing the defines to use to compile the shaders
  40594. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40595. * @param onCompiled defines a function to call when the effect creation is successful
  40596. * @param onError defines a function to call when the effect creation has failed
  40597. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40598. * @returns the new Effect
  40599. */
  40600. 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;
  40601. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40602. private _compileShader;
  40603. private _compileRawShader;
  40604. /** @hidden */
  40605. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40606. /**
  40607. * Directly creates a webGL program
  40608. * @param pipelineContext defines the pipeline context to attach to
  40609. * @param vertexCode defines the vertex shader code to use
  40610. * @param fragmentCode defines the fragment shader code to use
  40611. * @param context defines the webGL context to use (if not set, the current one will be used)
  40612. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40613. * @returns the new webGL program
  40614. */
  40615. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40616. /**
  40617. * Creates a webGL program
  40618. * @param pipelineContext defines the pipeline context to attach to
  40619. * @param vertexCode defines the vertex shader code to use
  40620. * @param fragmentCode defines the fragment shader code to use
  40621. * @param defines defines the string containing the defines to use to compile the shaders
  40622. * @param context defines the webGL context to use (if not set, the current one will be used)
  40623. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40624. * @returns the new webGL program
  40625. */
  40626. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40627. /**
  40628. * Creates a new pipeline context
  40629. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40630. * @returns the new pipeline
  40631. */
  40632. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40633. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40634. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40635. /** @hidden */
  40636. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40637. /** @hidden */
  40638. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40639. /** @hidden */
  40640. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40641. /**
  40642. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40643. * @param pipelineContext defines the pipeline context to use
  40644. * @param uniformsNames defines the list of uniform names
  40645. * @returns an array of webGL uniform locations
  40646. */
  40647. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40648. /**
  40649. * Gets the list of active attributes for a given webGL program
  40650. * @param pipelineContext defines the pipeline context to use
  40651. * @param attributesNames defines the list of attribute names to get
  40652. * @returns an array of indices indicating the offset of each attribute
  40653. */
  40654. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40655. /**
  40656. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40657. * @param effect defines the effect to activate
  40658. */
  40659. enableEffect(effect: Nullable<Effect>): void;
  40660. /**
  40661. * Set the value of an uniform to a number (int)
  40662. * @param uniform defines the webGL uniform location where to store the value
  40663. * @param value defines the int number to store
  40664. * @returns true if the value was set
  40665. */
  40666. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40667. /**
  40668. * Set the value of an uniform to a int2
  40669. * @param uniform defines the webGL uniform location where to store the value
  40670. * @param x defines the 1st component of the value
  40671. * @param y defines the 2nd component of the value
  40672. * @returns true if the value was set
  40673. */
  40674. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40675. /**
  40676. * Set the value of an uniform to a int3
  40677. * @param uniform defines the webGL uniform location where to store the value
  40678. * @param x defines the 1st component of the value
  40679. * @param y defines the 2nd component of the value
  40680. * @param z defines the 3rd component of the value
  40681. * @returns true if the value was set
  40682. */
  40683. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40684. /**
  40685. * Set the value of an uniform to a int4
  40686. * @param uniform defines the webGL uniform location where to store the value
  40687. * @param x defines the 1st component of the value
  40688. * @param y defines the 2nd component of the value
  40689. * @param z defines the 3rd component of the value
  40690. * @param w defines the 4th component of the value
  40691. * @returns true if the value was set
  40692. */
  40693. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40694. /**
  40695. * Set the value of an uniform to an array of int32
  40696. * @param uniform defines the webGL uniform location where to store the value
  40697. * @param array defines the array of int32 to store
  40698. * @returns true if the value was set
  40699. */
  40700. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40701. /**
  40702. * Set the value of an uniform to an array of int32 (stored as vec2)
  40703. * @param uniform defines the webGL uniform location where to store the value
  40704. * @param array defines the array of int32 to store
  40705. * @returns true if the value was set
  40706. */
  40707. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40708. /**
  40709. * Set the value of an uniform to an array of int32 (stored as vec3)
  40710. * @param uniform defines the webGL uniform location where to store the value
  40711. * @param array defines the array of int32 to store
  40712. * @returns true if the value was set
  40713. */
  40714. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40715. /**
  40716. * Set the value of an uniform to an array of int32 (stored as vec4)
  40717. * @param uniform defines the webGL uniform location where to store the value
  40718. * @param array defines the array of int32 to store
  40719. * @returns true if the value was set
  40720. */
  40721. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40722. /**
  40723. * Set the value of an uniform to an array of number
  40724. * @param uniform defines the webGL uniform location where to store the value
  40725. * @param array defines the array of number to store
  40726. * @returns true if the value was set
  40727. */
  40728. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40729. /**
  40730. * Set the value of an uniform to an array of number (stored as vec2)
  40731. * @param uniform defines the webGL uniform location where to store the value
  40732. * @param array defines the array of number to store
  40733. * @returns true if the value was set
  40734. */
  40735. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40736. /**
  40737. * Set the value of an uniform to an array of number (stored as vec3)
  40738. * @param uniform defines the webGL uniform location where to store the value
  40739. * @param array defines the array of number to store
  40740. * @returns true if the value was set
  40741. */
  40742. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40743. /**
  40744. * Set the value of an uniform to an array of number (stored as vec4)
  40745. * @param uniform defines the webGL uniform location where to store the value
  40746. * @param array defines the array of number to store
  40747. * @returns true if the value was set
  40748. */
  40749. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40750. /**
  40751. * Set the value of an uniform to an array of float32 (stored as matrices)
  40752. * @param uniform defines the webGL uniform location where to store the value
  40753. * @param matrices defines the array of float32 to store
  40754. * @returns true if the value was set
  40755. */
  40756. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40757. /**
  40758. * Set the value of an uniform to a matrix (3x3)
  40759. * @param uniform defines the webGL uniform location where to store the value
  40760. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40761. * @returns true if the value was set
  40762. */
  40763. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40764. /**
  40765. * Set the value of an uniform to a matrix (2x2)
  40766. * @param uniform defines the webGL uniform location where to store the value
  40767. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40768. * @returns true if the value was set
  40769. */
  40770. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40771. /**
  40772. * Set the value of an uniform to a number (float)
  40773. * @param uniform defines the webGL uniform location where to store the value
  40774. * @param value defines the float number to store
  40775. * @returns true if the value was transfered
  40776. */
  40777. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40778. /**
  40779. * Set the value of an uniform to a vec2
  40780. * @param uniform defines the webGL uniform location where to store the value
  40781. * @param x defines the 1st component of the value
  40782. * @param y defines the 2nd component of the value
  40783. * @returns true if the value was set
  40784. */
  40785. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40786. /**
  40787. * Set the value of an uniform to a vec3
  40788. * @param uniform defines the webGL uniform location where to store the value
  40789. * @param x defines the 1st component of the value
  40790. * @param y defines the 2nd component of the value
  40791. * @param z defines the 3rd component of the value
  40792. * @returns true if the value was set
  40793. */
  40794. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40795. /**
  40796. * Set the value of an uniform to a vec4
  40797. * @param uniform defines the webGL uniform location where to store the value
  40798. * @param x defines the 1st component of the value
  40799. * @param y defines the 2nd component of the value
  40800. * @param z defines the 3rd component of the value
  40801. * @param w defines the 4th component of the value
  40802. * @returns true if the value was set
  40803. */
  40804. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40805. /**
  40806. * Apply all cached states (depth, culling, stencil and alpha)
  40807. */
  40808. applyStates(): void;
  40809. /**
  40810. * Enable or disable color writing
  40811. * @param enable defines the state to set
  40812. */
  40813. setColorWrite(enable: boolean): void;
  40814. /**
  40815. * Gets a boolean indicating if color writing is enabled
  40816. * @returns the current color writing state
  40817. */
  40818. getColorWrite(): boolean;
  40819. /**
  40820. * Gets the depth culling state manager
  40821. */
  40822. get depthCullingState(): DepthCullingState;
  40823. /**
  40824. * Gets the alpha state manager
  40825. */
  40826. get alphaState(): AlphaState;
  40827. /**
  40828. * Gets the stencil state manager
  40829. */
  40830. get stencilState(): StencilState;
  40831. /**
  40832. * Clears the list of texture accessible through engine.
  40833. * This can help preventing texture load conflict due to name collision.
  40834. */
  40835. clearInternalTexturesCache(): void;
  40836. /**
  40837. * Force the entire cache to be cleared
  40838. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40839. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40840. */
  40841. wipeCaches(bruteForce?: boolean): void;
  40842. /** @hidden */
  40843. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40844. min: number;
  40845. mag: number;
  40846. };
  40847. /** @hidden */
  40848. protected _createTexture(): WebGLTexture;
  40849. /** @hidden */
  40850. _createHardwareTexture(): HardwareTextureWrapper;
  40851. protected _createTextureBase(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode: number | undefined, onLoad: (() => void) | null | undefined, onError: ((message: string, exception: any) => void) | null | undefined, prepareTexture: (texture: InternalTexture, extension: string, scene: Nullable<ISceneLike>, img: HTMLImageElement | ImageBitmap | {
  40852. width: number;
  40853. height: number;
  40854. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40855. width: number;
  40856. height: number;
  40857. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40858. width: number;
  40859. height: number;
  40860. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  40861. /**
  40862. * Usually called from Texture.ts.
  40863. * Passed information to create a WebGLTexture
  40864. * @param url defines a value which contains one of the following:
  40865. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40866. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40867. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40868. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40869. * @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)
  40870. * @param scene needed for loading to the correct scene
  40871. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40872. * @param onLoad optional callback to be called upon successful completion
  40873. * @param onError optional callback to be called upon failure
  40874. * @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
  40875. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40876. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40877. * @param forcedExtension defines the extension to use to pick the right loader
  40878. * @param mimeType defines an optional mime type
  40879. * @param loaderOptions options to be passed to the loader
  40880. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40881. */
  40882. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  40883. /**
  40884. * Loads an image as an HTMLImageElement.
  40885. * @param input url string, ArrayBuffer, or Blob to load
  40886. * @param onLoad callback called when the image successfully loads
  40887. * @param onError callback called when the image fails to load
  40888. * @param offlineProvider offline provider for caching
  40889. * @param mimeType optional mime type
  40890. * @returns the HTMLImageElement of the loaded image
  40891. * @hidden
  40892. */
  40893. 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>;
  40894. /**
  40895. * @hidden
  40896. */
  40897. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40898. private _unpackFlipYCached;
  40899. /**
  40900. * In case you are sharing the context with other applications, it might
  40901. * be interested to not cache the unpack flip y state to ensure a consistent
  40902. * value would be set.
  40903. */
  40904. enableUnpackFlipYCached: boolean;
  40905. /** @hidden */
  40906. _unpackFlipY(value: boolean): void;
  40907. /** @hidden */
  40908. _getUnpackAlignement(): number;
  40909. private _getTextureTarget;
  40910. /**
  40911. * Update the sampling mode of a given texture
  40912. * @param samplingMode defines the required sampling mode
  40913. * @param texture defines the texture to update
  40914. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40915. */
  40916. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40917. /**
  40918. * Update the dimensions of a texture
  40919. * @param texture texture to update
  40920. * @param width new width of the texture
  40921. * @param height new height of the texture
  40922. * @param depth new depth of the texture
  40923. */
  40924. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40925. /**
  40926. * Update the sampling mode of a given texture
  40927. * @param texture defines the texture to update
  40928. * @param wrapU defines the texture wrap mode of the u coordinates
  40929. * @param wrapV defines the texture wrap mode of the v coordinates
  40930. * @param wrapR defines the texture wrap mode of the r coordinates
  40931. */
  40932. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40933. /** @hidden */
  40934. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40935. width: number;
  40936. height: number;
  40937. layers?: number;
  40938. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  40939. /** @hidden */
  40940. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40941. /** @hidden */
  40942. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40943. /**
  40944. * Update a portion of an internal texture
  40945. * @param texture defines the texture to update
  40946. * @param imageData defines the data to store into the texture
  40947. * @param xOffset defines the x coordinates of the update rectangle
  40948. * @param yOffset defines the y coordinates of the update rectangle
  40949. * @param width defines the width of the update rectangle
  40950. * @param height defines the height of the update rectangle
  40951. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40952. * @param lod defines the lod level to update (0 by default)
  40953. */
  40954. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40955. /** @hidden */
  40956. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40957. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40958. private _prepareWebGLTexture;
  40959. /** @hidden */
  40960. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40961. private _getDepthStencilBuffer;
  40962. /** @hidden */
  40963. _releaseFramebufferObjects(texture: InternalTexture): void;
  40964. /** @hidden */
  40965. _releaseTexture(texture: InternalTexture): void;
  40966. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40967. protected _setProgram(program: WebGLProgram): void;
  40968. protected _boundUniforms: {
  40969. [key: number]: WebGLUniformLocation;
  40970. };
  40971. /**
  40972. * Binds an effect to the webGL context
  40973. * @param effect defines the effect to bind
  40974. */
  40975. bindSamplers(effect: Effect): void;
  40976. private _activateCurrentTexture;
  40977. /** @hidden */
  40978. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40979. /** @hidden */
  40980. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  40981. /**
  40982. * Unbind all textures from the webGL context
  40983. */
  40984. unbindAllTextures(): void;
  40985. /**
  40986. * Sets a texture to the according uniform.
  40987. * @param channel The texture channel
  40988. * @param uniform The uniform to set
  40989. * @param texture The texture to apply
  40990. * @param name The name of the uniform in the effect
  40991. */
  40992. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  40993. private _bindSamplerUniformToChannel;
  40994. private _getTextureWrapMode;
  40995. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  40996. /**
  40997. * Sets an array of texture to the webGL context
  40998. * @param channel defines the channel where the texture array must be set
  40999. * @param uniform defines the associated uniform location
  41000. * @param textures defines the array of textures to bind
  41001. * @param name name of the channel
  41002. */
  41003. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41004. /** @hidden */
  41005. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41006. private _setTextureParameterFloat;
  41007. private _setTextureParameterInteger;
  41008. /**
  41009. * Unbind all vertex attributes from the webGL context
  41010. */
  41011. unbindAllAttributes(): void;
  41012. /**
  41013. * 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
  41014. */
  41015. releaseEffects(): void;
  41016. /**
  41017. * Dispose and release all associated resources
  41018. */
  41019. dispose(): void;
  41020. /**
  41021. * Attach a new callback raised when context lost event is fired
  41022. * @param callback defines the callback to call
  41023. */
  41024. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41025. /**
  41026. * Attach a new callback raised when context restored event is fired
  41027. * @param callback defines the callback to call
  41028. */
  41029. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41030. /**
  41031. * Get the current error code of the webGL context
  41032. * @returns the error code
  41033. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41034. */
  41035. getError(): number;
  41036. private _canRenderToFloatFramebuffer;
  41037. private _canRenderToHalfFloatFramebuffer;
  41038. private _canRenderToFramebuffer;
  41039. /** @hidden */
  41040. _getWebGLTextureType(type: number): number;
  41041. /** @hidden */
  41042. _getInternalFormat(format: number): number;
  41043. /** @hidden */
  41044. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41045. /** @hidden */
  41046. _getRGBAMultiSampleBufferFormat(type: number): number;
  41047. /** @hidden */
  41048. _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;
  41049. /**
  41050. * Loads a file from a url
  41051. * @param url url to load
  41052. * @param onSuccess callback called when the file successfully loads
  41053. * @param onProgress callback called while file is loading (if the server supports this mode)
  41054. * @param offlineProvider defines the offline provider for caching
  41055. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41056. * @param onError callback called when the file fails to load
  41057. * @returns a file request object
  41058. * @hidden
  41059. */
  41060. 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;
  41061. /**
  41062. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41063. * @param x defines the x coordinate of the rectangle where pixels must be read
  41064. * @param y defines the y coordinate of the rectangle where pixels must be read
  41065. * @param width defines the width of the rectangle where pixels must be read
  41066. * @param height defines the height of the rectangle where pixels must be read
  41067. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41068. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41069. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41070. */
  41071. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41072. private static _IsSupported;
  41073. private static _HasMajorPerformanceCaveat;
  41074. /**
  41075. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41076. */
  41077. static get IsSupported(): boolean;
  41078. /**
  41079. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41080. * @returns true if the engine can be created
  41081. * @ignorenaming
  41082. */
  41083. static isSupported(): boolean;
  41084. /**
  41085. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  41086. */
  41087. static get HasMajorPerformanceCaveat(): boolean;
  41088. /**
  41089. * Find the next highest power of two.
  41090. * @param x Number to start search from.
  41091. * @return Next highest power of two.
  41092. */
  41093. static CeilingPOT(x: number): number;
  41094. /**
  41095. * Find the next lowest power of two.
  41096. * @param x Number to start search from.
  41097. * @return Next lowest power of two.
  41098. */
  41099. static FloorPOT(x: number): number;
  41100. /**
  41101. * Find the nearest power of two.
  41102. * @param x Number to start search from.
  41103. * @return Next nearest power of two.
  41104. */
  41105. static NearestPOT(x: number): number;
  41106. /**
  41107. * Get the closest exponent of two
  41108. * @param value defines the value to approximate
  41109. * @param max defines the maximum value to return
  41110. * @param mode defines how to define the closest value
  41111. * @returns closest exponent of two of the given value
  41112. */
  41113. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41114. /**
  41115. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41116. * @param func - the function to be called
  41117. * @param requester - the object that will request the next frame. Falls back to window.
  41118. * @returns frame number
  41119. */
  41120. static QueueNewFrame(func: () => void, requester?: any): number;
  41121. /**
  41122. * Gets host document
  41123. * @returns the host document object
  41124. */
  41125. getHostDocument(): Nullable<Document>;
  41126. }
  41127. }
  41128. declare module BABYLON {
  41129. /**
  41130. * Defines the source of the internal texture
  41131. */
  41132. export enum InternalTextureSource {
  41133. /**
  41134. * The source of the texture data is unknown
  41135. */
  41136. Unknown = 0,
  41137. /**
  41138. * Texture data comes from an URL
  41139. */
  41140. Url = 1,
  41141. /**
  41142. * Texture data is only used for temporary storage
  41143. */
  41144. Temp = 2,
  41145. /**
  41146. * Texture data comes from raw data (ArrayBuffer)
  41147. */
  41148. Raw = 3,
  41149. /**
  41150. * Texture content is dynamic (video or dynamic texture)
  41151. */
  41152. Dynamic = 4,
  41153. /**
  41154. * Texture content is generated by rendering to it
  41155. */
  41156. RenderTarget = 5,
  41157. /**
  41158. * Texture content is part of a multi render target process
  41159. */
  41160. MultiRenderTarget = 6,
  41161. /**
  41162. * Texture data comes from a cube data file
  41163. */
  41164. Cube = 7,
  41165. /**
  41166. * Texture data comes from a raw cube data
  41167. */
  41168. CubeRaw = 8,
  41169. /**
  41170. * Texture data come from a prefiltered cube data file
  41171. */
  41172. CubePrefiltered = 9,
  41173. /**
  41174. * Texture content is raw 3D data
  41175. */
  41176. Raw3D = 10,
  41177. /**
  41178. * Texture content is raw 2D array data
  41179. */
  41180. Raw2DArray = 11,
  41181. /**
  41182. * Texture content is a depth texture
  41183. */
  41184. Depth = 12,
  41185. /**
  41186. * Texture data comes from a raw cube data encoded with RGBD
  41187. */
  41188. CubeRawRGBD = 13
  41189. }
  41190. /**
  41191. * Class used to store data associated with WebGL texture data for the engine
  41192. * This class should not be used directly
  41193. */
  41194. export class InternalTexture {
  41195. /** @hidden */
  41196. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41197. /**
  41198. * Defines if the texture is ready
  41199. */
  41200. isReady: boolean;
  41201. /**
  41202. * Defines if the texture is a cube texture
  41203. */
  41204. isCube: boolean;
  41205. /**
  41206. * Defines if the texture contains 3D data
  41207. */
  41208. is3D: boolean;
  41209. /**
  41210. * Defines if the texture contains 2D array data
  41211. */
  41212. is2DArray: boolean;
  41213. /**
  41214. * Defines if the texture contains multiview data
  41215. */
  41216. isMultiview: boolean;
  41217. /**
  41218. * Gets the URL used to load this texture
  41219. */
  41220. url: string;
  41221. /** @hidden */
  41222. _originalUrl: string;
  41223. /**
  41224. * Gets the sampling mode of the texture
  41225. */
  41226. samplingMode: number;
  41227. /**
  41228. * Gets a boolean indicating if the texture needs mipmaps generation
  41229. */
  41230. generateMipMaps: boolean;
  41231. /**
  41232. * Gets the number of samples used by the texture (WebGL2+ only)
  41233. */
  41234. samples: number;
  41235. /**
  41236. * Gets the type of the texture (int, float...)
  41237. */
  41238. type: number;
  41239. /**
  41240. * Gets the format of the texture (RGB, RGBA...)
  41241. */
  41242. format: number;
  41243. /**
  41244. * Observable called when the texture is loaded
  41245. */
  41246. onLoadedObservable: Observable<InternalTexture>;
  41247. /**
  41248. * Gets the width of the texture
  41249. */
  41250. width: number;
  41251. /**
  41252. * Gets the height of the texture
  41253. */
  41254. height: number;
  41255. /**
  41256. * Gets the depth of the texture
  41257. */
  41258. depth: number;
  41259. /**
  41260. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41261. */
  41262. baseWidth: number;
  41263. /**
  41264. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41265. */
  41266. baseHeight: number;
  41267. /**
  41268. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41269. */
  41270. baseDepth: number;
  41271. /**
  41272. * Gets a boolean indicating if the texture is inverted on Y axis
  41273. */
  41274. invertY: boolean;
  41275. /** @hidden */
  41276. _invertVScale: boolean;
  41277. /** @hidden */
  41278. _associatedChannel: number;
  41279. /** @hidden */
  41280. _source: InternalTextureSource;
  41281. /** @hidden */
  41282. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41283. /** @hidden */
  41284. _bufferView: Nullable<ArrayBufferView>;
  41285. /** @hidden */
  41286. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41287. /** @hidden */
  41288. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41289. /** @hidden */
  41290. _size: number;
  41291. /** @hidden */
  41292. _extension: string;
  41293. /** @hidden */
  41294. _files: Nullable<string[]>;
  41295. /** @hidden */
  41296. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41297. /** @hidden */
  41298. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41299. /** @hidden */
  41300. _framebuffer: Nullable<WebGLFramebuffer>;
  41301. /** @hidden */
  41302. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41303. /** @hidden */
  41304. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41305. /** @hidden */
  41306. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41307. /** @hidden */
  41308. _attachments: Nullable<number[]>;
  41309. /** @hidden */
  41310. _textureArray: Nullable<InternalTexture[]>;
  41311. /** @hidden */
  41312. _cachedCoordinatesMode: Nullable<number>;
  41313. /** @hidden */
  41314. _cachedWrapU: Nullable<number>;
  41315. /** @hidden */
  41316. _cachedWrapV: Nullable<number>;
  41317. /** @hidden */
  41318. _cachedWrapR: Nullable<number>;
  41319. /** @hidden */
  41320. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41321. /** @hidden */
  41322. _isDisabled: boolean;
  41323. /** @hidden */
  41324. _compression: Nullable<string>;
  41325. /** @hidden */
  41326. _generateStencilBuffer: boolean;
  41327. /** @hidden */
  41328. _generateDepthBuffer: boolean;
  41329. /** @hidden */
  41330. _comparisonFunction: number;
  41331. /** @hidden */
  41332. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41333. /** @hidden */
  41334. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41335. /** @hidden */
  41336. _sphericalPolynomialComputed: boolean;
  41337. /** @hidden */
  41338. _lodGenerationScale: number;
  41339. /** @hidden */
  41340. _lodGenerationOffset: number;
  41341. /** @hidden */
  41342. _depthStencilTexture: Nullable<InternalTexture>;
  41343. /** @hidden */
  41344. _colorTextureArray: Nullable<WebGLTexture>;
  41345. /** @hidden */
  41346. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41347. /** @hidden */
  41348. _lodTextureHigh: Nullable<BaseTexture>;
  41349. /** @hidden */
  41350. _lodTextureMid: Nullable<BaseTexture>;
  41351. /** @hidden */
  41352. _lodTextureLow: Nullable<BaseTexture>;
  41353. /** @hidden */
  41354. _isRGBD: boolean;
  41355. /** @hidden */
  41356. _linearSpecularLOD: boolean;
  41357. /** @hidden */
  41358. _irradianceTexture: Nullable<BaseTexture>;
  41359. /** @hidden */
  41360. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41361. /** @hidden */
  41362. _references: number;
  41363. /** @hidden */
  41364. _gammaSpace: Nullable<boolean>;
  41365. private _engine;
  41366. private _uniqueId;
  41367. private static _Counter;
  41368. /** Gets the unique id of the internal texture */
  41369. get uniqueId(): number;
  41370. /**
  41371. * Gets the Engine the texture belongs to.
  41372. * @returns The babylon engine
  41373. */
  41374. getEngine(): ThinEngine;
  41375. /**
  41376. * Gets the data source type of the texture
  41377. */
  41378. get source(): InternalTextureSource;
  41379. /**
  41380. * Creates a new InternalTexture
  41381. * @param engine defines the engine to use
  41382. * @param source defines the type of data that will be used
  41383. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41384. */
  41385. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41386. /**
  41387. * Increments the number of references (ie. the number of Texture that point to it)
  41388. */
  41389. incrementReferences(): void;
  41390. /**
  41391. * Change the size of the texture (not the size of the content)
  41392. * @param width defines the new width
  41393. * @param height defines the new height
  41394. * @param depth defines the new depth (1 by default)
  41395. */
  41396. updateSize(width: int, height: int, depth?: int): void;
  41397. /** @hidden */
  41398. _rebuild(): void;
  41399. /** @hidden */
  41400. _swapAndDie(target: InternalTexture): void;
  41401. /**
  41402. * Dispose the current allocated resources
  41403. */
  41404. dispose(): void;
  41405. }
  41406. }
  41407. declare module BABYLON {
  41408. /**
  41409. * Interface used to present a loading screen while loading a scene
  41410. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41411. */
  41412. export interface ILoadingScreen {
  41413. /**
  41414. * Function called to display the loading screen
  41415. */
  41416. displayLoadingUI: () => void;
  41417. /**
  41418. * Function called to hide the loading screen
  41419. */
  41420. hideLoadingUI: () => void;
  41421. /**
  41422. * Gets or sets the color to use for the background
  41423. */
  41424. loadingUIBackgroundColor: string;
  41425. /**
  41426. * Gets or sets the text to display while loading
  41427. */
  41428. loadingUIText: string;
  41429. }
  41430. /**
  41431. * Class used for the default loading screen
  41432. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41433. */
  41434. export class DefaultLoadingScreen implements ILoadingScreen {
  41435. private _renderingCanvas;
  41436. private _loadingText;
  41437. private _loadingDivBackgroundColor;
  41438. private _loadingDiv;
  41439. private _loadingTextDiv;
  41440. /** Gets or sets the logo url to use for the default loading screen */
  41441. static DefaultLogoUrl: string;
  41442. /** Gets or sets the spinner url to use for the default loading screen */
  41443. static DefaultSpinnerUrl: string;
  41444. /**
  41445. * Creates a new default loading screen
  41446. * @param _renderingCanvas defines the canvas used to render the scene
  41447. * @param _loadingText defines the default text to display
  41448. * @param _loadingDivBackgroundColor defines the default background color
  41449. */
  41450. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41451. /**
  41452. * Function called to display the loading screen
  41453. */
  41454. displayLoadingUI(): void;
  41455. /**
  41456. * Function called to hide the loading screen
  41457. */
  41458. hideLoadingUI(): void;
  41459. /**
  41460. * Gets or sets the text to display while loading
  41461. */
  41462. set loadingUIText(text: string);
  41463. get loadingUIText(): string;
  41464. /**
  41465. * Gets or sets the color to use for the background
  41466. */
  41467. get loadingUIBackgroundColor(): string;
  41468. set loadingUIBackgroundColor(color: string);
  41469. private _resizeLoadingUI;
  41470. }
  41471. }
  41472. declare module BABYLON {
  41473. /**
  41474. * Interface for any object that can request an animation frame
  41475. */
  41476. export interface ICustomAnimationFrameRequester {
  41477. /**
  41478. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41479. */
  41480. renderFunction?: Function;
  41481. /**
  41482. * Called to request the next frame to render to
  41483. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41484. */
  41485. requestAnimationFrame: Function;
  41486. /**
  41487. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41488. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41489. */
  41490. requestID?: number;
  41491. }
  41492. }
  41493. declare module BABYLON {
  41494. /**
  41495. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41496. */
  41497. export class PerformanceMonitor {
  41498. private _enabled;
  41499. private _rollingFrameTime;
  41500. private _lastFrameTimeMs;
  41501. /**
  41502. * constructor
  41503. * @param frameSampleSize The number of samples required to saturate the sliding window
  41504. */
  41505. constructor(frameSampleSize?: number);
  41506. /**
  41507. * Samples current frame
  41508. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41509. */
  41510. sampleFrame(timeMs?: number): void;
  41511. /**
  41512. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41513. */
  41514. get averageFrameTime(): number;
  41515. /**
  41516. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41517. */
  41518. get averageFrameTimeVariance(): number;
  41519. /**
  41520. * Returns the frame time of the most recent frame
  41521. */
  41522. get instantaneousFrameTime(): number;
  41523. /**
  41524. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41525. */
  41526. get averageFPS(): number;
  41527. /**
  41528. * Returns the average framerate in frames per second using the most recent frame time
  41529. */
  41530. get instantaneousFPS(): number;
  41531. /**
  41532. * Returns true if enough samples have been taken to completely fill the sliding window
  41533. */
  41534. get isSaturated(): boolean;
  41535. /**
  41536. * Enables contributions to the sliding window sample set
  41537. */
  41538. enable(): void;
  41539. /**
  41540. * Disables contributions to the sliding window sample set
  41541. * Samples will not be interpolated over the disabled period
  41542. */
  41543. disable(): void;
  41544. /**
  41545. * Returns true if sampling is enabled
  41546. */
  41547. get isEnabled(): boolean;
  41548. /**
  41549. * Resets performance monitor
  41550. */
  41551. reset(): void;
  41552. }
  41553. /**
  41554. * RollingAverage
  41555. *
  41556. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41557. */
  41558. export class RollingAverage {
  41559. /**
  41560. * Current average
  41561. */
  41562. average: number;
  41563. /**
  41564. * Current variance
  41565. */
  41566. variance: number;
  41567. protected _samples: Array<number>;
  41568. protected _sampleCount: number;
  41569. protected _pos: number;
  41570. protected _m2: number;
  41571. /**
  41572. * constructor
  41573. * @param length The number of samples required to saturate the sliding window
  41574. */
  41575. constructor(length: number);
  41576. /**
  41577. * Adds a sample to the sample set
  41578. * @param v The sample value
  41579. */
  41580. add(v: number): void;
  41581. /**
  41582. * Returns previously added values or null if outside of history or outside the sliding window domain
  41583. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41584. * @return Value previously recorded with add() or null if outside of range
  41585. */
  41586. history(i: number): number;
  41587. /**
  41588. * Returns true if enough samples have been taken to completely fill the sliding window
  41589. * @return true if sample-set saturated
  41590. */
  41591. isSaturated(): boolean;
  41592. /**
  41593. * Resets the rolling average (equivalent to 0 samples taken so far)
  41594. */
  41595. reset(): void;
  41596. /**
  41597. * Wraps a value around the sample range boundaries
  41598. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41599. * @return Wrapped position in sample range
  41600. */
  41601. protected _wrapPosition(i: number): number;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * This class is used to track a performance counter which is number based.
  41607. * The user has access to many properties which give statistics of different nature.
  41608. *
  41609. * The implementer can track two kinds of Performance Counter: time and count.
  41610. * 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.
  41611. * 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.
  41612. */
  41613. export class PerfCounter {
  41614. /**
  41615. * Gets or sets a global boolean to turn on and off all the counters
  41616. */
  41617. static Enabled: boolean;
  41618. /**
  41619. * Returns the smallest value ever
  41620. */
  41621. get min(): number;
  41622. /**
  41623. * Returns the biggest value ever
  41624. */
  41625. get max(): number;
  41626. /**
  41627. * Returns the average value since the performance counter is running
  41628. */
  41629. get average(): number;
  41630. /**
  41631. * Returns the average value of the last second the counter was monitored
  41632. */
  41633. get lastSecAverage(): number;
  41634. /**
  41635. * Returns the current value
  41636. */
  41637. get current(): number;
  41638. /**
  41639. * Gets the accumulated total
  41640. */
  41641. get total(): number;
  41642. /**
  41643. * Gets the total value count
  41644. */
  41645. get count(): number;
  41646. /**
  41647. * Creates a new counter
  41648. */
  41649. constructor();
  41650. /**
  41651. * Call this method to start monitoring a new frame.
  41652. * 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.
  41653. */
  41654. fetchNewFrame(): void;
  41655. /**
  41656. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41657. * @param newCount the count value to add to the monitored count
  41658. * @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.
  41659. */
  41660. addCount(newCount: number, fetchResult: boolean): void;
  41661. /**
  41662. * Start monitoring this performance counter
  41663. */
  41664. beginMonitoring(): void;
  41665. /**
  41666. * Compute the time lapsed since the previous beginMonitoring() call.
  41667. * @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
  41668. */
  41669. endMonitoring(newFrame?: boolean): void;
  41670. private _fetchResult;
  41671. private _startMonitoringTime;
  41672. private _min;
  41673. private _max;
  41674. private _average;
  41675. private _current;
  41676. private _totalValueCount;
  41677. private _totalAccumulated;
  41678. private _lastSecAverage;
  41679. private _lastSecAccumulated;
  41680. private _lastSecTime;
  41681. private _lastSecValueCount;
  41682. }
  41683. }
  41684. declare module BABYLON {
  41685. interface ThinEngine {
  41686. /** @hidden */
  41687. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41688. }
  41689. }
  41690. declare module BABYLON {
  41691. /**
  41692. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41693. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41694. */
  41695. export class Analyser {
  41696. /**
  41697. * Gets or sets the smoothing
  41698. * @ignorenaming
  41699. */
  41700. SMOOTHING: number;
  41701. /**
  41702. * Gets or sets the FFT table size
  41703. * @ignorenaming
  41704. */
  41705. FFT_SIZE: number;
  41706. /**
  41707. * Gets or sets the bar graph amplitude
  41708. * @ignorenaming
  41709. */
  41710. BARGRAPHAMPLITUDE: number;
  41711. /**
  41712. * Gets or sets the position of the debug canvas
  41713. * @ignorenaming
  41714. */
  41715. DEBUGCANVASPOS: {
  41716. x: number;
  41717. y: number;
  41718. };
  41719. /**
  41720. * Gets or sets the debug canvas size
  41721. * @ignorenaming
  41722. */
  41723. DEBUGCANVASSIZE: {
  41724. width: number;
  41725. height: number;
  41726. };
  41727. private _byteFreqs;
  41728. private _byteTime;
  41729. private _floatFreqs;
  41730. private _webAudioAnalyser;
  41731. private _debugCanvas;
  41732. private _debugCanvasContext;
  41733. private _scene;
  41734. private _registerFunc;
  41735. private _audioEngine;
  41736. /**
  41737. * Creates a new analyser
  41738. * @param scene defines hosting scene
  41739. */
  41740. constructor(scene: Scene);
  41741. /**
  41742. * Get the number of data values you will have to play with for the visualization
  41743. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41744. * @returns a number
  41745. */
  41746. getFrequencyBinCount(): number;
  41747. /**
  41748. * Gets the current frequency data as a byte array
  41749. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41750. * @returns a Uint8Array
  41751. */
  41752. getByteFrequencyData(): Uint8Array;
  41753. /**
  41754. * Gets the current waveform as a byte array
  41755. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41756. * @returns a Uint8Array
  41757. */
  41758. getByteTimeDomainData(): Uint8Array;
  41759. /**
  41760. * Gets the current frequency data as a float array
  41761. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41762. * @returns a Float32Array
  41763. */
  41764. getFloatFrequencyData(): Float32Array;
  41765. /**
  41766. * Renders the debug canvas
  41767. */
  41768. drawDebugCanvas(): void;
  41769. /**
  41770. * Stops rendering the debug canvas and removes it
  41771. */
  41772. stopDebugCanvas(): void;
  41773. /**
  41774. * Connects two audio nodes
  41775. * @param inputAudioNode defines first node to connect
  41776. * @param outputAudioNode defines second node to connect
  41777. */
  41778. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41779. /**
  41780. * Releases all associated resources
  41781. */
  41782. dispose(): void;
  41783. }
  41784. }
  41785. declare module BABYLON {
  41786. /**
  41787. * This represents an audio engine and it is responsible
  41788. * to play, synchronize and analyse sounds throughout the application.
  41789. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41790. */
  41791. export interface IAudioEngine extends IDisposable {
  41792. /**
  41793. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41794. */
  41795. readonly canUseWebAudio: boolean;
  41796. /**
  41797. * Gets the current AudioContext if available.
  41798. */
  41799. readonly audioContext: Nullable<AudioContext>;
  41800. /**
  41801. * The master gain node defines the global audio volume of your audio engine.
  41802. */
  41803. readonly masterGain: GainNode;
  41804. /**
  41805. * Gets whether or not mp3 are supported by your browser.
  41806. */
  41807. readonly isMP3supported: boolean;
  41808. /**
  41809. * Gets whether or not ogg are supported by your browser.
  41810. */
  41811. readonly isOGGsupported: boolean;
  41812. /**
  41813. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41814. * @ignoreNaming
  41815. */
  41816. WarnedWebAudioUnsupported: boolean;
  41817. /**
  41818. * Defines if the audio engine relies on a custom unlocked button.
  41819. * In this case, the embedded button will not be displayed.
  41820. */
  41821. useCustomUnlockedButton: boolean;
  41822. /**
  41823. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41824. */
  41825. readonly unlocked: boolean;
  41826. /**
  41827. * Event raised when audio has been unlocked on the browser.
  41828. */
  41829. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41830. /**
  41831. * Event raised when audio has been locked on the browser.
  41832. */
  41833. onAudioLockedObservable: Observable<IAudioEngine>;
  41834. /**
  41835. * Flags the audio engine in Locked state.
  41836. * This happens due to new browser policies preventing audio to autoplay.
  41837. */
  41838. lock(): void;
  41839. /**
  41840. * Unlocks the audio engine once a user action has been done on the dom.
  41841. * This is helpful to resume play once browser policies have been satisfied.
  41842. */
  41843. unlock(): void;
  41844. /**
  41845. * Gets the global volume sets on the master gain.
  41846. * @returns the global volume if set or -1 otherwise
  41847. */
  41848. getGlobalVolume(): number;
  41849. /**
  41850. * Sets the global volume of your experience (sets on the master gain).
  41851. * @param newVolume Defines the new global volume of the application
  41852. */
  41853. setGlobalVolume(newVolume: number): void;
  41854. /**
  41855. * Connect the audio engine to an audio analyser allowing some amazing
  41856. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41857. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41858. * @param analyser The analyser to connect to the engine
  41859. */
  41860. connectToAnalyser(analyser: Analyser): void;
  41861. }
  41862. }
  41863. declare module BABYLON {
  41864. /**
  41865. * Defines the interface used by display changed events
  41866. */
  41867. export interface IDisplayChangedEventArgs {
  41868. /** Gets the vrDisplay object (if any) */
  41869. vrDisplay: Nullable<any>;
  41870. /** Gets a boolean indicating if webVR is supported */
  41871. vrSupported: boolean;
  41872. }
  41873. /**
  41874. * Defines the interface used by objects containing a viewport (like a camera)
  41875. */
  41876. interface IViewportOwnerLike {
  41877. /**
  41878. * Gets or sets the viewport
  41879. */
  41880. viewport: IViewportLike;
  41881. }
  41882. /**
  41883. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41884. */
  41885. export class Engine extends ThinEngine {
  41886. /** Defines that alpha blending is disabled */
  41887. static readonly ALPHA_DISABLE: number;
  41888. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41889. static readonly ALPHA_ADD: number;
  41890. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41891. static readonly ALPHA_COMBINE: number;
  41892. /** Defines that alpha blending to DEST - SRC * DEST */
  41893. static readonly ALPHA_SUBTRACT: number;
  41894. /** Defines that alpha blending to SRC * DEST */
  41895. static readonly ALPHA_MULTIPLY: number;
  41896. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41897. static readonly ALPHA_MAXIMIZED: number;
  41898. /** Defines that alpha blending to SRC + DEST */
  41899. static readonly ALPHA_ONEONE: number;
  41900. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41901. static readonly ALPHA_PREMULTIPLIED: number;
  41902. /**
  41903. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41904. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41905. */
  41906. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41907. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41908. static readonly ALPHA_INTERPOLATE: number;
  41909. /**
  41910. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41911. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41912. */
  41913. static readonly ALPHA_SCREENMODE: number;
  41914. /** Defines that the ressource is not delayed*/
  41915. static readonly DELAYLOADSTATE_NONE: number;
  41916. /** Defines that the ressource was successfully delay loaded */
  41917. static readonly DELAYLOADSTATE_LOADED: number;
  41918. /** Defines that the ressource is currently delay loading */
  41919. static readonly DELAYLOADSTATE_LOADING: number;
  41920. /** Defines that the ressource is delayed and has not started loading */
  41921. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41922. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41923. static readonly NEVER: number;
  41924. /** 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 */
  41925. static readonly ALWAYS: number;
  41926. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41927. static readonly LESS: number;
  41928. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41929. static readonly EQUAL: number;
  41930. /** 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 */
  41931. static readonly LEQUAL: number;
  41932. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41933. static readonly GREATER: number;
  41934. /** 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 */
  41935. static readonly GEQUAL: number;
  41936. /** 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 */
  41937. static readonly NOTEQUAL: number;
  41938. /** Passed to stencilOperation to specify that stencil value must be kept */
  41939. static readonly KEEP: number;
  41940. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41941. static readonly REPLACE: number;
  41942. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41943. static readonly INCR: number;
  41944. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41945. static readonly DECR: number;
  41946. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41947. static readonly INVERT: number;
  41948. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41949. static readonly INCR_WRAP: number;
  41950. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41951. static readonly DECR_WRAP: number;
  41952. /** Texture is not repeating outside of 0..1 UVs */
  41953. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41954. /** Texture is repeating outside of 0..1 UVs */
  41955. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41956. /** Texture is repeating and mirrored */
  41957. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41958. /** ALPHA */
  41959. static readonly TEXTUREFORMAT_ALPHA: number;
  41960. /** LUMINANCE */
  41961. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41962. /** LUMINANCE_ALPHA */
  41963. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41964. /** RGB */
  41965. static readonly TEXTUREFORMAT_RGB: number;
  41966. /** RGBA */
  41967. static readonly TEXTUREFORMAT_RGBA: number;
  41968. /** RED */
  41969. static readonly TEXTUREFORMAT_RED: number;
  41970. /** RED (2nd reference) */
  41971. static readonly TEXTUREFORMAT_R: number;
  41972. /** RG */
  41973. static readonly TEXTUREFORMAT_RG: number;
  41974. /** RED_INTEGER */
  41975. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41976. /** RED_INTEGER (2nd reference) */
  41977. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41978. /** RG_INTEGER */
  41979. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41980. /** RGB_INTEGER */
  41981. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41982. /** RGBA_INTEGER */
  41983. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41984. /** UNSIGNED_BYTE */
  41985. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41986. /** UNSIGNED_BYTE (2nd reference) */
  41987. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41988. /** FLOAT */
  41989. static readonly TEXTURETYPE_FLOAT: number;
  41990. /** HALF_FLOAT */
  41991. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41992. /** BYTE */
  41993. static readonly TEXTURETYPE_BYTE: number;
  41994. /** SHORT */
  41995. static readonly TEXTURETYPE_SHORT: number;
  41996. /** UNSIGNED_SHORT */
  41997. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41998. /** INT */
  41999. static readonly TEXTURETYPE_INT: number;
  42000. /** UNSIGNED_INT */
  42001. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42002. /** UNSIGNED_SHORT_4_4_4_4 */
  42003. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42004. /** UNSIGNED_SHORT_5_5_5_1 */
  42005. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42006. /** UNSIGNED_SHORT_5_6_5 */
  42007. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42008. /** UNSIGNED_INT_2_10_10_10_REV */
  42009. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42010. /** UNSIGNED_INT_24_8 */
  42011. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42012. /** UNSIGNED_INT_10F_11F_11F_REV */
  42013. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42014. /** UNSIGNED_INT_5_9_9_9_REV */
  42015. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42016. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42017. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42018. /** nearest is mag = nearest and min = nearest and mip = none */
  42019. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42020. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42021. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42022. /** Trilinear is mag = linear and min = linear and mip = linear */
  42023. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42024. /** nearest is mag = nearest and min = nearest and mip = linear */
  42025. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42026. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42027. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42028. /** Trilinear is mag = linear and min = linear and mip = linear */
  42029. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42030. /** mag = nearest and min = nearest and mip = nearest */
  42031. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42032. /** mag = nearest and min = linear and mip = nearest */
  42033. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42034. /** mag = nearest and min = linear and mip = linear */
  42035. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42036. /** mag = nearest and min = linear and mip = none */
  42037. static readonly TEXTURE_NEAREST_LINEAR: number;
  42038. /** mag = nearest and min = nearest and mip = none */
  42039. static readonly TEXTURE_NEAREST_NEAREST: number;
  42040. /** mag = linear and min = nearest and mip = nearest */
  42041. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42042. /** mag = linear and min = nearest and mip = linear */
  42043. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42044. /** mag = linear and min = linear and mip = none */
  42045. static readonly TEXTURE_LINEAR_LINEAR: number;
  42046. /** mag = linear and min = nearest and mip = none */
  42047. static readonly TEXTURE_LINEAR_NEAREST: number;
  42048. /** Explicit coordinates mode */
  42049. static readonly TEXTURE_EXPLICIT_MODE: number;
  42050. /** Spherical coordinates mode */
  42051. static readonly TEXTURE_SPHERICAL_MODE: number;
  42052. /** Planar coordinates mode */
  42053. static readonly TEXTURE_PLANAR_MODE: number;
  42054. /** Cubic coordinates mode */
  42055. static readonly TEXTURE_CUBIC_MODE: number;
  42056. /** Projection coordinates mode */
  42057. static readonly TEXTURE_PROJECTION_MODE: number;
  42058. /** Skybox coordinates mode */
  42059. static readonly TEXTURE_SKYBOX_MODE: number;
  42060. /** Inverse Cubic coordinates mode */
  42061. static readonly TEXTURE_INVCUBIC_MODE: number;
  42062. /** Equirectangular coordinates mode */
  42063. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42064. /** Equirectangular Fixed coordinates mode */
  42065. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42066. /** Equirectangular Fixed Mirrored coordinates mode */
  42067. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42068. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42069. static readonly SCALEMODE_FLOOR: number;
  42070. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42071. static readonly SCALEMODE_NEAREST: number;
  42072. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42073. static readonly SCALEMODE_CEILING: number;
  42074. /**
  42075. * Returns the current npm package of the sdk
  42076. */
  42077. static get NpmPackage(): string;
  42078. /**
  42079. * Returns the current version of the framework
  42080. */
  42081. static get Version(): string;
  42082. /** Gets the list of created engines */
  42083. static get Instances(): Engine[];
  42084. /**
  42085. * Gets the latest created engine
  42086. */
  42087. static get LastCreatedEngine(): Nullable<Engine>;
  42088. /**
  42089. * Gets the latest created scene
  42090. */
  42091. static get LastCreatedScene(): Nullable<Scene>;
  42092. /**
  42093. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42094. * @param flag defines which part of the materials must be marked as dirty
  42095. * @param predicate defines a predicate used to filter which materials should be affected
  42096. */
  42097. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42098. /**
  42099. * Method called to create the default loading screen.
  42100. * This can be overriden in your own app.
  42101. * @param canvas The rendering canvas element
  42102. * @returns The loading screen
  42103. */
  42104. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42105. /**
  42106. * Method called to create the default rescale post process on each engine.
  42107. */
  42108. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42109. /**
  42110. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42111. **/
  42112. enableOfflineSupport: boolean;
  42113. /**
  42114. * 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)
  42115. **/
  42116. disableManifestCheck: boolean;
  42117. /**
  42118. * Gets the list of created scenes
  42119. */
  42120. scenes: Scene[];
  42121. /**
  42122. * Event raised when a new scene is created
  42123. */
  42124. onNewSceneAddedObservable: Observable<Scene>;
  42125. /**
  42126. * Gets the list of created postprocesses
  42127. */
  42128. postProcesses: PostProcess[];
  42129. /**
  42130. * Gets a boolean indicating if the pointer is currently locked
  42131. */
  42132. isPointerLock: boolean;
  42133. /**
  42134. * Observable event triggered each time the rendering canvas is resized
  42135. */
  42136. onResizeObservable: Observable<Engine>;
  42137. /**
  42138. * Observable event triggered each time the canvas loses focus
  42139. */
  42140. onCanvasBlurObservable: Observable<Engine>;
  42141. /**
  42142. * Observable event triggered each time the canvas gains focus
  42143. */
  42144. onCanvasFocusObservable: Observable<Engine>;
  42145. /**
  42146. * Observable event triggered each time the canvas receives pointerout event
  42147. */
  42148. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42149. /**
  42150. * Observable raised when the engine begins a new frame
  42151. */
  42152. onBeginFrameObservable: Observable<Engine>;
  42153. /**
  42154. * If set, will be used to request the next animation frame for the render loop
  42155. */
  42156. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42157. /**
  42158. * Observable raised when the engine ends the current frame
  42159. */
  42160. onEndFrameObservable: Observable<Engine>;
  42161. /**
  42162. * Observable raised when the engine is about to compile a shader
  42163. */
  42164. onBeforeShaderCompilationObservable: Observable<Engine>;
  42165. /**
  42166. * Observable raised when the engine has jsut compiled a shader
  42167. */
  42168. onAfterShaderCompilationObservable: Observable<Engine>;
  42169. /**
  42170. * Gets the audio engine
  42171. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42172. * @ignorenaming
  42173. */
  42174. static audioEngine: IAudioEngine;
  42175. /**
  42176. * Default AudioEngine factory responsible of creating the Audio Engine.
  42177. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42178. */
  42179. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42180. /**
  42181. * Default offline support factory responsible of creating a tool used to store data locally.
  42182. * By default, this will create a Database object if the workload has been embedded.
  42183. */
  42184. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42185. private _loadingScreen;
  42186. private _pointerLockRequested;
  42187. private _rescalePostProcess;
  42188. protected _deterministicLockstep: boolean;
  42189. protected _lockstepMaxSteps: number;
  42190. protected _timeStep: number;
  42191. protected get _supportsHardwareTextureRescaling(): boolean;
  42192. private _fps;
  42193. private _deltaTime;
  42194. /** @hidden */
  42195. _drawCalls: PerfCounter;
  42196. /** 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 */
  42197. canvasTabIndex: number;
  42198. /**
  42199. * Turn this value on if you want to pause FPS computation when in background
  42200. */
  42201. disablePerformanceMonitorInBackground: boolean;
  42202. private _performanceMonitor;
  42203. /**
  42204. * Gets the performance monitor attached to this engine
  42205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42206. */
  42207. get performanceMonitor(): PerformanceMonitor;
  42208. private _onFocus;
  42209. private _onBlur;
  42210. private _onCanvasPointerOut;
  42211. private _onCanvasBlur;
  42212. private _onCanvasFocus;
  42213. private _onFullscreenChange;
  42214. private _onPointerLockChange;
  42215. /**
  42216. * Gets the HTML element used to attach event listeners
  42217. * @returns a HTML element
  42218. */
  42219. getInputElement(): Nullable<HTMLElement>;
  42220. /**
  42221. * Creates a new engine
  42222. * @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
  42223. * @param antialias defines enable antialiasing (default: false)
  42224. * @param options defines further options to be sent to the getContext() function
  42225. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42226. */
  42227. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42228. /**
  42229. * Shared initialization across engines types.
  42230. * @param canvas The canvas associated with this instance of the engine.
  42231. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42232. * @param audioEngine Defines if an audio engine should be created by default
  42233. */
  42234. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42235. /**
  42236. * Gets current aspect ratio
  42237. * @param viewportOwner defines the camera to use to get the aspect ratio
  42238. * @param useScreen defines if screen size must be used (or the current render target if any)
  42239. * @returns a number defining the aspect ratio
  42240. */
  42241. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42242. /**
  42243. * Gets current screen aspect ratio
  42244. * @returns a number defining the aspect ratio
  42245. */
  42246. getScreenAspectRatio(): number;
  42247. /**
  42248. * Gets the client rect of the HTML canvas attached with the current webGL context
  42249. * @returns a client rectanglee
  42250. */
  42251. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42252. /**
  42253. * Gets the client rect of the HTML element used for events
  42254. * @returns a client rectanglee
  42255. */
  42256. getInputElementClientRect(): Nullable<ClientRect>;
  42257. /**
  42258. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42259. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42260. * @returns true if engine is in deterministic lock step mode
  42261. */
  42262. isDeterministicLockStep(): boolean;
  42263. /**
  42264. * Gets the max steps when engine is running in deterministic lock step
  42265. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42266. * @returns the max steps
  42267. */
  42268. getLockstepMaxSteps(): number;
  42269. /**
  42270. * Returns the time in ms between steps when using deterministic lock step.
  42271. * @returns time step in (ms)
  42272. */
  42273. getTimeStep(): number;
  42274. /**
  42275. * Force the mipmap generation for the given render target texture
  42276. * @param texture defines the render target texture to use
  42277. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42278. */
  42279. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42280. /** States */
  42281. /**
  42282. * Set various states to the webGL context
  42283. * @param culling defines backface culling state
  42284. * @param zOffset defines the value to apply to zOffset (0 by default)
  42285. * @param force defines if states must be applied even if cache is up to date
  42286. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42287. */
  42288. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42289. /**
  42290. * Set the z offset to apply to current rendering
  42291. * @param value defines the offset to apply
  42292. */
  42293. setZOffset(value: number): void;
  42294. /**
  42295. * Gets the current value of the zOffset
  42296. * @returns the current zOffset state
  42297. */
  42298. getZOffset(): number;
  42299. /**
  42300. * Gets a boolean indicating if depth testing is enabled
  42301. * @returns the current state
  42302. */
  42303. getDepthBuffer(): boolean;
  42304. /**
  42305. * Enable or disable depth buffering
  42306. * @param enable defines the state to set
  42307. */
  42308. setDepthBuffer(enable: boolean): void;
  42309. /**
  42310. * Gets a boolean indicating if depth writing is enabled
  42311. * @returns the current depth writing state
  42312. */
  42313. getDepthWrite(): boolean;
  42314. /**
  42315. * Enable or disable depth writing
  42316. * @param enable defines the state to set
  42317. */
  42318. setDepthWrite(enable: boolean): void;
  42319. /**
  42320. * Gets a boolean indicating if stencil buffer is enabled
  42321. * @returns the current stencil buffer state
  42322. */
  42323. getStencilBuffer(): boolean;
  42324. /**
  42325. * Enable or disable the stencil buffer
  42326. * @param enable defines if the stencil buffer must be enabled or disabled
  42327. */
  42328. setStencilBuffer(enable: boolean): void;
  42329. /**
  42330. * Gets the current stencil mask
  42331. * @returns a number defining the new stencil mask to use
  42332. */
  42333. getStencilMask(): number;
  42334. /**
  42335. * Sets the current stencil mask
  42336. * @param mask defines the new stencil mask to use
  42337. */
  42338. setStencilMask(mask: number): void;
  42339. /**
  42340. * Gets the current stencil function
  42341. * @returns a number defining the stencil function to use
  42342. */
  42343. getStencilFunction(): number;
  42344. /**
  42345. * Gets the current stencil reference value
  42346. * @returns a number defining the stencil reference value to use
  42347. */
  42348. getStencilFunctionReference(): number;
  42349. /**
  42350. * Gets the current stencil mask
  42351. * @returns a number defining the stencil mask to use
  42352. */
  42353. getStencilFunctionMask(): number;
  42354. /**
  42355. * Sets the current stencil function
  42356. * @param stencilFunc defines the new stencil function to use
  42357. */
  42358. setStencilFunction(stencilFunc: number): void;
  42359. /**
  42360. * Sets the current stencil reference
  42361. * @param reference defines the new stencil reference to use
  42362. */
  42363. setStencilFunctionReference(reference: number): void;
  42364. /**
  42365. * Sets the current stencil mask
  42366. * @param mask defines the new stencil mask to use
  42367. */
  42368. setStencilFunctionMask(mask: number): void;
  42369. /**
  42370. * Gets the current stencil operation when stencil fails
  42371. * @returns a number defining stencil operation to use when stencil fails
  42372. */
  42373. getStencilOperationFail(): number;
  42374. /**
  42375. * Gets the current stencil operation when depth fails
  42376. * @returns a number defining stencil operation to use when depth fails
  42377. */
  42378. getStencilOperationDepthFail(): number;
  42379. /**
  42380. * Gets the current stencil operation when stencil passes
  42381. * @returns a number defining stencil operation to use when stencil passes
  42382. */
  42383. getStencilOperationPass(): number;
  42384. /**
  42385. * Sets the stencil operation to use when stencil fails
  42386. * @param operation defines the stencil operation to use when stencil fails
  42387. */
  42388. setStencilOperationFail(operation: number): void;
  42389. /**
  42390. * Sets the stencil operation to use when depth fails
  42391. * @param operation defines the stencil operation to use when depth fails
  42392. */
  42393. setStencilOperationDepthFail(operation: number): void;
  42394. /**
  42395. * Sets the stencil operation to use when stencil passes
  42396. * @param operation defines the stencil operation to use when stencil passes
  42397. */
  42398. setStencilOperationPass(operation: number): void;
  42399. /**
  42400. * Sets a boolean indicating if the dithering state is enabled or disabled
  42401. * @param value defines the dithering state
  42402. */
  42403. setDitheringState(value: boolean): void;
  42404. /**
  42405. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42406. * @param value defines the rasterizer state
  42407. */
  42408. setRasterizerState(value: boolean): void;
  42409. /**
  42410. * Gets the current depth function
  42411. * @returns a number defining the depth function
  42412. */
  42413. getDepthFunction(): Nullable<number>;
  42414. /**
  42415. * Sets the current depth function
  42416. * @param depthFunc defines the function to use
  42417. */
  42418. setDepthFunction(depthFunc: number): void;
  42419. /**
  42420. * Sets the current depth function to GREATER
  42421. */
  42422. setDepthFunctionToGreater(): void;
  42423. /**
  42424. * Sets the current depth function to GEQUAL
  42425. */
  42426. setDepthFunctionToGreaterOrEqual(): void;
  42427. /**
  42428. * Sets the current depth function to LESS
  42429. */
  42430. setDepthFunctionToLess(): void;
  42431. /**
  42432. * Sets the current depth function to LEQUAL
  42433. */
  42434. setDepthFunctionToLessOrEqual(): void;
  42435. private _cachedStencilBuffer;
  42436. private _cachedStencilFunction;
  42437. private _cachedStencilMask;
  42438. private _cachedStencilOperationPass;
  42439. private _cachedStencilOperationFail;
  42440. private _cachedStencilOperationDepthFail;
  42441. private _cachedStencilReference;
  42442. /**
  42443. * Caches the the state of the stencil buffer
  42444. */
  42445. cacheStencilState(): void;
  42446. /**
  42447. * Restores the state of the stencil buffer
  42448. */
  42449. restoreStencilState(): void;
  42450. /**
  42451. * Directly set the WebGL Viewport
  42452. * @param x defines the x coordinate of the viewport (in screen space)
  42453. * @param y defines the y coordinate of the viewport (in screen space)
  42454. * @param width defines the width of the viewport (in screen space)
  42455. * @param height defines the height of the viewport (in screen space)
  42456. * @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
  42457. */
  42458. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42459. /**
  42460. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42461. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42462. * @param y defines the y-coordinate of the corner of the clear rectangle
  42463. * @param width defines the width of the clear rectangle
  42464. * @param height defines the height of the clear rectangle
  42465. * @param clearColor defines the clear color
  42466. */
  42467. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42468. /**
  42469. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42470. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42471. * @param y defines the y-coordinate of the corner of the clear rectangle
  42472. * @param width defines the width of the clear rectangle
  42473. * @param height defines the height of the clear rectangle
  42474. */
  42475. enableScissor(x: number, y: number, width: number, height: number): void;
  42476. /**
  42477. * Disable previously set scissor test rectangle
  42478. */
  42479. disableScissor(): void;
  42480. protected _reportDrawCall(): void;
  42481. /**
  42482. * Initializes a webVR display and starts listening to display change events
  42483. * The onVRDisplayChangedObservable will be notified upon these changes
  42484. * @returns The onVRDisplayChangedObservable
  42485. */
  42486. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42487. /** @hidden */
  42488. _prepareVRComponent(): void;
  42489. /** @hidden */
  42490. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42491. /** @hidden */
  42492. _submitVRFrame(): void;
  42493. /**
  42494. * Call this function to leave webVR mode
  42495. * Will do nothing if webVR is not supported or if there is no webVR device
  42496. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42497. */
  42498. disableVR(): void;
  42499. /**
  42500. * Gets a boolean indicating that the system is in VR mode and is presenting
  42501. * @returns true if VR mode is engaged
  42502. */
  42503. isVRPresenting(): boolean;
  42504. /** @hidden */
  42505. _requestVRFrame(): void;
  42506. /** @hidden */
  42507. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42508. /**
  42509. * Gets the source code of the vertex shader associated with a specific webGL program
  42510. * @param program defines the program to use
  42511. * @returns a string containing the source code of the vertex shader associated with the program
  42512. */
  42513. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42514. /**
  42515. * Gets the source code of the fragment shader associated with a specific webGL program
  42516. * @param program defines the program to use
  42517. * @returns a string containing the source code of the fragment shader associated with the program
  42518. */
  42519. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42520. /**
  42521. * Sets a depth stencil texture from a render target to the according uniform.
  42522. * @param channel The texture channel
  42523. * @param uniform The uniform to set
  42524. * @param texture The render target texture containing the depth stencil texture to apply
  42525. * @param name The texture name
  42526. */
  42527. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42528. /**
  42529. * Sets a texture to the webGL context from a postprocess
  42530. * @param channel defines the channel to use
  42531. * @param postProcess defines the source postprocess
  42532. * @param name name of the channel
  42533. */
  42534. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42535. /**
  42536. * Binds the output of the passed in post process to the texture channel specified
  42537. * @param channel The channel the texture should be bound to
  42538. * @param postProcess The post process which's output should be bound
  42539. * @param name name of the channel
  42540. */
  42541. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42542. protected _rebuildBuffers(): void;
  42543. /** @hidden */
  42544. _renderFrame(): void;
  42545. _renderLoop(): void;
  42546. /** @hidden */
  42547. _renderViews(): boolean;
  42548. /**
  42549. * Toggle full screen mode
  42550. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42551. */
  42552. switchFullscreen(requestPointerLock: boolean): void;
  42553. /**
  42554. * Enters full screen mode
  42555. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42556. */
  42557. enterFullscreen(requestPointerLock: boolean): void;
  42558. /**
  42559. * Exits full screen mode
  42560. */
  42561. exitFullscreen(): void;
  42562. /**
  42563. * Enters Pointerlock mode
  42564. */
  42565. enterPointerlock(): void;
  42566. /**
  42567. * Exits Pointerlock mode
  42568. */
  42569. exitPointerlock(): void;
  42570. /**
  42571. * Begin a new frame
  42572. */
  42573. beginFrame(): void;
  42574. /**
  42575. * End the current frame
  42576. */
  42577. endFrame(): void;
  42578. /**
  42579. * Resize the view according to the canvas' size
  42580. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42581. */
  42582. resize(forceSetSize?: boolean): void;
  42583. /**
  42584. * Force a specific size of the canvas
  42585. * @param width defines the new canvas' width
  42586. * @param height defines the new canvas' height
  42587. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42588. * @returns true if the size was changed
  42589. */
  42590. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42591. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42592. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42593. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42594. _releaseTexture(texture: InternalTexture): void;
  42595. /**
  42596. * @hidden
  42597. * Rescales a texture
  42598. * @param source input texutre
  42599. * @param destination destination texture
  42600. * @param scene scene to use to render the resize
  42601. * @param internalFormat format to use when resizing
  42602. * @param onComplete callback to be called when resize has completed
  42603. */
  42604. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42605. /**
  42606. * Gets the current framerate
  42607. * @returns a number representing the framerate
  42608. */
  42609. getFps(): number;
  42610. /**
  42611. * Gets the time spent between current and previous frame
  42612. * @returns a number representing the delta time in ms
  42613. */
  42614. getDeltaTime(): number;
  42615. private _measureFps;
  42616. /** @hidden */
  42617. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42618. /**
  42619. * Updates the sample count of a render target texture
  42620. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42621. * @param texture defines the texture to update
  42622. * @param samples defines the sample count to set
  42623. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42624. */
  42625. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42626. /**
  42627. * Updates a depth texture Comparison Mode and Function.
  42628. * If the comparison Function is equal to 0, the mode will be set to none.
  42629. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42630. * @param texture The texture to set the comparison function for
  42631. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42632. */
  42633. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42634. /**
  42635. * Creates a webGL buffer to use with instanciation
  42636. * @param capacity defines the size of the buffer
  42637. * @returns the webGL buffer
  42638. */
  42639. createInstancesBuffer(capacity: number): DataBuffer;
  42640. /**
  42641. * Delete a webGL buffer used with instanciation
  42642. * @param buffer defines the webGL buffer to delete
  42643. */
  42644. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42645. private _clientWaitAsync;
  42646. /** @hidden */
  42647. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42648. dispose(): void;
  42649. private _disableTouchAction;
  42650. /**
  42651. * Display the loading screen
  42652. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42653. */
  42654. displayLoadingUI(): void;
  42655. /**
  42656. * Hide the loading screen
  42657. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42658. */
  42659. hideLoadingUI(): void;
  42660. /**
  42661. * Gets the current loading screen object
  42662. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42663. */
  42664. get loadingScreen(): ILoadingScreen;
  42665. /**
  42666. * Sets the current loading screen object
  42667. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42668. */
  42669. set loadingScreen(loadingScreen: ILoadingScreen);
  42670. /**
  42671. * Sets the current loading screen text
  42672. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42673. */
  42674. set loadingUIText(text: string);
  42675. /**
  42676. * Sets the current loading screen background color
  42677. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42678. */
  42679. set loadingUIBackgroundColor(color: string);
  42680. /** Pointerlock and fullscreen */
  42681. /**
  42682. * Ask the browser to promote the current element to pointerlock mode
  42683. * @param element defines the DOM element to promote
  42684. */
  42685. static _RequestPointerlock(element: HTMLElement): void;
  42686. /**
  42687. * Asks the browser to exit pointerlock mode
  42688. */
  42689. static _ExitPointerlock(): void;
  42690. /**
  42691. * Ask the browser to promote the current element to fullscreen rendering mode
  42692. * @param element defines the DOM element to promote
  42693. */
  42694. static _RequestFullscreen(element: HTMLElement): void;
  42695. /**
  42696. * Asks the browser to exit fullscreen mode
  42697. */
  42698. static _ExitFullscreen(): void;
  42699. }
  42700. }
  42701. declare module BABYLON {
  42702. /**
  42703. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42704. * during the life time of the application.
  42705. */
  42706. export class EngineStore {
  42707. /** Gets the list of created engines */
  42708. static Instances: Engine[];
  42709. /** @hidden */
  42710. static _LastCreatedScene: Nullable<Scene>;
  42711. /**
  42712. * Gets the latest created engine
  42713. */
  42714. static get LastCreatedEngine(): Nullable<Engine>;
  42715. /**
  42716. * Gets the latest created scene
  42717. */
  42718. static get LastCreatedScene(): Nullable<Scene>;
  42719. /**
  42720. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42721. * @ignorenaming
  42722. */
  42723. static UseFallbackTexture: boolean;
  42724. /**
  42725. * Texture content used if a texture cannot loaded
  42726. * @ignorenaming
  42727. */
  42728. static FallbackTexture: string;
  42729. }
  42730. }
  42731. declare module BABYLON {
  42732. /**
  42733. * Helper class that provides a small promise polyfill
  42734. */
  42735. export class PromisePolyfill {
  42736. /**
  42737. * Static function used to check if the polyfill is required
  42738. * If this is the case then the function will inject the polyfill to window.Promise
  42739. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42740. */
  42741. static Apply(force?: boolean): void;
  42742. }
  42743. }
  42744. declare module BABYLON {
  42745. /**
  42746. * Interface for screenshot methods with describe argument called `size` as object with options
  42747. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42748. */
  42749. export interface IScreenshotSize {
  42750. /**
  42751. * number in pixels for canvas height
  42752. */
  42753. height?: number;
  42754. /**
  42755. * multiplier allowing render at a higher or lower resolution
  42756. * If value is defined then height and width will be ignored and taken from camera
  42757. */
  42758. precision?: number;
  42759. /**
  42760. * number in pixels for canvas width
  42761. */
  42762. width?: number;
  42763. }
  42764. }
  42765. declare module BABYLON {
  42766. interface IColor4Like {
  42767. r: float;
  42768. g: float;
  42769. b: float;
  42770. a: float;
  42771. }
  42772. /**
  42773. * Class containing a set of static utilities functions
  42774. */
  42775. export class Tools {
  42776. /**
  42777. * Gets or sets the base URL to use to load assets
  42778. */
  42779. static get BaseUrl(): string;
  42780. static set BaseUrl(value: string);
  42781. /**
  42782. * Enable/Disable Custom HTTP Request Headers globally.
  42783. * default = false
  42784. * @see CustomRequestHeaders
  42785. */
  42786. static UseCustomRequestHeaders: boolean;
  42787. /**
  42788. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42789. * i.e. when loading files, where the server/service expects an Authorization header
  42790. */
  42791. static CustomRequestHeaders: {
  42792. [key: string]: string;
  42793. };
  42794. /**
  42795. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42796. */
  42797. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42798. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42799. /**
  42800. * Default behaviour for cors in the application.
  42801. * It can be a string if the expected behavior is identical in the entire app.
  42802. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42803. */
  42804. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42805. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42806. /**
  42807. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42808. * @ignorenaming
  42809. */
  42810. static get UseFallbackTexture(): boolean;
  42811. static set UseFallbackTexture(value: boolean);
  42812. /**
  42813. * Use this object to register external classes like custom textures or material
  42814. * to allow the laoders to instantiate them
  42815. */
  42816. static get RegisteredExternalClasses(): {
  42817. [key: string]: Object;
  42818. };
  42819. static set RegisteredExternalClasses(classes: {
  42820. [key: string]: Object;
  42821. });
  42822. /**
  42823. * Texture content used if a texture cannot loaded
  42824. * @ignorenaming
  42825. */
  42826. static get fallbackTexture(): string;
  42827. static set fallbackTexture(value: string);
  42828. /**
  42829. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42830. * @param u defines the coordinate on X axis
  42831. * @param v defines the coordinate on Y axis
  42832. * @param width defines the width of the source data
  42833. * @param height defines the height of the source data
  42834. * @param pixels defines the source byte array
  42835. * @param color defines the output color
  42836. */
  42837. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42838. /**
  42839. * Interpolates between a and b via alpha
  42840. * @param a The lower value (returned when alpha = 0)
  42841. * @param b The upper value (returned when alpha = 1)
  42842. * @param alpha The interpolation-factor
  42843. * @return The mixed value
  42844. */
  42845. static Mix(a: number, b: number, alpha: number): number;
  42846. /**
  42847. * Tries to instantiate a new object from a given class name
  42848. * @param className defines the class name to instantiate
  42849. * @returns the new object or null if the system was not able to do the instantiation
  42850. */
  42851. static Instantiate(className: string): any;
  42852. /**
  42853. * Provides a slice function that will work even on IE
  42854. * @param data defines the array to slice
  42855. * @param start defines the start of the data (optional)
  42856. * @param end defines the end of the data (optional)
  42857. * @returns the new sliced array
  42858. */
  42859. static Slice<T>(data: T, start?: number, end?: number): T;
  42860. /**
  42861. * Provides a slice function that will work even on IE
  42862. * The difference between this and Slice is that this will force-convert to array
  42863. * @param data defines the array to slice
  42864. * @param start defines the start of the data (optional)
  42865. * @param end defines the end of the data (optional)
  42866. * @returns the new sliced array
  42867. */
  42868. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42869. /**
  42870. * Polyfill for setImmediate
  42871. * @param action defines the action to execute after the current execution block
  42872. */
  42873. static SetImmediate(action: () => void): void;
  42874. /**
  42875. * Function indicating if a number is an exponent of 2
  42876. * @param value defines the value to test
  42877. * @returns true if the value is an exponent of 2
  42878. */
  42879. static IsExponentOfTwo(value: number): boolean;
  42880. private static _tmpFloatArray;
  42881. /**
  42882. * Returns the nearest 32-bit single precision float representation of a Number
  42883. * @param value A Number. If the parameter is of a different type, it will get converted
  42884. * to a number or to NaN if it cannot be converted
  42885. * @returns number
  42886. */
  42887. static FloatRound(value: number): number;
  42888. /**
  42889. * Extracts the filename from a path
  42890. * @param path defines the path to use
  42891. * @returns the filename
  42892. */
  42893. static GetFilename(path: string): string;
  42894. /**
  42895. * Extracts the "folder" part of a path (everything before the filename).
  42896. * @param uri The URI to extract the info from
  42897. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42898. * @returns The "folder" part of the path
  42899. */
  42900. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42901. /**
  42902. * Extracts text content from a DOM element hierarchy
  42903. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42904. */
  42905. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42906. /**
  42907. * Convert an angle in radians to degrees
  42908. * @param angle defines the angle to convert
  42909. * @returns the angle in degrees
  42910. */
  42911. static ToDegrees(angle: number): number;
  42912. /**
  42913. * Convert an angle in degrees to radians
  42914. * @param angle defines the angle to convert
  42915. * @returns the angle in radians
  42916. */
  42917. static ToRadians(angle: number): number;
  42918. /**
  42919. * Returns an array if obj is not an array
  42920. * @param obj defines the object to evaluate as an array
  42921. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42922. * @returns either obj directly if obj is an array or a new array containing obj
  42923. */
  42924. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42925. /**
  42926. * Gets the pointer prefix to use
  42927. * @param engine defines the engine we are finding the prefix for
  42928. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42929. */
  42930. static GetPointerPrefix(engine: Engine): string;
  42931. /**
  42932. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42933. * @param url define the url we are trying
  42934. * @param element define the dom element where to configure the cors policy
  42935. */
  42936. static SetCorsBehavior(url: string | string[], element: {
  42937. crossOrigin: string | null;
  42938. }): void;
  42939. /**
  42940. * Removes unwanted characters from an url
  42941. * @param url defines the url to clean
  42942. * @returns the cleaned url
  42943. */
  42944. static CleanUrl(url: string): string;
  42945. /**
  42946. * Gets or sets a function used to pre-process url before using them to load assets
  42947. */
  42948. static get PreprocessUrl(): (url: string) => string;
  42949. static set PreprocessUrl(processor: (url: string) => string);
  42950. /**
  42951. * Loads an image as an HTMLImageElement.
  42952. * @param input url string, ArrayBuffer, or Blob to load
  42953. * @param onLoad callback called when the image successfully loads
  42954. * @param onError callback called when the image fails to load
  42955. * @param offlineProvider offline provider for caching
  42956. * @param mimeType optional mime type
  42957. * @returns the HTMLImageElement of the loaded image
  42958. */
  42959. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42960. /**
  42961. * Loads a file from a url
  42962. * @param url url string, ArrayBuffer, or Blob to load
  42963. * @param onSuccess callback called when the file successfully loads
  42964. * @param onProgress callback called while file is loading (if the server supports this mode)
  42965. * @param offlineProvider defines the offline provider for caching
  42966. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42967. * @param onError callback called when the file fails to load
  42968. * @returns a file request object
  42969. */
  42970. 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;
  42971. /**
  42972. * Loads a file from a url
  42973. * @param url the file url to load
  42974. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42975. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42976. */
  42977. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42978. /**
  42979. * Load a script (identified by an url). When the url returns, the
  42980. * content of this file is added into a new script element, attached to the DOM (body element)
  42981. * @param scriptUrl defines the url of the script to laod
  42982. * @param onSuccess defines the callback called when the script is loaded
  42983. * @param onError defines the callback to call if an error occurs
  42984. * @param scriptId defines the id of the script element
  42985. */
  42986. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42987. /**
  42988. * Load an asynchronous script (identified by an url). When the url returns, the
  42989. * content of this file is added into a new script element, attached to the DOM (body element)
  42990. * @param scriptUrl defines the url of the script to laod
  42991. * @param scriptId defines the id of the script element
  42992. * @returns a promise request object
  42993. */
  42994. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42995. /**
  42996. * Loads a file from a blob
  42997. * @param fileToLoad defines the blob to use
  42998. * @param callback defines the callback to call when data is loaded
  42999. * @param progressCallback defines the callback to call during loading process
  43000. * @returns a file request object
  43001. */
  43002. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43003. /**
  43004. * Reads a file from a File object
  43005. * @param file defines the file to load
  43006. * @param onSuccess defines the callback to call when data is loaded
  43007. * @param onProgress defines the callback to call during loading process
  43008. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43009. * @param onError defines the callback to call when an error occurs
  43010. * @returns a file request object
  43011. */
  43012. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43013. /**
  43014. * Creates a data url from a given string content
  43015. * @param content defines the content to convert
  43016. * @returns the new data url link
  43017. */
  43018. static FileAsURL(content: string): string;
  43019. /**
  43020. * Format the given number to a specific decimal format
  43021. * @param value defines the number to format
  43022. * @param decimals defines the number of decimals to use
  43023. * @returns the formatted string
  43024. */
  43025. static Format(value: number, decimals?: number): string;
  43026. /**
  43027. * Tries to copy an object by duplicating every property
  43028. * @param source defines the source object
  43029. * @param destination defines the target object
  43030. * @param doNotCopyList defines a list of properties to avoid
  43031. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43032. */
  43033. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43034. /**
  43035. * Gets a boolean indicating if the given object has no own property
  43036. * @param obj defines the object to test
  43037. * @returns true if object has no own property
  43038. */
  43039. static IsEmpty(obj: any): boolean;
  43040. /**
  43041. * Function used to register events at window level
  43042. * @param windowElement defines the Window object to use
  43043. * @param events defines the events to register
  43044. */
  43045. static RegisterTopRootEvents(windowElement: Window, events: {
  43046. name: string;
  43047. handler: Nullable<(e: FocusEvent) => any>;
  43048. }[]): void;
  43049. /**
  43050. * Function used to unregister events from window level
  43051. * @param windowElement defines the Window object to use
  43052. * @param events defines the events to unregister
  43053. */
  43054. static UnregisterTopRootEvents(windowElement: Window, events: {
  43055. name: string;
  43056. handler: Nullable<(e: FocusEvent) => any>;
  43057. }[]): void;
  43058. /**
  43059. * @ignore
  43060. */
  43061. static _ScreenshotCanvas: HTMLCanvasElement;
  43062. /**
  43063. * Dumps the current bound framebuffer
  43064. * @param width defines the rendering width
  43065. * @param height defines the rendering height
  43066. * @param engine defines the hosting engine
  43067. * @param successCallback defines the callback triggered once the data are available
  43068. * @param mimeType defines the mime type of the result
  43069. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43070. * @return a void promise
  43071. */
  43072. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43073. /**
  43074. * Dumps an array buffer
  43075. * @param width defines the rendering width
  43076. * @param height defines the rendering height
  43077. * @param data the data array
  43078. * @param successCallback defines the callback triggered once the data are available
  43079. * @param mimeType defines the mime type of the result
  43080. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43081. * @param invertY true to invert the picture in the Y dimension
  43082. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43083. */
  43084. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43085. /**
  43086. * Dumps an array buffer
  43087. * @param width defines the rendering width
  43088. * @param height defines the rendering height
  43089. * @param data the data array
  43090. * @param successCallback defines the callback triggered once the data are available
  43091. * @param mimeType defines the mime type of the result
  43092. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43093. * @param invertY true to invert the picture in the Y dimension
  43094. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43095. * @return a promise that resolve to the final data
  43096. */
  43097. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43098. /**
  43099. * Converts the canvas data to blob.
  43100. * This acts as a polyfill for browsers not supporting the to blob function.
  43101. * @param canvas Defines the canvas to extract the data from
  43102. * @param successCallback Defines the callback triggered once the data are available
  43103. * @param mimeType Defines the mime type of the result
  43104. */
  43105. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43106. /**
  43107. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43108. * @param successCallback defines the callback triggered once the data are available
  43109. * @param mimeType defines the mime type of the result
  43110. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43111. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43112. */
  43113. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43114. /**
  43115. * Downloads a blob in the browser
  43116. * @param blob defines the blob to download
  43117. * @param fileName defines the name of the downloaded file
  43118. */
  43119. static Download(blob: Blob, fileName: string): void;
  43120. /**
  43121. * Will return the right value of the noPreventDefault variable
  43122. * Needed to keep backwards compatibility to the old API.
  43123. *
  43124. * @param args arguments passed to the attachControl function
  43125. * @returns the correct value for noPreventDefault
  43126. */
  43127. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43128. /**
  43129. * Captures a screenshot of the current rendering
  43130. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43131. * @param engine defines the rendering engine
  43132. * @param camera defines the source camera
  43133. * @param size This parameter can be set to a single number or to an object with the
  43134. * following (optional) properties: precision, width, height. If a single number is passed,
  43135. * it will be used for both width and height. If an object is passed, the screenshot size
  43136. * will be derived from the parameters. The precision property is a multiplier allowing
  43137. * rendering at a higher or lower resolution
  43138. * @param successCallback defines the callback receives a single parameter which contains the
  43139. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43140. * src parameter of an <img> to display it
  43141. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43142. * Check your browser for supported MIME types
  43143. */
  43144. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43145. /**
  43146. * Captures a screenshot of the current rendering
  43147. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43148. * @param engine defines the rendering engine
  43149. * @param camera defines the source camera
  43150. * @param size This parameter can be set to a single number or to an object with the
  43151. * following (optional) properties: precision, width, height. If a single number is passed,
  43152. * it will be used for both width and height. If an object is passed, the screenshot size
  43153. * will be derived from the parameters. The precision property is a multiplier allowing
  43154. * rendering at a higher or lower resolution
  43155. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43156. * Check your browser for supported MIME types
  43157. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43158. * to the src parameter of an <img> to display it
  43159. */
  43160. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43161. /**
  43162. * Generates an image screenshot from the specified camera.
  43163. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43164. * @param engine The engine to use for rendering
  43165. * @param camera The camera to use for rendering
  43166. * @param size This parameter can be set to a single number or to an object with the
  43167. * following (optional) properties: precision, width, height. If a single number is passed,
  43168. * it will be used for both width and height. If an object is passed, the screenshot size
  43169. * will be derived from the parameters. The precision property is a multiplier allowing
  43170. * rendering at a higher or lower resolution
  43171. * @param successCallback The callback receives a single parameter which contains the
  43172. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43173. * src parameter of an <img> to display it
  43174. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43175. * Check your browser for supported MIME types
  43176. * @param samples Texture samples (default: 1)
  43177. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43178. * @param fileName A name for for the downloaded file.
  43179. */
  43180. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43181. /**
  43182. * Generates an image screenshot from the specified camera.
  43183. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43184. * @param engine The engine to use for rendering
  43185. * @param camera The camera to use for rendering
  43186. * @param size This parameter can be set to a single number or to an object with the
  43187. * following (optional) properties: precision, width, height. If a single number is passed,
  43188. * it will be used for both width and height. If an object is passed, the screenshot size
  43189. * will be derived from the parameters. The precision property is a multiplier allowing
  43190. * rendering at a higher or lower resolution
  43191. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43192. * Check your browser for supported MIME types
  43193. * @param samples Texture samples (default: 1)
  43194. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43195. * @param fileName A name for for the downloaded file.
  43196. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43197. * to the src parameter of an <img> to display it
  43198. */
  43199. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43200. /**
  43201. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43202. * Be aware Math.random() could cause collisions, but:
  43203. * "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"
  43204. * @returns a pseudo random id
  43205. */
  43206. static RandomId(): string;
  43207. /**
  43208. * Test if the given uri is a base64 string
  43209. * @param uri The uri to test
  43210. * @return True if the uri is a base64 string or false otherwise
  43211. */
  43212. static IsBase64(uri: string): boolean;
  43213. /**
  43214. * Decode the given base64 uri.
  43215. * @param uri The uri to decode
  43216. * @return The decoded base64 data.
  43217. */
  43218. static DecodeBase64(uri: string): ArrayBuffer;
  43219. /**
  43220. * Gets the absolute url.
  43221. * @param url the input url
  43222. * @return the absolute url
  43223. */
  43224. static GetAbsoluteUrl(url: string): string;
  43225. /**
  43226. * No log
  43227. */
  43228. static readonly NoneLogLevel: number;
  43229. /**
  43230. * Only message logs
  43231. */
  43232. static readonly MessageLogLevel: number;
  43233. /**
  43234. * Only warning logs
  43235. */
  43236. static readonly WarningLogLevel: number;
  43237. /**
  43238. * Only error logs
  43239. */
  43240. static readonly ErrorLogLevel: number;
  43241. /**
  43242. * All logs
  43243. */
  43244. static readonly AllLogLevel: number;
  43245. /**
  43246. * Gets a value indicating the number of loading errors
  43247. * @ignorenaming
  43248. */
  43249. static get errorsCount(): number;
  43250. /**
  43251. * Callback called when a new log is added
  43252. */
  43253. static OnNewCacheEntry: (entry: string) => void;
  43254. /**
  43255. * Log a message to the console
  43256. * @param message defines the message to log
  43257. */
  43258. static Log(message: string): void;
  43259. /**
  43260. * Write a warning message to the console
  43261. * @param message defines the message to log
  43262. */
  43263. static Warn(message: string): void;
  43264. /**
  43265. * Write an error message to the console
  43266. * @param message defines the message to log
  43267. */
  43268. static Error(message: string): void;
  43269. /**
  43270. * Gets current log cache (list of logs)
  43271. */
  43272. static get LogCache(): string;
  43273. /**
  43274. * Clears the log cache
  43275. */
  43276. static ClearLogCache(): void;
  43277. /**
  43278. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43279. */
  43280. static set LogLevels(level: number);
  43281. /**
  43282. * Checks if the window object exists
  43283. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43284. */
  43285. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43286. /**
  43287. * No performance log
  43288. */
  43289. static readonly PerformanceNoneLogLevel: number;
  43290. /**
  43291. * Use user marks to log performance
  43292. */
  43293. static readonly PerformanceUserMarkLogLevel: number;
  43294. /**
  43295. * Log performance to the console
  43296. */
  43297. static readonly PerformanceConsoleLogLevel: number;
  43298. private static _performance;
  43299. /**
  43300. * Sets the current performance log level
  43301. */
  43302. static set PerformanceLogLevel(level: number);
  43303. private static _StartPerformanceCounterDisabled;
  43304. private static _EndPerformanceCounterDisabled;
  43305. private static _StartUserMark;
  43306. private static _EndUserMark;
  43307. private static _StartPerformanceConsole;
  43308. private static _EndPerformanceConsole;
  43309. /**
  43310. * Starts a performance counter
  43311. */
  43312. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43313. /**
  43314. * Ends a specific performance coutner
  43315. */
  43316. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43317. /**
  43318. * Gets either window.performance.now() if supported or Date.now() else
  43319. */
  43320. static get Now(): number;
  43321. /**
  43322. * This method will return the name of the class used to create the instance of the given object.
  43323. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43324. * @param object the object to get the class name from
  43325. * @param isType defines if the object is actually a type
  43326. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43327. */
  43328. static GetClassName(object: any, isType?: boolean): string;
  43329. /**
  43330. * Gets the first element of an array satisfying a given predicate
  43331. * @param array defines the array to browse
  43332. * @param predicate defines the predicate to use
  43333. * @returns null if not found or the element
  43334. */
  43335. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43336. /**
  43337. * This method will return the name of the full name of the class, including its owning module (if any).
  43338. * 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).
  43339. * @param object the object to get the class name from
  43340. * @param isType defines if the object is actually a type
  43341. * @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.
  43342. * @ignorenaming
  43343. */
  43344. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43345. /**
  43346. * Returns a promise that resolves after the given amount of time.
  43347. * @param delay Number of milliseconds to delay
  43348. * @returns Promise that resolves after the given amount of time
  43349. */
  43350. static DelayAsync(delay: number): Promise<void>;
  43351. /**
  43352. * Utility function to detect if the current user agent is Safari
  43353. * @returns whether or not the current user agent is safari
  43354. */
  43355. static IsSafari(): boolean;
  43356. }
  43357. /**
  43358. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43359. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43360. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43361. * @param name The name of the class, case should be preserved
  43362. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43363. */
  43364. export function className(name: string, module?: string): (target: Object) => void;
  43365. /**
  43366. * An implementation of a loop for asynchronous functions.
  43367. */
  43368. export class AsyncLoop {
  43369. /**
  43370. * Defines the number of iterations for the loop
  43371. */
  43372. iterations: number;
  43373. /**
  43374. * Defines the current index of the loop.
  43375. */
  43376. index: number;
  43377. private _done;
  43378. private _fn;
  43379. private _successCallback;
  43380. /**
  43381. * Constructor.
  43382. * @param iterations the number of iterations.
  43383. * @param func the function to run each iteration
  43384. * @param successCallback the callback that will be called upon succesful execution
  43385. * @param offset starting offset.
  43386. */
  43387. constructor(
  43388. /**
  43389. * Defines the number of iterations for the loop
  43390. */
  43391. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43392. /**
  43393. * Execute the next iteration. Must be called after the last iteration was finished.
  43394. */
  43395. executeNext(): void;
  43396. /**
  43397. * Break the loop and run the success callback.
  43398. */
  43399. breakLoop(): void;
  43400. /**
  43401. * Create and run an async loop.
  43402. * @param iterations the number of iterations.
  43403. * @param fn the function to run each iteration
  43404. * @param successCallback the callback that will be called upon succesful execution
  43405. * @param offset starting offset.
  43406. * @returns the created async loop object
  43407. */
  43408. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43409. /**
  43410. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43411. * @param iterations total number of iterations
  43412. * @param syncedIterations number of synchronous iterations in each async iteration.
  43413. * @param fn the function to call each iteration.
  43414. * @param callback a success call back that will be called when iterating stops.
  43415. * @param breakFunction a break condition (optional)
  43416. * @param timeout timeout settings for the setTimeout function. default - 0.
  43417. * @returns the created async loop object
  43418. */
  43419. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43420. }
  43421. }
  43422. declare module BABYLON {
  43423. /**
  43424. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43425. * The underlying implementation relies on an associative array to ensure the best performances.
  43426. * The value can be anything including 'null' but except 'undefined'
  43427. */
  43428. export class StringDictionary<T> {
  43429. /**
  43430. * This will clear this dictionary and copy the content from the 'source' one.
  43431. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43432. * @param source the dictionary to take the content from and copy to this dictionary
  43433. */
  43434. copyFrom(source: StringDictionary<T>): void;
  43435. /**
  43436. * Get a value based from its key
  43437. * @param key the given key to get the matching value from
  43438. * @return the value if found, otherwise undefined is returned
  43439. */
  43440. get(key: string): T | undefined;
  43441. /**
  43442. * Get a value from its key or add it if it doesn't exist.
  43443. * This method will ensure you that a given key/data will be present in the dictionary.
  43444. * @param key the given key to get the matching value from
  43445. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43446. * The factory will only be invoked if there's no data for the given key.
  43447. * @return the value corresponding to the key.
  43448. */
  43449. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43450. /**
  43451. * Get a value from its key if present in the dictionary otherwise add it
  43452. * @param key the key to get the value from
  43453. * @param val if there's no such key/value pair in the dictionary add it with this value
  43454. * @return the value corresponding to the key
  43455. */
  43456. getOrAdd(key: string, val: T): T;
  43457. /**
  43458. * Check if there's a given key in the dictionary
  43459. * @param key the key to check for
  43460. * @return true if the key is present, false otherwise
  43461. */
  43462. contains(key: string): boolean;
  43463. /**
  43464. * Add a new key and its corresponding value
  43465. * @param key the key to add
  43466. * @param value the value corresponding to the key
  43467. * @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
  43468. */
  43469. add(key: string, value: T): boolean;
  43470. /**
  43471. * Update a specific value associated to a key
  43472. * @param key defines the key to use
  43473. * @param value defines the value to store
  43474. * @returns true if the value was updated (or false if the key was not found)
  43475. */
  43476. set(key: string, value: T): boolean;
  43477. /**
  43478. * Get the element of the given key and remove it from the dictionary
  43479. * @param key defines the key to search
  43480. * @returns the value associated with the key or null if not found
  43481. */
  43482. getAndRemove(key: string): Nullable<T>;
  43483. /**
  43484. * Remove a key/value from the dictionary.
  43485. * @param key the key to remove
  43486. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43487. */
  43488. remove(key: string): boolean;
  43489. /**
  43490. * Clear the whole content of the dictionary
  43491. */
  43492. clear(): void;
  43493. /**
  43494. * Gets the current count
  43495. */
  43496. get count(): number;
  43497. /**
  43498. * Execute a callback on each key/val of the dictionary.
  43499. * Note that you can remove any element in this dictionary in the callback implementation
  43500. * @param callback the callback to execute on a given key/value pair
  43501. */
  43502. forEach(callback: (key: string, val: T) => void): void;
  43503. /**
  43504. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43505. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43506. * Note that you can remove any element in this dictionary in the callback implementation
  43507. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43508. * @returns the first item
  43509. */
  43510. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43511. private _count;
  43512. private _data;
  43513. }
  43514. }
  43515. declare module BABYLON {
  43516. /** @hidden */
  43517. export interface ICollisionCoordinator {
  43518. createCollider(): Collider;
  43519. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43520. init(scene: Scene): void;
  43521. }
  43522. /** @hidden */
  43523. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43524. private _scene;
  43525. private _scaledPosition;
  43526. private _scaledVelocity;
  43527. private _finalPosition;
  43528. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43529. createCollider(): Collider;
  43530. init(scene: Scene): void;
  43531. private _collideWithWorld;
  43532. }
  43533. }
  43534. declare module BABYLON {
  43535. /**
  43536. * Class used to manage all inputs for the scene.
  43537. */
  43538. export class InputManager {
  43539. /** The distance in pixel that you have to move to prevent some events */
  43540. static DragMovementThreshold: number;
  43541. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43542. static LongPressDelay: number;
  43543. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43544. static DoubleClickDelay: number;
  43545. /** If you need to check double click without raising a single click at first click, enable this flag */
  43546. static ExclusiveDoubleClickMode: boolean;
  43547. /** 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. */
  43548. private _alreadyAttached;
  43549. private _alreadyAttachedTo;
  43550. private _wheelEventName;
  43551. private _onPointerMove;
  43552. private _onPointerDown;
  43553. private _onPointerUp;
  43554. private _initClickEvent;
  43555. private _initActionManager;
  43556. private _delayedSimpleClick;
  43557. private _delayedSimpleClickTimeout;
  43558. private _previousDelayedSimpleClickTimeout;
  43559. private _meshPickProceed;
  43560. private _previousButtonPressed;
  43561. private _currentPickResult;
  43562. private _previousPickResult;
  43563. private _totalPointersPressed;
  43564. private _doubleClickOccured;
  43565. private _pointerOverMesh;
  43566. private _pickedDownMesh;
  43567. private _pickedUpMesh;
  43568. private _pointerX;
  43569. private _pointerY;
  43570. private _unTranslatedPointerX;
  43571. private _unTranslatedPointerY;
  43572. private _startingPointerPosition;
  43573. private _previousStartingPointerPosition;
  43574. private _startingPointerTime;
  43575. private _previousStartingPointerTime;
  43576. private _pointerCaptures;
  43577. private _meshUnderPointerId;
  43578. private _onKeyDown;
  43579. private _onKeyUp;
  43580. private _keyboardIsAttached;
  43581. private _onCanvasFocusObserver;
  43582. private _onCanvasBlurObserver;
  43583. private _scene;
  43584. /**
  43585. * Creates a new InputManager
  43586. * @param scene defines the hosting scene
  43587. */
  43588. constructor(scene: Scene);
  43589. /**
  43590. * Gets the mesh that is currently under the pointer
  43591. */
  43592. get meshUnderPointer(): Nullable<AbstractMesh>;
  43593. /**
  43594. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43595. * @param pointerId the pointer id to use
  43596. * @returns The mesh under this pointer id or null if not found
  43597. */
  43598. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43599. /**
  43600. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43601. */
  43602. get unTranslatedPointer(): Vector2;
  43603. /**
  43604. * Gets or sets the current on-screen X position of the pointer
  43605. */
  43606. get pointerX(): number;
  43607. set pointerX(value: number);
  43608. /**
  43609. * Gets or sets the current on-screen Y position of the pointer
  43610. */
  43611. get pointerY(): number;
  43612. set pointerY(value: number);
  43613. private _updatePointerPosition;
  43614. private _processPointerMove;
  43615. private _setRayOnPointerInfo;
  43616. private _checkPrePointerObservable;
  43617. /**
  43618. * Use this method to simulate a pointer move on a mesh
  43619. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43620. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43621. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43622. */
  43623. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43624. /**
  43625. * Use this method to simulate a pointer down on a mesh
  43626. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43627. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43628. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43629. */
  43630. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43631. private _processPointerDown;
  43632. /** @hidden */
  43633. _isPointerSwiping(): boolean;
  43634. /**
  43635. * Use this method to simulate a pointer up on a mesh
  43636. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43637. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43638. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43639. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43640. */
  43641. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43642. private _processPointerUp;
  43643. /**
  43644. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43645. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43646. * @returns true if the pointer was captured
  43647. */
  43648. isPointerCaptured(pointerId?: number): boolean;
  43649. /**
  43650. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43651. * @param attachUp defines if you want to attach events to pointerup
  43652. * @param attachDown defines if you want to attach events to pointerdown
  43653. * @param attachMove defines if you want to attach events to pointermove
  43654. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43655. */
  43656. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43657. /**
  43658. * Detaches all event handlers
  43659. */
  43660. detachControl(): void;
  43661. /**
  43662. * Force the value of meshUnderPointer
  43663. * @param mesh defines the mesh to use
  43664. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43665. */
  43666. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43667. /**
  43668. * Gets the mesh under the pointer
  43669. * @returns a Mesh or null if no mesh is under the pointer
  43670. */
  43671. getPointerOverMesh(): Nullable<AbstractMesh>;
  43672. }
  43673. }
  43674. declare module BABYLON {
  43675. /**
  43676. * This class defines the direct association between an animation and a target
  43677. */
  43678. export class TargetedAnimation {
  43679. /**
  43680. * Animation to perform
  43681. */
  43682. animation: Animation;
  43683. /**
  43684. * Target to animate
  43685. */
  43686. target: any;
  43687. /**
  43688. * Returns the string "TargetedAnimation"
  43689. * @returns "TargetedAnimation"
  43690. */
  43691. getClassName(): string;
  43692. /**
  43693. * Serialize the object
  43694. * @returns the JSON object representing the current entity
  43695. */
  43696. serialize(): any;
  43697. }
  43698. /**
  43699. * Use this class to create coordinated animations on multiple targets
  43700. */
  43701. export class AnimationGroup implements IDisposable {
  43702. /** The name of the animation group */
  43703. name: string;
  43704. private _scene;
  43705. private _targetedAnimations;
  43706. private _animatables;
  43707. private _from;
  43708. private _to;
  43709. private _isStarted;
  43710. private _isPaused;
  43711. private _speedRatio;
  43712. private _loopAnimation;
  43713. private _isAdditive;
  43714. /**
  43715. * Gets or sets the unique id of the node
  43716. */
  43717. uniqueId: number;
  43718. /**
  43719. * This observable will notify when one animation have ended
  43720. */
  43721. onAnimationEndObservable: Observable<TargetedAnimation>;
  43722. /**
  43723. * Observer raised when one animation loops
  43724. */
  43725. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43726. /**
  43727. * Observer raised when all animations have looped
  43728. */
  43729. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43730. /**
  43731. * This observable will notify when all animations have ended.
  43732. */
  43733. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43734. /**
  43735. * This observable will notify when all animations have paused.
  43736. */
  43737. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43738. /**
  43739. * This observable will notify when all animations are playing.
  43740. */
  43741. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43742. /**
  43743. * Gets the first frame
  43744. */
  43745. get from(): number;
  43746. /**
  43747. * Gets the last frame
  43748. */
  43749. get to(): number;
  43750. /**
  43751. * Define if the animations are started
  43752. */
  43753. get isStarted(): boolean;
  43754. /**
  43755. * Gets a value indicating that the current group is playing
  43756. */
  43757. get isPlaying(): boolean;
  43758. /**
  43759. * Gets or sets the speed ratio to use for all animations
  43760. */
  43761. get speedRatio(): number;
  43762. /**
  43763. * Gets or sets the speed ratio to use for all animations
  43764. */
  43765. set speedRatio(value: number);
  43766. /**
  43767. * Gets or sets if all animations should loop or not
  43768. */
  43769. get loopAnimation(): boolean;
  43770. set loopAnimation(value: boolean);
  43771. /**
  43772. * Gets or sets if all animations should be evaluated additively
  43773. */
  43774. get isAdditive(): boolean;
  43775. set isAdditive(value: boolean);
  43776. /**
  43777. * Gets the targeted animations for this animation group
  43778. */
  43779. get targetedAnimations(): Array<TargetedAnimation>;
  43780. /**
  43781. * returning the list of animatables controlled by this animation group.
  43782. */
  43783. get animatables(): Array<Animatable>;
  43784. /**
  43785. * Gets the list of target animations
  43786. */
  43787. get children(): TargetedAnimation[];
  43788. /**
  43789. * Instantiates a new Animation Group.
  43790. * This helps managing several animations at once.
  43791. * @see https://doc.babylonjs.com/how_to/group
  43792. * @param name Defines the name of the group
  43793. * @param scene Defines the scene the group belongs to
  43794. */
  43795. constructor(
  43796. /** The name of the animation group */
  43797. name: string, scene?: Nullable<Scene>);
  43798. /**
  43799. * Add an animation (with its target) in the group
  43800. * @param animation defines the animation we want to add
  43801. * @param target defines the target of the animation
  43802. * @returns the TargetedAnimation object
  43803. */
  43804. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43805. /**
  43806. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43807. * It can add constant keys at begin or end
  43808. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43809. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43810. * @returns the animation group
  43811. */
  43812. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43813. private _animationLoopCount;
  43814. private _animationLoopFlags;
  43815. private _processLoop;
  43816. /**
  43817. * Start all animations on given targets
  43818. * @param loop defines if animations must loop
  43819. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43820. * @param from defines the from key (optional)
  43821. * @param to defines the to key (optional)
  43822. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43823. * @returns the current animation group
  43824. */
  43825. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43826. /**
  43827. * Pause all animations
  43828. * @returns the animation group
  43829. */
  43830. pause(): AnimationGroup;
  43831. /**
  43832. * Play all animations to initial state
  43833. * This function will start() the animations if they were not started or will restart() them if they were paused
  43834. * @param loop defines if animations must loop
  43835. * @returns the animation group
  43836. */
  43837. play(loop?: boolean): AnimationGroup;
  43838. /**
  43839. * Reset all animations to initial state
  43840. * @returns the animation group
  43841. */
  43842. reset(): AnimationGroup;
  43843. /**
  43844. * Restart animations from key 0
  43845. * @returns the animation group
  43846. */
  43847. restart(): AnimationGroup;
  43848. /**
  43849. * Stop all animations
  43850. * @returns the animation group
  43851. */
  43852. stop(): AnimationGroup;
  43853. /**
  43854. * Set animation weight for all animatables
  43855. * @param weight defines the weight to use
  43856. * @return the animationGroup
  43857. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43858. */
  43859. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43860. /**
  43861. * Synchronize and normalize all animatables with a source animatable
  43862. * @param root defines the root animatable to synchronize with
  43863. * @return the animationGroup
  43864. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43865. */
  43866. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43867. /**
  43868. * Goes to a specific frame in this animation group
  43869. * @param frame the frame number to go to
  43870. * @return the animationGroup
  43871. */
  43872. goToFrame(frame: number): AnimationGroup;
  43873. /**
  43874. * Dispose all associated resources
  43875. */
  43876. dispose(): void;
  43877. private _checkAnimationGroupEnded;
  43878. /**
  43879. * Clone the current animation group and returns a copy
  43880. * @param newName defines the name of the new group
  43881. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43882. * @returns the new aniamtion group
  43883. */
  43884. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43885. /**
  43886. * Serializes the animationGroup to an object
  43887. * @returns Serialized object
  43888. */
  43889. serialize(): any;
  43890. /**
  43891. * Returns a new AnimationGroup object parsed from the source provided.
  43892. * @param parsedAnimationGroup defines the source
  43893. * @param scene defines the scene that will receive the animationGroup
  43894. * @returns a new AnimationGroup
  43895. */
  43896. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43897. /**
  43898. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43899. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43900. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43901. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43902. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43903. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43904. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43905. */
  43906. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43907. /**
  43908. * Returns the string "AnimationGroup"
  43909. * @returns "AnimationGroup"
  43910. */
  43911. getClassName(): string;
  43912. /**
  43913. * Creates a detailled string about the object
  43914. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43915. * @returns a string representing the object
  43916. */
  43917. toString(fullDetails?: boolean): string;
  43918. }
  43919. }
  43920. declare module BABYLON {
  43921. /**
  43922. * @hidden
  43923. **/
  43924. export class _TimeToken {
  43925. _startTimeQuery: Nullable<WebGLQuery>;
  43926. _endTimeQuery: Nullable<WebGLQuery>;
  43927. _timeElapsedQuery: Nullable<WebGLQuery>;
  43928. _timeElapsedQueryEnded: boolean;
  43929. }
  43930. }
  43931. declare module BABYLON {
  43932. /** @hidden */
  43933. export enum ExtensionName {
  43934. DepthClamping = "depth-clamping",
  43935. Depth24UnormStencil8 = "depth24unorm-stencil8",
  43936. Depth32FloatStencil8 = "depth32float-stencil8",
  43937. PipelineStatisticsQuery = "pipeline-statistics-query",
  43938. TextureCompressionBC = "texture-compression-bc",
  43939. TimestampQuery = "timestamp-query"
  43940. }
  43941. /** @hidden */
  43942. export enum AddressMode {
  43943. ClampToEdge = "clamp-to-edge",
  43944. Repeat = "repeat",
  43945. MirrorRepeat = "mirror-repeat"
  43946. }
  43947. /** @hidden */
  43948. export enum BindingType {
  43949. UniformBuffer = "uniform-buffer",
  43950. StorageBuffer = "storage-buffer",
  43951. ReadonlyStorageBuffer = "readonly-storage-buffer",
  43952. Sampler = "sampler",
  43953. ComparisonSampler = "comparison-sampler",
  43954. SampledTexture = "sampled-texture",
  43955. ReadonlyStorageTexture = "readonly-storage-texture",
  43956. WriteonlyStorageTexture = "writeonly-storage-texture"
  43957. }
  43958. /** @hidden */
  43959. export enum BlendFactor {
  43960. Zero = "zero",
  43961. One = "one",
  43962. SrcColor = "src-color",
  43963. OneMinusSrcColor = "one-minus-src-color",
  43964. SrcAlpha = "src-alpha",
  43965. OneMinusSrcAlpha = "one-minus-src-alpha",
  43966. DstColor = "dst-color",
  43967. OneMinusDstColor = "one-minus-dst-color",
  43968. DstAlpha = "dst-alpha",
  43969. OneMinusDstAlpha = "one-minus-dst-alpha",
  43970. SrcAlphaSaturated = "src-alpha-saturated",
  43971. BlendColor = "blend-color",
  43972. OneMinusBlendColor = "one-minus-blend-color"
  43973. }
  43974. /** @hidden */
  43975. export enum BlendOperation {
  43976. Add = "add",
  43977. Subtract = "subtract",
  43978. ReverseSubtract = "reverse-subtract",
  43979. Min = "min",
  43980. Max = "max"
  43981. }
  43982. /** @hidden */
  43983. export enum CompareFunction {
  43984. Never = "never",
  43985. Less = "less",
  43986. Equal = "equal",
  43987. LessEqual = "less-equal",
  43988. Greater = "greater",
  43989. NotEqual = "not-equal",
  43990. GreaterEqual = "greater-equal",
  43991. Always = "always"
  43992. }
  43993. /** @hidden */
  43994. export enum CullMode {
  43995. None = "none",
  43996. Front = "front",
  43997. Back = "back"
  43998. }
  43999. /** @hidden */
  44000. export enum FilterMode {
  44001. Nearest = "nearest",
  44002. Linear = "linear"
  44003. }
  44004. /** @hidden */
  44005. export enum FrontFace {
  44006. CCW = "ccw",
  44007. CW = "cw"
  44008. }
  44009. /** @hidden */
  44010. export enum IndexFormat {
  44011. Uint16 = "uint16",
  44012. Uint32 = "uint32"
  44013. }
  44014. /** @hidden */
  44015. export enum InputStepMode {
  44016. Vertex = "vertex",
  44017. Instance = "instance"
  44018. }
  44019. /** @hidden */
  44020. export enum LoadOp {
  44021. Load = "load"
  44022. }
  44023. /** @hidden */
  44024. export enum PrimitiveTopology {
  44025. PointList = "point-list",
  44026. LineList = "line-list",
  44027. LineStrip = "line-strip",
  44028. TriangleList = "triangle-list",
  44029. TriangleStrip = "triangle-strip"
  44030. }
  44031. /** @hidden */
  44032. export enum StencilOperation {
  44033. Keep = "keep",
  44034. Zero = "zero",
  44035. Replace = "replace",
  44036. Invert = "invert",
  44037. IncrementClamp = "increment-clamp",
  44038. DecrementClamp = "decrement-clamp",
  44039. IncrementWrap = "increment-wrap",
  44040. DecrementWrap = "decrement-wrap"
  44041. }
  44042. /** @hidden */
  44043. export enum StoreOp {
  44044. Store = "store",
  44045. Clear = "clear"
  44046. }
  44047. /** @hidden */
  44048. export enum TextureDimension {
  44049. E1d = "1d",
  44050. E2d = "2d",
  44051. E3d = "3d"
  44052. }
  44053. /** @hidden */
  44054. export enum TextureFormat {
  44055. R8Unorm = "r8unorm",
  44056. R8Snorm = "r8snorm",
  44057. R8Uint = "r8uint",
  44058. R8Sint = "r8sint",
  44059. R16Uint = "r16uint",
  44060. R16Sint = "r16sint",
  44061. R16Float = "r16float",
  44062. RG8Unorm = "rg8unorm",
  44063. RG8Snorm = "rg8snorm",
  44064. RG8Uint = "rg8uint",
  44065. RG8Sint = "rg8sint",
  44066. R32Uint = "r32uint",
  44067. R32Sint = "r32sint",
  44068. R32Float = "r32float",
  44069. RG16Uint = "rg16uint",
  44070. RG16Sint = "rg16sint",
  44071. RG16Float = "rg16float",
  44072. RGBA8Unorm = "rgba8unorm",
  44073. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44074. RGBA8Snorm = "rgba8snorm",
  44075. RGBA8Uint = "rgba8uint",
  44076. RGBA8Sint = "rgba8sint",
  44077. BGRA8Unorm = "bgra8unorm",
  44078. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44079. RGB9E5UFloat = "rgb9e5ufloat",
  44080. RGB10A2Unorm = "rgb10a2unorm",
  44081. RG11B10UFloat = "rg11b10ufloat",
  44082. RG32Uint = "rg32uint",
  44083. RG32Sint = "rg32sint",
  44084. RG32Float = "rg32float",
  44085. RGBA16Uint = "rgba16uint",
  44086. RGBA16Sint = "rgba16sint",
  44087. RGBA16Float = "rgba16float",
  44088. RGBA32Uint = "rgba32uint",
  44089. RGBA32Sint = "rgba32sint",
  44090. RGBA32Float = "rgba32float",
  44091. Stencil8 = "stencil8",
  44092. Depth16Unorm = "depth16unorm",
  44093. Depth24Plus = "depth24plus",
  44094. Depth24PlusStencil8 = "depth24plus-stencil8",
  44095. Depth32Float = "depth32float",
  44096. BC1RGBAUNorm = "bc1-rgba-unorm",
  44097. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44098. BC2RGBAUnorm = "bc2-rgba-unorm",
  44099. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44100. BC3RGBAUnorm = "bc3-rgba-unorm",
  44101. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44102. BC4RUnorm = "bc4-r-unorm",
  44103. BC4RSnorm = "bc4-r-snorm",
  44104. BC5RGUnorm = "bc5-rg-unorm",
  44105. BC5RGSnorm = "bc5-rg-snorm",
  44106. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44107. BC6HRGBFloat = "bc6h-rgb-float",
  44108. BC7RGBAUnorm = "bc7-rgba-unorm",
  44109. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44110. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44111. Depth32FloatStencil8 = "depth32float-stencil8"
  44112. }
  44113. /** @hidden */
  44114. export enum TextureComponentType {
  44115. Float = "float",
  44116. Sint = "sint",
  44117. Uint = "uint",
  44118. DepthComparison = "depth-comparison"
  44119. }
  44120. /** @hidden */
  44121. export enum TextureViewDimension {
  44122. E1d = "1d",
  44123. E2d = "2d",
  44124. E2dArray = "2d-array",
  44125. Cube = "cube",
  44126. CubeArray = "cube-array",
  44127. E3d = "3d"
  44128. }
  44129. /** @hidden */
  44130. export enum VertexFormat {
  44131. Uchar2 = "uchar2",
  44132. Uchar4 = "uchar4",
  44133. Char2 = "char2",
  44134. Char4 = "char4",
  44135. Uchar2Norm = "uchar2norm",
  44136. Uchar4Norm = "uchar4norm",
  44137. Char2Norm = "char2norm",
  44138. Char4Norm = "char4norm",
  44139. Ushort2 = "ushort2",
  44140. Ushort4 = "ushort4",
  44141. Short2 = "short2",
  44142. Short4 = "short4",
  44143. Ushort2Norm = "ushort2norm",
  44144. Ushort4Norm = "ushort4norm",
  44145. Short2Norm = "short2norm",
  44146. Short4Norm = "short4norm",
  44147. Half2 = "half2",
  44148. Half4 = "half4",
  44149. Float = "float",
  44150. Float2 = "float2",
  44151. Float3 = "float3",
  44152. Float4 = "float4",
  44153. Uint = "uint",
  44154. Uint2 = "uint2",
  44155. Uint3 = "uint3",
  44156. Uint4 = "uint4",
  44157. Int = "int",
  44158. Int2 = "int2",
  44159. Int3 = "int3",
  44160. Int4 = "int4"
  44161. }
  44162. /** @hidden */
  44163. export enum TextureAspect {
  44164. All = "all",
  44165. StencilOnly = "stencil-only",
  44166. DepthOnly = "depth-only"
  44167. }
  44168. /** @hidden */
  44169. export enum CompilationMessageType {
  44170. Error = "error",
  44171. Warning = "warning",
  44172. Info = "info"
  44173. }
  44174. /** @hidden */
  44175. export enum QueryType {
  44176. Occlusion = "occlusion"
  44177. }
  44178. /** @hidden */
  44179. export enum BufferUsage {
  44180. MapRead = 1,
  44181. MapWrite = 2,
  44182. CopySrc = 4,
  44183. CopyDst = 8,
  44184. Index = 16,
  44185. Vertex = 32,
  44186. Uniform = 64,
  44187. Storage = 128,
  44188. Indirect = 256,
  44189. QueryResolve = 512
  44190. }
  44191. /** @hidden */
  44192. export enum ColorWrite {
  44193. Red = 1,
  44194. Green = 2,
  44195. Blue = 4,
  44196. Alpha = 8,
  44197. All = 15
  44198. }
  44199. /** @hidden */
  44200. export enum ShaderStage {
  44201. Vertex = 1,
  44202. Fragment = 2,
  44203. Compute = 4
  44204. }
  44205. /** @hidden */
  44206. export enum TextureUsage {
  44207. CopySrc = 1,
  44208. CopyDst = 2,
  44209. Sampled = 4,
  44210. Storage = 8,
  44211. OutputAttachment = 16
  44212. }
  44213. /** @hidden */
  44214. export enum MapMode {
  44215. Read = 1,
  44216. Write = 2
  44217. }
  44218. }
  44219. declare module BABYLON {
  44220. /** @hidden */
  44221. export interface WebGPUBindingInfo {
  44222. setIndex: number;
  44223. bindingIndex: number;
  44224. }
  44225. /** @hidden */
  44226. export interface WebGPUTextureSamplerBindingDescription {
  44227. sampler: WebGPUBindingInfo;
  44228. isTextureArray: boolean;
  44229. textures: Array<WebGPUBindingInfo>;
  44230. }
  44231. /** @hidden
  44232. * If the binding is a UBO, isSampler=isTexture=false
  44233. */
  44234. export interface WebGPUBindingDescription {
  44235. name: string;
  44236. usedInVertex: boolean;
  44237. usedInFragment: boolean;
  44238. isSampler: boolean;
  44239. isComparisonSampler?: boolean;
  44240. isTexture: boolean;
  44241. componentType?: GPUTextureComponentType;
  44242. textureDimension?: GPUTextureViewDimension;
  44243. }
  44244. /**
  44245. * @hidden
  44246. */
  44247. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44248. uboNextBindingIndex: number;
  44249. freeSetIndex: number;
  44250. freeBindingIndex: number;
  44251. availableVaryings: {
  44252. [key: string]: number;
  44253. };
  44254. availableAttributes: {
  44255. [key: string]: number;
  44256. };
  44257. availableUBOs: {
  44258. [key: string]: {
  44259. setIndex: number;
  44260. bindingIndex: number;
  44261. };
  44262. };
  44263. availableSamplers: {
  44264. [key: string]: WebGPUTextureSamplerBindingDescription;
  44265. };
  44266. leftOverUniforms: {
  44267. name: string;
  44268. type: string;
  44269. length: number;
  44270. }[];
  44271. orderedAttributes: string[];
  44272. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44273. uniformBufferNames: string[];
  44274. private _attributeNextLocation;
  44275. private _varyingNextLocation;
  44276. constructor();
  44277. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44278. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44279. getNextFreeUBOBinding(): {
  44280. setIndex: number;
  44281. bindingIndex: number;
  44282. };
  44283. private _getNextFreeBinding;
  44284. }
  44285. }
  44286. declare module BABYLON {
  44287. /** @hidden */
  44288. export interface IWebGPUPipelineContextSamplerCache {
  44289. samplerBinding: number;
  44290. firstTextureName: string;
  44291. }
  44292. /** @hidden */
  44293. export interface IWebGPUPipelineContextTextureCache {
  44294. textureBinding: number;
  44295. texture: InternalTexture;
  44296. }
  44297. /** @hidden */
  44298. export interface IWebGPUPipelineContextVertexInputsCache {
  44299. indexBuffer: Nullable<GPUBuffer>;
  44300. indexOffset: number;
  44301. vertexStartSlot: number;
  44302. vertexBuffers: GPUBuffer[];
  44303. vertexOffsets: number[];
  44304. }
  44305. /** @hidden */
  44306. export interface IWebGPURenderPipelineStageDescriptor {
  44307. vertexStage: GPUProgrammableStageDescriptor;
  44308. fragmentStage?: GPUProgrammableStageDescriptor;
  44309. }
  44310. /** @hidden */
  44311. export class WebGPUPipelineContext implements IPipelineContext {
  44312. engine: WebGPUEngine;
  44313. shaderProcessingContext: WebGPUShaderProcessingContext;
  44314. leftOverUniformsByName: {
  44315. [name: string]: string;
  44316. };
  44317. sources: {
  44318. vertex: string;
  44319. fragment: string;
  44320. rawVertex: string;
  44321. rawFragment: string;
  44322. };
  44323. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44324. samplers: {
  44325. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44326. };
  44327. textures: {
  44328. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44329. };
  44330. bindGroupLayouts: GPUBindGroupLayout[];
  44331. bindGroupsCache: {
  44332. [key: string]: GPUBindGroup[];
  44333. };
  44334. /**
  44335. * Stores the uniform buffer
  44336. */
  44337. uniformBuffer: Nullable<UniformBuffer>;
  44338. onCompiled?: () => void;
  44339. get isAsync(): boolean;
  44340. get isReady(): boolean;
  44341. /** @hidden */
  44342. _name: string;
  44343. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44344. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44345. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44346. [key: string]: number;
  44347. }, uniformsNames: string[], uniforms: {
  44348. [key: string]: Nullable<WebGLUniformLocation>;
  44349. }, samplerList: string[], samplers: {
  44350. [key: string]: number;
  44351. }, attributesNames: string[], attributes: number[]): void;
  44352. /** @hidden */
  44353. /**
  44354. * Build the uniform buffer used in the material.
  44355. */
  44356. buildUniformLayout(): void;
  44357. /**
  44358. * Release all associated resources.
  44359. **/
  44360. dispose(): void;
  44361. /**
  44362. * Sets an integer value on a uniform variable.
  44363. * @param uniformName Name of the variable.
  44364. * @param value Value to be set.
  44365. */
  44366. setInt(uniformName: string, value: number): void;
  44367. /**
  44368. * Sets an int2 value on a uniform variable.
  44369. * @param uniformName Name of the variable.
  44370. * @param x First int in int2.
  44371. * @param y Second int in int2.
  44372. */
  44373. setInt2(uniformName: string, x: number, y: number): void;
  44374. /**
  44375. * Sets an int3 value on a uniform variable.
  44376. * @param uniformName Name of the variable.
  44377. * @param x First int in int3.
  44378. * @param y Second int in int3.
  44379. * @param z Third int in int3.
  44380. */
  44381. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44382. /**
  44383. * Sets an int4 value on a uniform variable.
  44384. * @param uniformName Name of the variable.
  44385. * @param x First int in int4.
  44386. * @param y Second int in int4.
  44387. * @param z Third int in int4.
  44388. * @param w Fourth int in int4.
  44389. */
  44390. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44391. /**
  44392. * Sets an int array on a uniform variable.
  44393. * @param uniformName Name of the variable.
  44394. * @param array array to be set.
  44395. */
  44396. setIntArray(uniformName: string, array: Int32Array): void;
  44397. /**
  44398. * 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)
  44399. * @param uniformName Name of the variable.
  44400. * @param array array to be set.
  44401. */
  44402. setIntArray2(uniformName: string, array: Int32Array): void;
  44403. /**
  44404. * 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)
  44405. * @param uniformName Name of the variable.
  44406. * @param array array to be set.
  44407. */
  44408. setIntArray3(uniformName: string, array: Int32Array): void;
  44409. /**
  44410. * 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)
  44411. * @param uniformName Name of the variable.
  44412. * @param array array to be set.
  44413. */
  44414. setIntArray4(uniformName: string, array: Int32Array): void;
  44415. /**
  44416. * Sets an array on a uniform variable.
  44417. * @param uniformName Name of the variable.
  44418. * @param array array to be set.
  44419. */
  44420. setArray(uniformName: string, array: number[]): void;
  44421. /**
  44422. * 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)
  44423. * @param uniformName Name of the variable.
  44424. * @param array array to be set.
  44425. */
  44426. setArray2(uniformName: string, array: number[]): void;
  44427. /**
  44428. * 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)
  44429. * @param uniformName Name of the variable.
  44430. * @param array array to be set.
  44431. * @returns this effect.
  44432. */
  44433. setArray3(uniformName: string, array: number[]): void;
  44434. /**
  44435. * 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)
  44436. * @param uniformName Name of the variable.
  44437. * @param array array to be set.
  44438. */
  44439. setArray4(uniformName: string, array: number[]): void;
  44440. /**
  44441. * Sets matrices on a uniform variable.
  44442. * @param uniformName Name of the variable.
  44443. * @param matrices matrices to be set.
  44444. */
  44445. setMatrices(uniformName: string, matrices: Float32Array): void;
  44446. /**
  44447. * Sets matrix on a uniform variable.
  44448. * @param uniformName Name of the variable.
  44449. * @param matrix matrix to be set.
  44450. */
  44451. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44452. /**
  44453. * 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)
  44454. * @param uniformName Name of the variable.
  44455. * @param matrix matrix to be set.
  44456. */
  44457. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44458. /**
  44459. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44460. * @param uniformName Name of the variable.
  44461. * @param matrix matrix to be set.
  44462. */
  44463. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44464. /**
  44465. * Sets a float on a uniform variable.
  44466. * @param uniformName Name of the variable.
  44467. * @param value value to be set.
  44468. * @returns this effect.
  44469. */
  44470. setFloat(uniformName: string, value: number): void;
  44471. /**
  44472. * Sets a Vector2 on a uniform variable.
  44473. * @param uniformName Name of the variable.
  44474. * @param vector2 vector2 to be set.
  44475. */
  44476. setVector2(uniformName: string, vector2: IVector2Like): void;
  44477. /**
  44478. * Sets a float2 on a uniform variable.
  44479. * @param uniformName Name of the variable.
  44480. * @param x First float in float2.
  44481. * @param y Second float in float2.
  44482. */
  44483. setFloat2(uniformName: string, x: number, y: number): void;
  44484. /**
  44485. * Sets a Vector3 on a uniform variable.
  44486. * @param uniformName Name of the variable.
  44487. * @param vector3 Value to be set.
  44488. */
  44489. setVector3(uniformName: string, vector3: IVector3Like): void;
  44490. /**
  44491. * Sets a float3 on a uniform variable.
  44492. * @param uniformName Name of the variable.
  44493. * @param x First float in float3.
  44494. * @param y Second float in float3.
  44495. * @param z Third float in float3.
  44496. */
  44497. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44498. /**
  44499. * Sets a Vector4 on a uniform variable.
  44500. * @param uniformName Name of the variable.
  44501. * @param vector4 Value to be set.
  44502. */
  44503. setVector4(uniformName: string, vector4: IVector4Like): void;
  44504. /**
  44505. * Sets a float4 on a uniform variable.
  44506. * @param uniformName Name of the variable.
  44507. * @param x First float in float4.
  44508. * @param y Second float in float4.
  44509. * @param z Third float in float4.
  44510. * @param w Fourth float in float4.
  44511. * @returns this effect.
  44512. */
  44513. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44514. /**
  44515. * Sets a Color3 on a uniform variable.
  44516. * @param uniformName Name of the variable.
  44517. * @param color3 Value to be set.
  44518. */
  44519. setColor3(uniformName: string, color3: IColor3Like): void;
  44520. /**
  44521. * Sets a Color4 on a uniform variable.
  44522. * @param uniformName Name of the variable.
  44523. * @param color3 Value to be set.
  44524. * @param alpha Alpha value to be set.
  44525. */
  44526. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44527. /**
  44528. * Sets a Color4 on a uniform variable
  44529. * @param uniformName defines the name of the variable
  44530. * @param color4 defines the value to be set
  44531. */
  44532. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44533. _getVertexShaderCode(): string | null;
  44534. _getFragmentShaderCode(): string | null;
  44535. }
  44536. }
  44537. declare module BABYLON {
  44538. /** @hidden */
  44539. export class WebGPUDataBuffer extends DataBuffer {
  44540. private _buffer;
  44541. constructor(resource: GPUBuffer);
  44542. get underlyingResource(): any;
  44543. }
  44544. }
  44545. declare module BABYLON {
  44546. /**
  44547. * Class used to inline functions in shader code
  44548. */
  44549. export class ShaderCodeInliner {
  44550. private static readonly _RegexpFindFunctionNameAndType;
  44551. private _sourceCode;
  44552. private _functionDescr;
  44553. private _numMaxIterations;
  44554. /** Gets or sets the token used to mark the functions to inline */
  44555. inlineToken: string;
  44556. /** Gets or sets the debug mode */
  44557. debug: boolean;
  44558. /** Gets the code after the inlining process */
  44559. get code(): string;
  44560. /**
  44561. * Initializes the inliner
  44562. * @param sourceCode shader code source to inline
  44563. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44564. */
  44565. constructor(sourceCode: string, numMaxIterations?: number);
  44566. /**
  44567. * Start the processing of the shader code
  44568. */
  44569. processCode(): void;
  44570. private _collectFunctions;
  44571. private _processInlining;
  44572. private _extractBetweenMarkers;
  44573. private _skipWhitespaces;
  44574. private _isIdentifierChar;
  44575. private _removeComments;
  44576. private _replaceFunctionCallsByCode;
  44577. private _findBackward;
  44578. private _escapeRegExp;
  44579. private _replaceNames;
  44580. }
  44581. }
  44582. declare module BABYLON {
  44583. /** @hidden */
  44584. export class WebGPUShaderProcessor implements IShaderProcessor {
  44585. protected _missingVaryings: Array<string>;
  44586. protected _textureArrayProcessing: Array<string>;
  44587. protected _preProcessors: {
  44588. [key: string]: string;
  44589. };
  44590. private _getArraySize;
  44591. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44592. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44593. [key: string]: string;
  44594. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44595. attributeProcessor(attribute: string, preProcessors: {
  44596. [key: string]: string;
  44597. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44598. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44599. [key: string]: string;
  44600. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44601. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44602. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44603. private _applyTextureArrayProcessing;
  44604. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44605. vertexCode: string;
  44606. fragmentCode: string;
  44607. };
  44608. }
  44609. }
  44610. declare module BABYLON {
  44611. /** @hidden */
  44612. export class WebGPUBufferManager {
  44613. private _device;
  44614. private _deferredReleaseBuffers;
  44615. private static _IsGPUBuffer;
  44616. constructor(device: GPUDevice);
  44617. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44618. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44619. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44620. private _FromHalfFloat;
  44621. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44622. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44623. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44624. destroyDeferredBuffers(): void;
  44625. }
  44626. }
  44627. declare module BABYLON {
  44628. /** @hidden */
  44629. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44630. private _webgpuTexture;
  44631. private _webgpuMSAATexture;
  44632. get underlyingResource(): Nullable<GPUTexture>;
  44633. get msaaTexture(): Nullable<GPUTexture>;
  44634. set msaaTexture(texture: Nullable<GPUTexture>);
  44635. view: Nullable<GPUTextureView>;
  44636. format: GPUTextureFormat;
  44637. textureUsages: number;
  44638. constructor(existingTexture?: Nullable<GPUTexture>);
  44639. set(hardwareTexture: GPUTexture): void;
  44640. setMSAATexture(hardwareTexture: GPUTexture): void;
  44641. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44642. createView(descriptor?: GPUTextureViewDescriptor): void;
  44643. reset(): void;
  44644. release(): void;
  44645. }
  44646. }
  44647. declare module BABYLON {
  44648. /** @hidden */
  44649. export class WebGPUTextureHelper {
  44650. private _device;
  44651. private _glslang;
  44652. private _bufferManager;
  44653. private _mipmapSampler;
  44654. private _invertYPreMultiplyAlphaSampler;
  44655. private _pipelines;
  44656. private _compiledShaders;
  44657. private _deferredReleaseTextures;
  44658. private _commandEncoderForCreation;
  44659. static ComputeNumMipmapLevels(width: number, height: number): number;
  44660. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44661. private _getPipeline;
  44662. private static _GetTextureTypeFromFormat;
  44663. private static _GetBlockInformationFromFormat;
  44664. private static _IsHardwareTexture;
  44665. private static _IsInternalTexture;
  44666. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44667. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44668. width: number;
  44669. height: number;
  44670. }): imageBitmap is ImageBitmap;
  44671. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44672. width: number;
  44673. height: number;
  44674. }): imageBitmap is ImageBitmap[];
  44675. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44676. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44677. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44678. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44679. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44680. createTexture(imageBitmap: ImageBitmap | {
  44681. width: number;
  44682. height: number;
  44683. layers: number;
  44684. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44685. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44686. width: number;
  44687. height: number;
  44688. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44689. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44690. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44691. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44692. createMSAATexture(texture: InternalTexture, samples: number): void;
  44693. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44694. updateTexture(imageBitmap: ImageBitmap | Uint8Array, gpuTexture: GPUTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44695. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44696. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44697. destroyDeferredTextures(): void;
  44698. }
  44699. }
  44700. declare module BABYLON {
  44701. /** @hidden */
  44702. export class WebGPURenderPassWrapper {
  44703. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44704. renderPass: Nullable<GPURenderPassEncoder>;
  44705. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44706. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44707. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44708. depthTextureFormat: GPUTextureFormat | undefined;
  44709. constructor();
  44710. reset(fullReset?: boolean): void;
  44711. }
  44712. }
  44713. declare module BABYLON {
  44714. /** @hidden */
  44715. export class WebGPUCacheSampler {
  44716. private _samplers;
  44717. private _device;
  44718. disabled: boolean;
  44719. constructor(device: GPUDevice);
  44720. private static _GetSamplerHashCode;
  44721. private static _GetSamplerFilterDescriptor;
  44722. private static _GetWrappingMode;
  44723. private static _GetSamplerWrappingDescriptor;
  44724. private static _GetSamplerDescriptor;
  44725. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44726. }
  44727. }
  44728. declare module BABYLON {
  44729. /** @hidden */
  44730. export class WebGPUShaderManager {
  44731. private _shaders;
  44732. private _device;
  44733. constructor(device: GPUDevice);
  44734. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44735. }
  44736. }
  44737. declare module BABYLON {
  44738. /** @hidden */
  44739. export class WebGPUCacheRenderPipeline {
  44740. static NumCacheHitWithoutHash: number;
  44741. static NumCacheHitWithHash: number;
  44742. static NumCacheMiss: number;
  44743. static NumPipelineCreationLastFrame: number;
  44744. disabled: boolean;
  44745. private static _Cache;
  44746. private static _NumPipelineCreationCurrentFrame;
  44747. private _device;
  44748. private _states;
  44749. private _isDirty;
  44750. private _currentRenderPipeline;
  44751. private _emptyVertexBuffer;
  44752. private _shaderId;
  44753. private _alphaToCoverageEnabled;
  44754. private _frontFace;
  44755. private _cullEnabled;
  44756. private _cullFace;
  44757. private _clampDepth;
  44758. private _rasterizationState;
  44759. private _depthBias;
  44760. private _depthBiasClamp;
  44761. private _depthBiasSlopeScale;
  44762. private _colorFormat;
  44763. private _webgpuColorFormat;
  44764. private _mrtAttachments1;
  44765. private _mrtAttachments2;
  44766. private _mrtFormats;
  44767. private _alphaBlendEnabled;
  44768. private _alphaBlendFuncParams;
  44769. private _alphaBlendEqParams;
  44770. private _writeMask;
  44771. private _colorStates;
  44772. private _depthStencilFormat;
  44773. private _webgpuDepthStencilFormat;
  44774. private _depthTestEnabled;
  44775. private _depthWriteEnabled;
  44776. private _depthCompare;
  44777. private _stencilEnabled;
  44778. private _stencilFrontCompare;
  44779. private _stencilFrontDepthFailOp;
  44780. private _stencilFrontPassOp;
  44781. private _stencilFrontFailOp;
  44782. private _stencilReadMask;
  44783. private _stencilWriteMask;
  44784. private _depthStencilState;
  44785. private _vertexBuffers;
  44786. private _indexBuffer;
  44787. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  44788. reset(): void;
  44789. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  44790. endFrame(): void;
  44791. setAlphaToCoverage(enabled: boolean): void;
  44792. setFrontFace(frontFace: number): void;
  44793. setCullEnabled(enabled: boolean): void;
  44794. setCullFace(cullFace: number): void;
  44795. setClampDepth(clampDepth: boolean): void;
  44796. resetDepthCullingState(): void;
  44797. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  44798. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  44799. setColorFormat(format: GPUTextureFormat): void;
  44800. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  44801. setAlphaBlendEnabled(enabled: boolean): void;
  44802. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  44803. setWriteMask(mask: number): void;
  44804. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  44805. setDepthTestEnabled(enabled: boolean): void;
  44806. setDepthWriteEnabled(enabled: boolean): void;
  44807. setDepthCompare(func: Nullable<number>): void;
  44808. setStencilEnabled(enabled: boolean): void;
  44809. setStencilCompare(func: Nullable<number>): void;
  44810. setStencilDepthFailOp(op: Nullable<number>): void;
  44811. setStencilPassOp(op: Nullable<number>): void;
  44812. setStencilFailOp(op: Nullable<number>): void;
  44813. setStencilReadMask(mask: number): void;
  44814. setStencilWriteMask(mask: number): void;
  44815. resetStencilState(): void;
  44816. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  44817. setBuffers(vertexBuffers: Nullable<{
  44818. [key: string]: Nullable<VertexBuffer>;
  44819. }>, indexBuffer: Nullable<DataBuffer>): void;
  44820. private static _GetTopology;
  44821. private static _GetAphaBlendOperation;
  44822. private static _GetAphaBlendFactor;
  44823. private static _GetCompareFunction;
  44824. private static _GetStencilOpFunction;
  44825. private static _GetVertexInputDescriptorFormat;
  44826. private _getAphaBlendState;
  44827. private _getColorBlendState;
  44828. private _setShaderStage;
  44829. private _setRasterizationState;
  44830. private _setColorStates;
  44831. private _setDepthStencilState;
  44832. private _setVertexState;
  44833. private _createPipelineLayout;
  44834. private _getVertexInputDescriptor;
  44835. private _createRenderPipeline;
  44836. }
  44837. }
  44838. declare module BABYLON {
  44839. /** @hidden */
  44840. export var clearQuadVertexShader: {
  44841. name: string;
  44842. shader: string;
  44843. };
  44844. }
  44845. declare module BABYLON {
  44846. /** @hidden */
  44847. export var clearQuadPixelShader: {
  44848. name: string;
  44849. shader: string;
  44850. };
  44851. }
  44852. declare module BABYLON {
  44853. /**
  44854. * Options to load the associated Glslang library
  44855. */
  44856. export interface GlslangOptions {
  44857. /**
  44858. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44859. */
  44860. glslang?: any;
  44861. /**
  44862. * Defines the URL of the glslang JS File.
  44863. */
  44864. jsPath?: string;
  44865. /**
  44866. * Defines the URL of the glslang WASM File.
  44867. */
  44868. wasmPath?: string;
  44869. }
  44870. /**
  44871. * Options to create the WebGPU engine
  44872. */
  44873. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44874. /**
  44875. * If delta time between frames should be constant
  44876. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44877. */
  44878. deterministicLockstep?: boolean;
  44879. /**
  44880. * Maximum about of steps between frames (Default: 4)
  44881. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44882. */
  44883. lockstepMaxSteps?: number;
  44884. /**
  44885. * Defines the seconds between each deterministic lock step
  44886. */
  44887. timeStep?: number;
  44888. /**
  44889. * Defines that engine should ignore modifying touch action attribute and style
  44890. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44891. */
  44892. doNotHandleTouchAction?: boolean;
  44893. /**
  44894. * Defines if webaudio should be initialized as well
  44895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44896. */
  44897. audioEngine?: boolean;
  44898. /**
  44899. * Defines the category of adapter to use.
  44900. * Is it the discrete or integrated device.
  44901. */
  44902. powerPreference?: GPUPowerPreference;
  44903. /**
  44904. * Defines the device descriptor used to create a device.
  44905. */
  44906. deviceDescriptor?: GPUDeviceDescriptor;
  44907. /**
  44908. * Defines the requested Swap Chain Format.
  44909. */
  44910. swapChainFormat?: GPUTextureFormat;
  44911. /**
  44912. * Defines wether MSAA is enabled on the canvas.
  44913. */
  44914. antialiasing?: boolean;
  44915. /**
  44916. * Defines wether the stencil buffer should be enabled.
  44917. */
  44918. stencil?: boolean;
  44919. /**
  44920. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44921. */
  44922. enableGPUDebugMarkers?: boolean;
  44923. /**
  44924. * Options to load the associated Glslang library
  44925. */
  44926. glslangOptions?: GlslangOptions;
  44927. }
  44928. /**
  44929. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44930. */
  44931. export class WebGPUEngine extends Engine {
  44932. private static readonly _glslangDefaultOptions;
  44933. private readonly _uploadEncoderDescriptor;
  44934. private readonly _renderEncoderDescriptor;
  44935. private readonly _renderTargetEncoderDescriptor;
  44936. private readonly _clearDepthValue;
  44937. private readonly _clearReverseDepthValue;
  44938. private readonly _clearStencilValue;
  44939. private readonly _defaultSampleCount;
  44940. private _canvas;
  44941. private _options;
  44942. private _glslang;
  44943. private _adapter;
  44944. private _adapterSupportedExtensions;
  44945. private _device;
  44946. private _deviceEnabledExtensions;
  44947. private _context;
  44948. private _swapChain;
  44949. private _swapChainTexture;
  44950. private _mainPassSampleCount;
  44951. private _textureHelper;
  44952. private _bufferManager;
  44953. private _shaderManager;
  44954. private _cacheSampler;
  44955. private _cacheRenderPipeline;
  44956. private _emptyVertexBuffer;
  44957. private _lastCachedWrapU;
  44958. private _lastCachedWrapV;
  44959. private _lastCachedWrapR;
  44960. private _mrtAttachments;
  44961. private _counters;
  44962. private _mainTexture;
  44963. private _depthTexture;
  44964. private _mainTextureExtends;
  44965. private _depthTextureFormat;
  44966. private _colorFormat;
  44967. private _uploadEncoder;
  44968. private _renderEncoder;
  44969. private _renderTargetEncoder;
  44970. private _commandBuffers;
  44971. private _currentRenderPass;
  44972. private _mainRenderPassWrapper;
  44973. private _rttRenderPassWrapper;
  44974. private _pendingDebugCommands;
  44975. private _currentVertexBuffers;
  44976. private _currentIndexBuffer;
  44977. private __colorWrite;
  44978. private _uniformsBuffers;
  44979. private _forceEnableEffect;
  44980. /** @hidden */
  44981. dbgShowShaderCode: boolean;
  44982. /** @hidden */
  44983. dbgSanityChecks: boolean;
  44984. /** @hidden */
  44985. dbgGenerateLogs: boolean;
  44986. /** @hidden */
  44987. dbgVerboseLogsForFirstFrames: boolean;
  44988. /** @hidden */
  44989. dbgVerboseLogsNumFrames: number;
  44990. /** @hidden */
  44991. dbgShowWarningsNotImplemented: boolean;
  44992. /**
  44993. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  44994. */
  44995. get disableCacheSamplers(): boolean;
  44996. set disableCacheSamplers(disable: boolean);
  44997. /**
  44998. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  44999. */
  45000. get disableCacheRenderPipelines(): boolean;
  45001. set disableCacheRenderPipelines(disable: boolean);
  45002. /**
  45003. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  45004. * @returns true if the engine can be created
  45005. */
  45006. static get IsSupported(): boolean;
  45007. /**
  45008. * Gets a boolean indicating that the engine supports uniform buffers
  45009. */
  45010. get supportsUniformBuffers(): boolean;
  45011. /** Gets the supported extensions by the WebGPU adapter */
  45012. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45013. /** Gets the currently enabled extensions on the WebGPU device */
  45014. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45015. /**
  45016. * Returns the name of the engine
  45017. */
  45018. get name(): string;
  45019. /**
  45020. * Returns a string describing the current engine
  45021. */
  45022. get description(): string;
  45023. /**
  45024. * Returns the version of the engine
  45025. */
  45026. get version(): number;
  45027. /**
  45028. * Create a new instance of the gpu engine asynchronously
  45029. * @param canvas Defines the canvas to use to display the result
  45030. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45031. * @returns a promise that resolves with the created engine
  45032. */
  45033. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45034. /**
  45035. * Create a new instance of the gpu engine.
  45036. * @param canvas Defines the canvas to use to display the result
  45037. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45038. */
  45039. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45040. /**
  45041. * Initializes the WebGPU context and dependencies.
  45042. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45043. * @returns a promise notifying the readiness of the engine.
  45044. */
  45045. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45046. private _initGlslang;
  45047. private _initializeLimits;
  45048. private _initializeContextAndSwapChain;
  45049. private _initializeMainAttachments;
  45050. /**
  45051. * Force a specific size of the canvas
  45052. * @param width defines the new canvas' width
  45053. * @param height defines the new canvas' height
  45054. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45055. * @returns true if the size was changed
  45056. */
  45057. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45058. /**
  45059. * Gets a shader processor implementation fitting with the current engine type.
  45060. * @returns The shader processor implementation.
  45061. */
  45062. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45063. /** @hidden */
  45064. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45065. /**
  45066. * Force the entire cache to be cleared
  45067. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45068. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45069. */
  45070. wipeCaches(bruteForce?: boolean): void;
  45071. /**
  45072. * Enable or disable color writing
  45073. * @param enable defines the state to set
  45074. */
  45075. setColorWrite(enable: boolean): void;
  45076. /**
  45077. * Gets a boolean indicating if color writing is enabled
  45078. * @returns the current color writing state
  45079. */
  45080. getColorWrite(): boolean;
  45081. private _viewportsCurrent;
  45082. private _resetCurrentViewport;
  45083. private _applyViewport;
  45084. /** @hidden */
  45085. _viewport(x: number, y: number, width: number, height: number): void;
  45086. private _scissorsCurrent;
  45087. protected _scissorCached: {
  45088. x: number;
  45089. y: number;
  45090. z: number;
  45091. w: number;
  45092. };
  45093. private _resetCurrentScissor;
  45094. private _applyScissor;
  45095. private _scissorIsActive;
  45096. enableScissor(x: number, y: number, width: number, height: number): void;
  45097. disableScissor(): void;
  45098. /**
  45099. * Clear the current render buffer or the current render target (if any is set up)
  45100. * @param color defines the color to use
  45101. * @param backBuffer defines if the back buffer must be cleared
  45102. * @param depth defines if the depth buffer must be cleared
  45103. * @param stencil defines if the stencil buffer must be cleared
  45104. */
  45105. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45106. /**
  45107. * Clears a list of attachments
  45108. * @param attachments list of the attachments
  45109. * @param colorMain clear color for the main attachment (the first one)
  45110. * @param colorOthers clear color for the other attachments
  45111. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45112. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45113. */
  45114. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45115. /**
  45116. * Creates a vertex buffer
  45117. * @param data the data for the vertex buffer
  45118. * @returns the new buffer
  45119. */
  45120. createVertexBuffer(data: DataArray): DataBuffer;
  45121. /**
  45122. * Creates a vertex buffer
  45123. * @param data the data for the dynamic vertex buffer
  45124. * @returns the new buffer
  45125. */
  45126. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45127. /**
  45128. * Updates a vertex buffer.
  45129. * @param vertexBuffer the vertex buffer to update
  45130. * @param data the data used to update the vertex buffer
  45131. * @param byteOffset the byte offset of the data
  45132. * @param byteLength the byte length of the data
  45133. */
  45134. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45135. /**
  45136. * Creates a new index buffer
  45137. * @param indices defines the content of the index buffer
  45138. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45139. * @returns a new buffer
  45140. */
  45141. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45142. /**
  45143. * Update an index buffer
  45144. * @param indexBuffer defines the target index buffer
  45145. * @param indices defines the data to update
  45146. * @param offset defines the offset in the target index buffer where update should start
  45147. */
  45148. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45149. /** @hidden */
  45150. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45151. /** @hidden */
  45152. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45153. /**
  45154. * Bind a list of vertex buffers with the engine
  45155. * @param vertexBuffers defines the list of vertex buffers to bind
  45156. * @param indexBuffer defines the index buffer to bind
  45157. * @param effect defines the effect associated with the vertex buffers
  45158. */
  45159. bindBuffers(vertexBuffers: {
  45160. [key: string]: Nullable<VertexBuffer>;
  45161. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  45162. /** @hidden */
  45163. _releaseBuffer(buffer: DataBuffer): boolean;
  45164. createUniformBuffer(elements: FloatArray): DataBuffer;
  45165. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45166. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45167. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45168. /**
  45169. * Create a new effect (used to store vertex/fragment shaders)
  45170. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45171. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45172. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45173. * @param samplers defines an array of string used to represent textures
  45174. * @param defines defines the string containing the defines to use to compile the shaders
  45175. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  45176. * @param onCompiled defines a function to call when the effect creation is successful
  45177. * @param onError defines a function to call when the effect creation has failed
  45178. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45179. * @returns the new Effect
  45180. */
  45181. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  45182. private _compileRawShaderToSpirV;
  45183. private _compileShaderToSpirV;
  45184. private _createPipelineStageDescriptor;
  45185. private _compileRawPipelineStageDescriptor;
  45186. private _compilePipelineStageDescriptor;
  45187. /** @hidden */
  45188. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45189. /** @hidden */
  45190. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45191. /**
  45192. * Creates a new pipeline context
  45193. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45194. * @returns the new pipeline
  45195. */
  45196. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45197. /** @hidden */
  45198. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45199. /**
  45200. * Gets the list of active attributes for a given WebGPU program
  45201. * @param pipelineContext defines the pipeline context to use
  45202. * @param attributesNames defines the list of attribute names to get
  45203. * @returns an array of indices indicating the offset of each attribute
  45204. */
  45205. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45206. /**
  45207. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45208. * @param effect defines the effect to activate
  45209. */
  45210. enableEffect(effect: Nullable<Effect>): void;
  45211. /** @hidden */
  45212. _releaseEffect(effect: Effect): void;
  45213. /**
  45214. * 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
  45215. */
  45216. releaseEffects(): void;
  45217. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45218. /**
  45219. * Gets a boolean indicating that only power of 2 textures are supported
  45220. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45221. */
  45222. get needPOTTextures(): boolean;
  45223. /** @hidden */
  45224. _createHardwareTexture(): HardwareTextureWrapper;
  45225. /** @hidden */
  45226. _releaseTexture(texture: InternalTexture): void;
  45227. /** @hidden */
  45228. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45229. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45230. /**
  45231. * Usually called from Texture.ts.
  45232. * Passed information to create a hardware texture
  45233. * @param url defines a value which contains one of the following:
  45234. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45235. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45236. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45237. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45238. * @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)
  45239. * @param scene needed for loading to the correct scene
  45240. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45241. * @param onLoad optional callback to be called upon successful completion
  45242. * @param onError optional callback to be called upon failure
  45243. * @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
  45244. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45245. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45246. * @param forcedExtension defines the extension to use to pick the right loader
  45247. * @param mimeType defines an optional mime type
  45248. * @param loaderOptions options to be passed to the loader
  45249. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45250. */
  45251. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  45252. /** @hidden */
  45253. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45254. /**
  45255. * Creates a cube texture
  45256. * @param rootUrl defines the url where the files to load is located
  45257. * @param scene defines the current scene
  45258. * @param files defines the list of files to load (1 per face)
  45259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45260. * @param onLoad defines an optional callback raised when the texture is loaded
  45261. * @param onError defines an optional callback raised if there is an issue to load the texture
  45262. * @param format defines the format of the data
  45263. * @param forcedExtension defines the extension to use to pick the right loader
  45264. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45265. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45266. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45267. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45268. * @param loaderOptions options to be passed to the loader
  45269. * @returns the cube texture as an InternalTexture
  45270. */
  45271. 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;
  45272. /**
  45273. * Creates a raw texture
  45274. * @param data defines the data to store in the texture
  45275. * @param width defines the width of the texture
  45276. * @param height defines the height of the texture
  45277. * @param format defines the format of the data
  45278. * @param generateMipMaps defines if the engine should generate the mip levels
  45279. * @param invertY defines if data must be stored with Y axis inverted
  45280. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45281. * @param compression defines the compression used (null by default)
  45282. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45283. * @returns the raw texture inside an InternalTexture
  45284. */
  45285. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45286. /**
  45287. * Creates a new raw cube texture
  45288. * @param data defines the array of data to use to create each face
  45289. * @param size defines the size of the textures
  45290. * @param format defines the format of the data
  45291. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45292. * @param generateMipMaps defines if the engine should generate the mip levels
  45293. * @param invertY defines if data must be stored with Y axis inverted
  45294. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45295. * @param compression defines the compression used (null by default)
  45296. * @returns the cube texture as an InternalTexture
  45297. */
  45298. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45299. /**
  45300. * Creates a new raw cube texture from a specified url
  45301. * @param url defines the url where the data is located
  45302. * @param scene defines the current scene
  45303. * @param size defines the size of the textures
  45304. * @param format defines the format of the data
  45305. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45306. * @param noMipmap defines if the engine should avoid generating the mip levels
  45307. * @param callback defines a callback used to extract texture data from loaded data
  45308. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45309. * @param onLoad defines a callback called when texture is loaded
  45310. * @param onError defines a callback called if there is an error
  45311. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45312. * @param invertY defines if data must be stored with Y axis inverted
  45313. * @returns the cube texture as an InternalTexture
  45314. */
  45315. 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;
  45316. /**
  45317. * Creates a new raw 2D array texture
  45318. * @param data defines the data used to create the texture
  45319. * @param width defines the width of the texture
  45320. * @param height defines the height of the texture
  45321. * @param depth defines the number of layers of the texture
  45322. * @param format defines the format of the texture
  45323. * @param generateMipMaps defines if the engine must generate mip levels
  45324. * @param invertY defines if data must be stored with Y axis inverted
  45325. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45326. * @param compression defines the compressed used (can be null)
  45327. * @param textureType defines the compressed used (can be null)
  45328. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45329. */
  45330. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45331. /**
  45332. * Creates a new raw 3D texture
  45333. * @param data defines the data used to create the texture
  45334. * @param width defines the width of the texture
  45335. * @param height defines the height of the texture
  45336. * @param depth defines the depth of the texture
  45337. * @param format defines the format of the texture
  45338. * @param generateMipMaps defines if the engine must generate mip levels
  45339. * @param invertY defines if data must be stored with Y axis inverted
  45340. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45341. * @param compression defines the compressed used (can be null)
  45342. * @param textureType defines the compressed used (can be null)
  45343. * @returns a new raw 3D texture (stored in an InternalTexture)
  45344. */
  45345. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45346. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45347. /**
  45348. * Update the sampling mode of a given texture
  45349. * @param samplingMode defines the required sampling mode
  45350. * @param texture defines the texture to update
  45351. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45352. */
  45353. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45354. /**
  45355. * Update the sampling mode of a given texture
  45356. * @param texture defines the texture to update
  45357. * @param wrapU defines the texture wrap mode of the u coordinates
  45358. * @param wrapV defines the texture wrap mode of the v coordinates
  45359. * @param wrapR defines the texture wrap mode of the r coordinates
  45360. */
  45361. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45362. /**
  45363. * Update the dimensions of a texture
  45364. * @param texture texture to update
  45365. * @param width new width of the texture
  45366. * @param height new height of the texture
  45367. * @param depth new depth of the texture
  45368. */
  45369. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45370. private _setInternalTexture;
  45371. /**
  45372. * Sets a texture to the according uniform.
  45373. * @param channel The texture channel
  45374. * @param unused unused parameter
  45375. * @param texture The texture to apply
  45376. * @param name The name of the uniform in the effect
  45377. */
  45378. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45379. /**
  45380. * Sets an array of texture to the WebGPU context
  45381. * @param channel defines the channel where the texture array must be set
  45382. * @param unused unused parameter
  45383. * @param textures defines the array of textures to bind
  45384. * @param name name of the channel
  45385. */
  45386. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45387. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45388. /** @hidden */
  45389. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45390. /** @hidden */
  45391. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45392. private _generateMipmaps;
  45393. /**
  45394. * Update the content of a texture
  45395. * @param texture defines the texture to update
  45396. * @param canvas defines the source containing the data
  45397. * @param invertY defines if data must be stored with Y axis inverted
  45398. * @param premulAlpha defines if alpha is stored as premultiplied
  45399. * @param format defines the format of the data
  45400. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45401. */
  45402. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45403. /**
  45404. * Update a portion of an internal texture
  45405. * @param texture defines the texture to update
  45406. * @param imageData defines the data to store into the texture
  45407. * @param xOffset defines the x coordinates of the update rectangle
  45408. * @param yOffset defines the y coordinates of the update rectangle
  45409. * @param width defines the width of the update rectangle
  45410. * @param height defines the height of the update rectangle
  45411. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45412. * @param lod defines the lod level to update (0 by default)
  45413. */
  45414. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45415. /**
  45416. * Update a video texture
  45417. * @param texture defines the texture to update
  45418. * @param video defines the video element to use
  45419. * @param invertY defines if data must be stored with Y axis inverted
  45420. */
  45421. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45422. /** @hidden */
  45423. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45424. /** @hidden */
  45425. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45426. /** @hidden */
  45427. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45428. /** @hidden */
  45429. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45430. /**
  45431. * Update a raw texture
  45432. * @param texture defines the texture to update
  45433. * @param bufferView defines the data to store in the texture
  45434. * @param format defines the format of the data
  45435. * @param invertY defines if data must be stored with Y axis inverted
  45436. * @param compression defines the compression used (null by default)
  45437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45438. */
  45439. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45440. /**
  45441. * Update a raw cube texture
  45442. * @param texture defines the texture to udpdate
  45443. * @param bufferView defines the data to store
  45444. * @param format defines the data format
  45445. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45446. * @param invertY defines if data must be stored with Y axis inverted
  45447. * @param compression defines the compression used (null by default)
  45448. * @param level defines which level of the texture to update
  45449. */
  45450. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45451. /**
  45452. * Update a raw 2D array texture
  45453. * @param texture defines the texture to update
  45454. * @param bufferView defines the data to store
  45455. * @param format defines the data format
  45456. * @param invertY defines if data must be stored with Y axis inverted
  45457. * @param compression defines the used compression (can be null)
  45458. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45459. */
  45460. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45461. /**
  45462. * Update a raw 3D texture
  45463. * @param texture defines the texture to update
  45464. * @param bufferView defines the data to store
  45465. * @param format defines the data format
  45466. * @param invertY defines if data must be stored with Y axis inverted
  45467. * @param compression defines the used compression (can be null)
  45468. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45469. */
  45470. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45471. /**
  45472. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45473. * @param x defines the x coordinate of the rectangle where pixels must be read
  45474. * @param y defines the y coordinate of the rectangle where pixels must be read
  45475. * @param width defines the width of the rectangle where pixels must be read
  45476. * @param height defines the height of the rectangle where pixels must be read
  45477. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45478. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45479. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45480. */
  45481. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45482. /** @hidden */
  45483. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45484. /**
  45485. * Creates a new render target texture
  45486. * @param size defines the size of the texture
  45487. * @param options defines the options used to create the texture
  45488. * @returns a new render target texture stored in an InternalTexture
  45489. */
  45490. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45491. /**
  45492. * Create a multi render target texture
  45493. * @param size defines the size of the texture
  45494. * @param options defines the creation options
  45495. * @returns the cube texture as an InternalTexture
  45496. */
  45497. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45498. /**
  45499. * Creates a new render target cube texture
  45500. * @param size defines the size of the texture
  45501. * @param options defines the options used to create the texture
  45502. * @returns a new render target cube texture stored in an InternalTexture
  45503. */
  45504. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45505. /** @hidden */
  45506. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45507. width: number;
  45508. height: number;
  45509. layers?: number;
  45510. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45511. /** @hidden */
  45512. _createDepthStencilTexture(size: number | {
  45513. width: number;
  45514. height: number;
  45515. layers?: number;
  45516. }, options: DepthTextureCreationOptions): InternalTexture;
  45517. /** @hidden */
  45518. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45519. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45520. /**
  45521. * Update the sample count for a given multiple render target texture
  45522. * @param textures defines the textures to update
  45523. * @param samples defines the sample count to set
  45524. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45525. */
  45526. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45527. /**
  45528. * Begin a new frame
  45529. */
  45530. beginFrame(): void;
  45531. /**
  45532. * End the current frame
  45533. */
  45534. endFrame(): void;
  45535. /**
  45536. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45537. */
  45538. flushFramebuffer(): void;
  45539. private _startRenderTargetRenderPass;
  45540. private _endRenderTargetRenderPass;
  45541. private _getCurrentRenderPass;
  45542. private _startMainRenderPass;
  45543. private _endMainRenderPass;
  45544. /**
  45545. * Restores the WebGPU state to only draw on the main color attachment
  45546. */
  45547. restoreSingleAttachment(): void;
  45548. /**
  45549. * Creates a layout object to draw/clear on specific textures in a MRT
  45550. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45551. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45552. */
  45553. buildTextureLayout(textureStatus: boolean[]): number[];
  45554. /**
  45555. * Select a subsets of attachments to draw to.
  45556. * @param attachments index of attachments
  45557. */
  45558. bindAttachments(attachments: number[]): void;
  45559. /**
  45560. * Binds the frame buffer to the specified texture.
  45561. * @param texture The texture to render to or null for the default canvas
  45562. * @param faceIndex The face of the texture to render to in case of cube texture
  45563. * @param requiredWidth The width of the target to render to
  45564. * @param requiredHeight The height of the target to render to
  45565. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45566. * @param lodLevel defines the lod level to bind to the frame buffer
  45567. * @param layer defines the 2d array index to bind to frame buffer to
  45568. */
  45569. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45570. /**
  45571. * Unbind the current render target texture from the WebGPU context
  45572. * @param texture defines the render target texture to unbind
  45573. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45574. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45575. */
  45576. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45577. /**
  45578. * Unbind a list of render target textures from the WebGPU context
  45579. * @param textures defines the render target textures to unbind
  45580. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45581. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45582. */
  45583. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45584. /**
  45585. * Unbind the current render target and bind the default framebuffer
  45586. */
  45587. restoreDefaultFramebuffer(): void;
  45588. setZOffset(value: number): void;
  45589. private _setColorFormat;
  45590. private _setDepthTextureFormat;
  45591. setDepthBuffer(enable: boolean): void;
  45592. setDepthWrite(enable: boolean): void;
  45593. setStencilBuffer(enable: boolean): void;
  45594. setStencilMask(mask: number): void;
  45595. setStencilFunction(stencilFunc: number): void;
  45596. setStencilFunctionReference(reference: number): void;
  45597. setStencilFunctionMask(mask: number): void;
  45598. setStencilOperationFail(operation: number): void;
  45599. setStencilOperationDepthFail(operation: number): void;
  45600. setStencilOperationPass(operation: number): void;
  45601. setDitheringState(value: boolean): void;
  45602. setRasterizerState(value: boolean): void;
  45603. setDepthFunction(depthFunc: number): void;
  45604. setDepthFunctionToGreater(): void;
  45605. setDepthFunctionToGreaterOrEqual(): void;
  45606. setDepthFunctionToLess(): void;
  45607. setDepthFunctionToLessOrEqual(): void;
  45608. /**
  45609. * Set various states to the context
  45610. * @param culling defines backface culling state
  45611. * @param zOffset defines the value to apply to zOffset (0 by default)
  45612. * @param force defines if states must be applied even if cache is up to date
  45613. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45614. */
  45615. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45616. /**
  45617. * Sets the current alpha mode
  45618. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45619. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45620. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45621. */
  45622. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45623. /**
  45624. * Sets the current alpha equation
  45625. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  45626. */
  45627. setAlphaEquation(equation: number): void;
  45628. private _getBindGroupsToRender;
  45629. private _bindVertexInputs;
  45630. private _setRenderBindGroups;
  45631. private _setRenderPipeline;
  45632. /**
  45633. * Draw a list of indexed primitives
  45634. * @param fillMode defines the primitive to use
  45635. * @param indexStart defines the starting index
  45636. * @param indexCount defines the number of index to draw
  45637. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45638. */
  45639. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45640. /**
  45641. * Draw a list of unindexed primitives
  45642. * @param fillMode defines the primitive to use
  45643. * @param verticesStart defines the index of first vertex to draw
  45644. * @param verticesCount defines the count of vertices to draw
  45645. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45646. */
  45647. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45648. private _bundleEncoder;
  45649. /**
  45650. * Start recording all the gpu calls into a bundle.
  45651. */
  45652. startRecordBundle(): void;
  45653. /**
  45654. * Stops recording the bundle.
  45655. * @returns the recorded bundle
  45656. */
  45657. stopRecordBundle(): GPURenderBundle;
  45658. /**
  45659. * Execute the previously recorded bundle.
  45660. * @param bundles defines the bundle to replay
  45661. */
  45662. executeBundles(bundles: GPURenderBundle[]): void;
  45663. /**
  45664. * Dispose and release all associated resources
  45665. */
  45666. dispose(): void;
  45667. /**
  45668. * Gets the current render width
  45669. * @param useScreen defines if screen size must be used (or the current render target if any)
  45670. * @returns a number defining the current render width
  45671. */
  45672. getRenderWidth(useScreen?: boolean): number;
  45673. /**
  45674. * Gets the current render height
  45675. * @param useScreen defines if screen size must be used (or the current render target if any)
  45676. * @returns a number defining the current render height
  45677. */
  45678. getRenderHeight(useScreen?: boolean): number;
  45679. /**
  45680. * Gets the HTML canvas attached with the current WebGPU context
  45681. * @returns a HTML canvas
  45682. */
  45683. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45684. /** @hidden */
  45685. _debugPushGroup(groupName: string, targetObject?: number): void;
  45686. /** @hidden */
  45687. _debugPopGroup(targetObject?: number): void;
  45688. /** @hidden */
  45689. _debugInsertMarker(text: string, targetObject?: number): void;
  45690. private _debugFlushPendingCommands;
  45691. /**
  45692. * Get the current error code of the WebGPU context
  45693. * @returns the error code
  45694. */
  45695. getError(): number;
  45696. /** @hidden */
  45697. bindSamplers(effect: Effect): void;
  45698. /** @hidden */
  45699. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45700. /** @hidden */
  45701. _releaseFramebufferObjects(texture: InternalTexture): void;
  45702. /** @hidden */
  45703. applyStates(): void;
  45704. /**
  45705. * Gets a boolean indicating if all created effects are ready
  45706. * @returns always true - No parallel shader compilation
  45707. */
  45708. areAllEffectsReady(): boolean;
  45709. /** @hidden */
  45710. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45711. /** @hidden */
  45712. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45713. /** @hidden */
  45714. _getUnpackAlignement(): number;
  45715. /** @hidden */
  45716. _unpackFlipY(value: boolean): void;
  45717. /** @hidden */
  45718. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45719. min: number;
  45720. mag: number;
  45721. };
  45722. /** @hidden */
  45723. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45724. /** @hidden */
  45725. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45726. /** @hidden */
  45727. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45728. /** @hidden */
  45729. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45730. /** @hidden */
  45731. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45732. /** @hidden */
  45733. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45734. /** @hidden */
  45735. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45736. /** @hidden */
  45737. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45738. /** @hidden */
  45739. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45740. /** @hidden */
  45741. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45742. /** @hidden */
  45743. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45744. /** @hidden */
  45745. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45746. /** @hidden */
  45747. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45748. /** @hidden */
  45749. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45750. /** @hidden */
  45751. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45752. /** @hidden */
  45753. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45754. /** @hidden */
  45755. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45756. }
  45757. }
  45758. declare module BABYLON {
  45759. /**
  45760. * Define an interface for all classes that will hold resources
  45761. */
  45762. export interface IDisposable {
  45763. /**
  45764. * Releases all held resources
  45765. */
  45766. dispose(): void;
  45767. }
  45768. /** Interface defining initialization parameters for Scene class */
  45769. export interface SceneOptions {
  45770. /**
  45771. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45772. * It will improve performance when the number of geometries becomes important.
  45773. */
  45774. useGeometryUniqueIdsMap?: boolean;
  45775. /**
  45776. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45777. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45778. */
  45779. useMaterialMeshMap?: boolean;
  45780. /**
  45781. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45782. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45783. */
  45784. useClonedMeshMap?: boolean;
  45785. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45786. virtual?: boolean;
  45787. }
  45788. /**
  45789. * Represents a scene to be rendered by the engine.
  45790. * @see https://doc.babylonjs.com/features/scene
  45791. */
  45792. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45793. /** The fog is deactivated */
  45794. static readonly FOGMODE_NONE: number;
  45795. /** The fog density is following an exponential function */
  45796. static readonly FOGMODE_EXP: number;
  45797. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45798. static readonly FOGMODE_EXP2: number;
  45799. /** The fog density is following a linear function. */
  45800. static readonly FOGMODE_LINEAR: number;
  45801. /**
  45802. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45803. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45804. */
  45805. static MinDeltaTime: number;
  45806. /**
  45807. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45808. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45809. */
  45810. static MaxDeltaTime: number;
  45811. /**
  45812. * Factory used to create the default material.
  45813. * @param name The name of the material to create
  45814. * @param scene The scene to create the material for
  45815. * @returns The default material
  45816. */
  45817. static DefaultMaterialFactory(scene: Scene): Material;
  45818. /**
  45819. * Factory used to create the a collision coordinator.
  45820. * @returns The collision coordinator
  45821. */
  45822. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45823. /** @hidden */
  45824. _inputManager: InputManager;
  45825. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45826. cameraToUseForPointers: Nullable<Camera>;
  45827. /** @hidden */
  45828. readonly _isScene: boolean;
  45829. /** @hidden */
  45830. _blockEntityCollection: boolean;
  45831. /**
  45832. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45833. */
  45834. autoClear: boolean;
  45835. /**
  45836. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45837. */
  45838. autoClearDepthAndStencil: boolean;
  45839. /**
  45840. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45841. */
  45842. clearColor: Color4;
  45843. /**
  45844. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45845. */
  45846. ambientColor: Color3;
  45847. /**
  45848. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45849. * It should only be one of the following (if not the default embedded one):
  45850. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45851. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45852. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45853. * The material properties need to be setup according to the type of texture in use.
  45854. */
  45855. environmentBRDFTexture: BaseTexture;
  45856. /**
  45857. * Texture used in all pbr material as the reflection texture.
  45858. * As in the majority of the scene they are the same (exception for multi room and so on),
  45859. * this is easier to reference from here than from all the materials.
  45860. */
  45861. get environmentTexture(): Nullable<BaseTexture>;
  45862. /**
  45863. * Texture used in all pbr material as the reflection texture.
  45864. * As in the majority of the scene they are the same (exception for multi room and so on),
  45865. * this is easier to set here than in all the materials.
  45866. */
  45867. set environmentTexture(value: Nullable<BaseTexture>);
  45868. /** @hidden */
  45869. protected _environmentIntensity: number;
  45870. /**
  45871. * Intensity of the environment in all pbr material.
  45872. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45873. * As in the majority of the scene they are the same (exception for multi room and so on),
  45874. * this is easier to reference from here than from all the materials.
  45875. */
  45876. get environmentIntensity(): number;
  45877. /**
  45878. * Intensity of the environment in all pbr material.
  45879. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45880. * As in the majority of the scene they are the same (exception for multi room and so on),
  45881. * this is easier to set here than in all the materials.
  45882. */
  45883. set environmentIntensity(value: number);
  45884. /** @hidden */
  45885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45886. /**
  45887. * Default image processing configuration used either in the rendering
  45888. * Forward main pass or through the imageProcessingPostProcess if present.
  45889. * As in the majority of the scene they are the same (exception for multi camera),
  45890. * this is easier to reference from here than from all the materials and post process.
  45891. *
  45892. * No setter as we it is a shared configuration, you can set the values instead.
  45893. */
  45894. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45895. private _forceWireframe;
  45896. /**
  45897. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45898. */
  45899. set forceWireframe(value: boolean);
  45900. get forceWireframe(): boolean;
  45901. private _skipFrustumClipping;
  45902. /**
  45903. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45904. */
  45905. set skipFrustumClipping(value: boolean);
  45906. get skipFrustumClipping(): boolean;
  45907. private _forcePointsCloud;
  45908. /**
  45909. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45910. */
  45911. set forcePointsCloud(value: boolean);
  45912. get forcePointsCloud(): boolean;
  45913. /**
  45914. * Gets or sets the active clipplane 1
  45915. */
  45916. clipPlane: Nullable<Plane>;
  45917. /**
  45918. * Gets or sets the active clipplane 2
  45919. */
  45920. clipPlane2: Nullable<Plane>;
  45921. /**
  45922. * Gets or sets the active clipplane 3
  45923. */
  45924. clipPlane3: Nullable<Plane>;
  45925. /**
  45926. * Gets or sets the active clipplane 4
  45927. */
  45928. clipPlane4: Nullable<Plane>;
  45929. /**
  45930. * Gets or sets the active clipplane 5
  45931. */
  45932. clipPlane5: Nullable<Plane>;
  45933. /**
  45934. * Gets or sets the active clipplane 6
  45935. */
  45936. clipPlane6: Nullable<Plane>;
  45937. /**
  45938. * Gets or sets a boolean indicating if animations are enabled
  45939. */
  45940. animationsEnabled: boolean;
  45941. private _animationPropertiesOverride;
  45942. /**
  45943. * Gets or sets the animation properties override
  45944. */
  45945. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  45946. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  45947. /**
  45948. * Gets or sets a boolean indicating if a constant deltatime has to be used
  45949. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  45950. */
  45951. useConstantAnimationDeltaTime: boolean;
  45952. /**
  45953. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  45954. * Please note that it requires to run a ray cast through the scene on every frame
  45955. */
  45956. constantlyUpdateMeshUnderPointer: boolean;
  45957. /**
  45958. * Defines the HTML cursor to use when hovering over interactive elements
  45959. */
  45960. hoverCursor: string;
  45961. /**
  45962. * Defines the HTML default cursor to use (empty by default)
  45963. */
  45964. defaultCursor: string;
  45965. /**
  45966. * Defines whether cursors are handled by the scene.
  45967. */
  45968. doNotHandleCursors: boolean;
  45969. /**
  45970. * This is used to call preventDefault() on pointer down
  45971. * in order to block unwanted artifacts like system double clicks
  45972. */
  45973. preventDefaultOnPointerDown: boolean;
  45974. /**
  45975. * This is used to call preventDefault() on pointer up
  45976. * in order to block unwanted artifacts like system double clicks
  45977. */
  45978. preventDefaultOnPointerUp: boolean;
  45979. /**
  45980. * Gets or sets user defined metadata
  45981. */
  45982. metadata: any;
  45983. /**
  45984. * For internal use only. Please do not use.
  45985. */
  45986. reservedDataStore: any;
  45987. /**
  45988. * Gets the name of the plugin used to load this scene (null by default)
  45989. */
  45990. loadingPluginName: string;
  45991. /**
  45992. * Use this array to add regular expressions used to disable offline support for specific urls
  45993. */
  45994. disableOfflineSupportExceptionRules: RegExp[];
  45995. /**
  45996. * An event triggered when the scene is disposed.
  45997. */
  45998. onDisposeObservable: Observable<Scene>;
  45999. private _onDisposeObserver;
  46000. /** Sets a function to be executed when this scene is disposed. */
  46001. set onDispose(callback: () => void);
  46002. /**
  46003. * An event triggered before rendering the scene (right after animations and physics)
  46004. */
  46005. onBeforeRenderObservable: Observable<Scene>;
  46006. private _onBeforeRenderObserver;
  46007. /** Sets a function to be executed before rendering this scene */
  46008. set beforeRender(callback: Nullable<() => void>);
  46009. /**
  46010. * An event triggered after rendering the scene
  46011. */
  46012. onAfterRenderObservable: Observable<Scene>;
  46013. /**
  46014. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46015. */
  46016. onAfterRenderCameraObservable: Observable<Camera>;
  46017. private _onAfterRenderObserver;
  46018. /** Sets a function to be executed after rendering this scene */
  46019. set afterRender(callback: Nullable<() => void>);
  46020. /**
  46021. * An event triggered before animating the scene
  46022. */
  46023. onBeforeAnimationsObservable: Observable<Scene>;
  46024. /**
  46025. * An event triggered after animations processing
  46026. */
  46027. onAfterAnimationsObservable: Observable<Scene>;
  46028. /**
  46029. * An event triggered before draw calls are ready to be sent
  46030. */
  46031. onBeforeDrawPhaseObservable: Observable<Scene>;
  46032. /**
  46033. * An event triggered after draw calls have been sent
  46034. */
  46035. onAfterDrawPhaseObservable: Observable<Scene>;
  46036. /**
  46037. * An event triggered when the scene is ready
  46038. */
  46039. onReadyObservable: Observable<Scene>;
  46040. /**
  46041. * An event triggered before rendering a camera
  46042. */
  46043. onBeforeCameraRenderObservable: Observable<Camera>;
  46044. private _onBeforeCameraRenderObserver;
  46045. /** Sets a function to be executed before rendering a camera*/
  46046. set beforeCameraRender(callback: () => void);
  46047. /**
  46048. * An event triggered after rendering a camera
  46049. */
  46050. onAfterCameraRenderObservable: Observable<Camera>;
  46051. private _onAfterCameraRenderObserver;
  46052. /** Sets a function to be executed after rendering a camera*/
  46053. set afterCameraRender(callback: () => void);
  46054. /**
  46055. * An event triggered when active meshes evaluation is about to start
  46056. */
  46057. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46058. /**
  46059. * An event triggered when active meshes evaluation is done
  46060. */
  46061. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46062. /**
  46063. * An event triggered when particles rendering is about to start
  46064. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46065. */
  46066. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46067. /**
  46068. * An event triggered when particles rendering is done
  46069. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46070. */
  46071. onAfterParticlesRenderingObservable: Observable<Scene>;
  46072. /**
  46073. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46074. */
  46075. onDataLoadedObservable: Observable<Scene>;
  46076. /**
  46077. * An event triggered when a camera is created
  46078. */
  46079. onNewCameraAddedObservable: Observable<Camera>;
  46080. /**
  46081. * An event triggered when a camera is removed
  46082. */
  46083. onCameraRemovedObservable: Observable<Camera>;
  46084. /**
  46085. * An event triggered when a light is created
  46086. */
  46087. onNewLightAddedObservable: Observable<Light>;
  46088. /**
  46089. * An event triggered when a light is removed
  46090. */
  46091. onLightRemovedObservable: Observable<Light>;
  46092. /**
  46093. * An event triggered when a geometry is created
  46094. */
  46095. onNewGeometryAddedObservable: Observable<Geometry>;
  46096. /**
  46097. * An event triggered when a geometry is removed
  46098. */
  46099. onGeometryRemovedObservable: Observable<Geometry>;
  46100. /**
  46101. * An event triggered when a transform node is created
  46102. */
  46103. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46104. /**
  46105. * An event triggered when a transform node is removed
  46106. */
  46107. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46108. /**
  46109. * An event triggered when a mesh is created
  46110. */
  46111. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46112. /**
  46113. * An event triggered when a mesh is removed
  46114. */
  46115. onMeshRemovedObservable: Observable<AbstractMesh>;
  46116. /**
  46117. * An event triggered when a skeleton is created
  46118. */
  46119. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46120. /**
  46121. * An event triggered when a skeleton is removed
  46122. */
  46123. onSkeletonRemovedObservable: Observable<Skeleton>;
  46124. /**
  46125. * An event triggered when a material is created
  46126. */
  46127. onNewMaterialAddedObservable: Observable<Material>;
  46128. /**
  46129. * An event triggered when a multi material is created
  46130. */
  46131. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46132. /**
  46133. * An event triggered when a material is removed
  46134. */
  46135. onMaterialRemovedObservable: Observable<Material>;
  46136. /**
  46137. * An event triggered when a multi material is removed
  46138. */
  46139. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46140. /**
  46141. * An event triggered when a texture is created
  46142. */
  46143. onNewTextureAddedObservable: Observable<BaseTexture>;
  46144. /**
  46145. * An event triggered when a texture is removed
  46146. */
  46147. onTextureRemovedObservable: Observable<BaseTexture>;
  46148. /**
  46149. * An event triggered when render targets are about to be rendered
  46150. * Can happen multiple times per frame.
  46151. */
  46152. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46153. /**
  46154. * An event triggered when render targets were rendered.
  46155. * Can happen multiple times per frame.
  46156. */
  46157. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46158. /**
  46159. * An event triggered before calculating deterministic simulation step
  46160. */
  46161. onBeforeStepObservable: Observable<Scene>;
  46162. /**
  46163. * An event triggered after calculating deterministic simulation step
  46164. */
  46165. onAfterStepObservable: Observable<Scene>;
  46166. /**
  46167. * An event triggered when the activeCamera property is updated
  46168. */
  46169. onActiveCameraChanged: Observable<Scene>;
  46170. /**
  46171. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46172. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46173. * 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)
  46174. */
  46175. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46176. /**
  46177. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46178. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46179. * 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)
  46180. */
  46181. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46182. /**
  46183. * This Observable will when a mesh has been imported into the scene.
  46184. */
  46185. onMeshImportedObservable: Observable<AbstractMesh>;
  46186. /**
  46187. * This Observable will when an animation file has been imported into the scene.
  46188. */
  46189. onAnimationFileImportedObservable: Observable<Scene>;
  46190. /**
  46191. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46192. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46193. */
  46194. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46195. /** @hidden */
  46196. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46197. /**
  46198. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46199. */
  46200. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46201. /**
  46202. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46203. */
  46204. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46205. /**
  46206. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46207. */
  46208. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46209. /** Callback called when a pointer move is detected */
  46210. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46211. /** Callback called when a pointer down is detected */
  46212. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46213. /** Callback called when a pointer up is detected */
  46214. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46215. /** Callback called when a pointer pick is detected */
  46216. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46217. /**
  46218. * 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).
  46219. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46220. */
  46221. onPrePointerObservable: Observable<PointerInfoPre>;
  46222. /**
  46223. * Observable event triggered each time an input event is received from the rendering canvas
  46224. */
  46225. onPointerObservable: Observable<PointerInfo>;
  46226. /**
  46227. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46228. */
  46229. get unTranslatedPointer(): Vector2;
  46230. /**
  46231. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46232. */
  46233. static get DragMovementThreshold(): number;
  46234. static set DragMovementThreshold(value: number);
  46235. /**
  46236. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46237. */
  46238. static get LongPressDelay(): number;
  46239. static set LongPressDelay(value: number);
  46240. /**
  46241. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46242. */
  46243. static get DoubleClickDelay(): number;
  46244. static set DoubleClickDelay(value: number);
  46245. /** If you need to check double click without raising a single click at first click, enable this flag */
  46246. static get ExclusiveDoubleClickMode(): boolean;
  46247. static set ExclusiveDoubleClickMode(value: boolean);
  46248. /** @hidden */
  46249. _mirroredCameraPosition: Nullable<Vector3>;
  46250. /**
  46251. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46252. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46253. */
  46254. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46255. /**
  46256. * Observable event triggered each time an keyboard event is received from the hosting window
  46257. */
  46258. onKeyboardObservable: Observable<KeyboardInfo>;
  46259. private _useRightHandedSystem;
  46260. /**
  46261. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46262. */
  46263. set useRightHandedSystem(value: boolean);
  46264. get useRightHandedSystem(): boolean;
  46265. private _timeAccumulator;
  46266. private _currentStepId;
  46267. private _currentInternalStep;
  46268. /**
  46269. * Sets the step Id used by deterministic lock step
  46270. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46271. * @param newStepId defines the step Id
  46272. */
  46273. setStepId(newStepId: number): void;
  46274. /**
  46275. * Gets the step Id used by deterministic lock step
  46276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46277. * @returns the step Id
  46278. */
  46279. getStepId(): number;
  46280. /**
  46281. * Gets the internal step used by deterministic lock step
  46282. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46283. * @returns the internal step
  46284. */
  46285. getInternalStep(): number;
  46286. private _fogEnabled;
  46287. /**
  46288. * Gets or sets a boolean indicating if fog is enabled on this scene
  46289. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46290. * (Default is true)
  46291. */
  46292. set fogEnabled(value: boolean);
  46293. get fogEnabled(): boolean;
  46294. private _fogMode;
  46295. /**
  46296. * Gets or sets the fog mode to use
  46297. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46298. * | mode | value |
  46299. * | --- | --- |
  46300. * | FOGMODE_NONE | 0 |
  46301. * | FOGMODE_EXP | 1 |
  46302. * | FOGMODE_EXP2 | 2 |
  46303. * | FOGMODE_LINEAR | 3 |
  46304. */
  46305. set fogMode(value: number);
  46306. get fogMode(): number;
  46307. /**
  46308. * Gets or sets the fog color to use
  46309. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46310. * (Default is Color3(0.2, 0.2, 0.3))
  46311. */
  46312. fogColor: Color3;
  46313. /**
  46314. * Gets or sets the fog density to use
  46315. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46316. * (Default is 0.1)
  46317. */
  46318. fogDensity: number;
  46319. /**
  46320. * Gets or sets the fog start distance to use
  46321. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46322. * (Default is 0)
  46323. */
  46324. fogStart: number;
  46325. /**
  46326. * Gets or sets the fog end distance to use
  46327. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46328. * (Default is 1000)
  46329. */
  46330. fogEnd: number;
  46331. /**
  46332. * Flag indicating that the frame buffer binding is handled by another component
  46333. */
  46334. prePass: boolean;
  46335. private _shadowsEnabled;
  46336. /**
  46337. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46338. */
  46339. set shadowsEnabled(value: boolean);
  46340. get shadowsEnabled(): boolean;
  46341. private _lightsEnabled;
  46342. /**
  46343. * Gets or sets a boolean indicating if lights are enabled on this scene
  46344. */
  46345. set lightsEnabled(value: boolean);
  46346. get lightsEnabled(): boolean;
  46347. /** All of the active cameras added to this scene. */
  46348. activeCameras: Nullable<Camera[]>;
  46349. /** @hidden */
  46350. _activeCamera: Nullable<Camera>;
  46351. /** Gets or sets the current active camera */
  46352. get activeCamera(): Nullable<Camera>;
  46353. set activeCamera(value: Nullable<Camera>);
  46354. private _defaultMaterial;
  46355. /** The default material used on meshes when no material is affected */
  46356. get defaultMaterial(): Material;
  46357. /** The default material used on meshes when no material is affected */
  46358. set defaultMaterial(value: Material);
  46359. private _texturesEnabled;
  46360. /**
  46361. * Gets or sets a boolean indicating if textures are enabled on this scene
  46362. */
  46363. set texturesEnabled(value: boolean);
  46364. get texturesEnabled(): boolean;
  46365. /**
  46366. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46367. */
  46368. physicsEnabled: boolean;
  46369. /**
  46370. * Gets or sets a boolean indicating if particles are enabled on this scene
  46371. */
  46372. particlesEnabled: boolean;
  46373. /**
  46374. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46375. */
  46376. spritesEnabled: boolean;
  46377. private _skeletonsEnabled;
  46378. /**
  46379. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46380. */
  46381. set skeletonsEnabled(value: boolean);
  46382. get skeletonsEnabled(): boolean;
  46383. /**
  46384. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46385. */
  46386. lensFlaresEnabled: boolean;
  46387. /**
  46388. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46389. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46390. */
  46391. collisionsEnabled: boolean;
  46392. private _collisionCoordinator;
  46393. /** @hidden */
  46394. get collisionCoordinator(): ICollisionCoordinator;
  46395. /**
  46396. * Defines the gravity applied to this scene (used only for collisions)
  46397. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46398. */
  46399. gravity: Vector3;
  46400. /**
  46401. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46402. */
  46403. postProcessesEnabled: boolean;
  46404. /**
  46405. * Gets the current postprocess manager
  46406. */
  46407. postProcessManager: PostProcessManager;
  46408. /**
  46409. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46410. */
  46411. renderTargetsEnabled: boolean;
  46412. /**
  46413. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46414. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46415. */
  46416. dumpNextRenderTargets: boolean;
  46417. /**
  46418. * The list of user defined render targets added to the scene
  46419. */
  46420. customRenderTargets: RenderTargetTexture[];
  46421. /**
  46422. * Defines if texture loading must be delayed
  46423. * If true, textures will only be loaded when they need to be rendered
  46424. */
  46425. useDelayedTextureLoading: boolean;
  46426. /**
  46427. * Gets the list of meshes imported to the scene through SceneLoader
  46428. */
  46429. importedMeshesFiles: String[];
  46430. /**
  46431. * Gets or sets a boolean indicating if probes are enabled on this scene
  46432. */
  46433. probesEnabled: boolean;
  46434. /**
  46435. * Gets or sets the current offline provider to use to store scene data
  46436. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46437. */
  46438. offlineProvider: IOfflineProvider;
  46439. /**
  46440. * Gets or sets the action manager associated with the scene
  46441. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46442. */
  46443. actionManager: AbstractActionManager;
  46444. private _meshesForIntersections;
  46445. /**
  46446. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46447. */
  46448. proceduralTexturesEnabled: boolean;
  46449. private _engine;
  46450. private _totalVertices;
  46451. /** @hidden */
  46452. _activeIndices: PerfCounter;
  46453. /** @hidden */
  46454. _activeParticles: PerfCounter;
  46455. /** @hidden */
  46456. _activeBones: PerfCounter;
  46457. private _animationRatio;
  46458. /** @hidden */
  46459. _animationTimeLast: number;
  46460. /** @hidden */
  46461. _animationTime: number;
  46462. /**
  46463. * Gets or sets a general scale for animation speed
  46464. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46465. */
  46466. animationTimeScale: number;
  46467. /** @hidden */
  46468. _cachedMaterial: Nullable<Material>;
  46469. /** @hidden */
  46470. _cachedEffect: Nullable<Effect>;
  46471. /** @hidden */
  46472. _cachedVisibility: Nullable<number>;
  46473. private _renderId;
  46474. private _frameId;
  46475. private _executeWhenReadyTimeoutId;
  46476. private _intermediateRendering;
  46477. private _viewUpdateFlag;
  46478. private _projectionUpdateFlag;
  46479. /** @hidden */
  46480. _toBeDisposed: Nullable<IDisposable>[];
  46481. private _activeRequests;
  46482. /** @hidden */
  46483. _pendingData: any[];
  46484. private _isDisposed;
  46485. /**
  46486. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46487. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46488. */
  46489. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46490. private _activeMeshes;
  46491. private _processedMaterials;
  46492. private _renderTargets;
  46493. /** @hidden */
  46494. _activeParticleSystems: SmartArray<IParticleSystem>;
  46495. private _activeSkeletons;
  46496. private _softwareSkinnedMeshes;
  46497. private _renderingManager;
  46498. /** @hidden */
  46499. _activeAnimatables: Animatable[];
  46500. private _transformMatrix;
  46501. private _sceneUbo;
  46502. /** @hidden */
  46503. _viewMatrix: Matrix;
  46504. /** @hidden */
  46505. _projectionMatrix: Matrix;
  46506. /** @hidden */
  46507. _forcedViewPosition: Nullable<Vector3>;
  46508. /** @hidden */
  46509. _frustumPlanes: Plane[];
  46510. /**
  46511. * Gets the list of frustum planes (built from the active camera)
  46512. */
  46513. get frustumPlanes(): Plane[];
  46514. /**
  46515. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46516. * This is useful if there are more lights that the maximum simulteanous authorized
  46517. */
  46518. requireLightSorting: boolean;
  46519. /** @hidden */
  46520. readonly useMaterialMeshMap: boolean;
  46521. /** @hidden */
  46522. readonly useClonedMeshMap: boolean;
  46523. private _externalData;
  46524. private _uid;
  46525. /**
  46526. * @hidden
  46527. * Backing store of defined scene components.
  46528. */
  46529. _components: ISceneComponent[];
  46530. /**
  46531. * @hidden
  46532. * Backing store of defined scene components.
  46533. */
  46534. _serializableComponents: ISceneSerializableComponent[];
  46535. /**
  46536. * List of components to register on the next registration step.
  46537. */
  46538. private _transientComponents;
  46539. /**
  46540. * Registers the transient components if needed.
  46541. */
  46542. private _registerTransientComponents;
  46543. /**
  46544. * @hidden
  46545. * Add a component to the scene.
  46546. * Note that the ccomponent could be registered on th next frame if this is called after
  46547. * the register component stage.
  46548. * @param component Defines the component to add to the scene
  46549. */
  46550. _addComponent(component: ISceneComponent): void;
  46551. /**
  46552. * @hidden
  46553. * Gets a component from the scene.
  46554. * @param name defines the name of the component to retrieve
  46555. * @returns the component or null if not present
  46556. */
  46557. _getComponent(name: string): Nullable<ISceneComponent>;
  46558. /**
  46559. * @hidden
  46560. * Defines the actions happening before camera updates.
  46561. */
  46562. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46563. /**
  46564. * @hidden
  46565. * Defines the actions happening before clear the canvas.
  46566. */
  46567. _beforeClearStage: Stage<SimpleStageAction>;
  46568. /**
  46569. * @hidden
  46570. * Defines the actions when collecting render targets for the frame.
  46571. */
  46572. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46573. /**
  46574. * @hidden
  46575. * Defines the actions happening for one camera in the frame.
  46576. */
  46577. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46578. /**
  46579. * @hidden
  46580. * Defines the actions happening during the per mesh ready checks.
  46581. */
  46582. _isReadyForMeshStage: Stage<MeshStageAction>;
  46583. /**
  46584. * @hidden
  46585. * Defines the actions happening before evaluate active mesh checks.
  46586. */
  46587. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46588. /**
  46589. * @hidden
  46590. * Defines the actions happening during the evaluate sub mesh checks.
  46591. */
  46592. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46593. /**
  46594. * @hidden
  46595. * Defines the actions happening during the active mesh stage.
  46596. */
  46597. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46598. /**
  46599. * @hidden
  46600. * Defines the actions happening during the per camera render target step.
  46601. */
  46602. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46603. /**
  46604. * @hidden
  46605. * Defines the actions happening just before the active camera is drawing.
  46606. */
  46607. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46608. /**
  46609. * @hidden
  46610. * Defines the actions happening just before a render target is drawing.
  46611. */
  46612. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46613. /**
  46614. * @hidden
  46615. * Defines the actions happening just before a rendering group is drawing.
  46616. */
  46617. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46618. /**
  46619. * @hidden
  46620. * Defines the actions happening just before a mesh is drawing.
  46621. */
  46622. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46623. /**
  46624. * @hidden
  46625. * Defines the actions happening just after a mesh has been drawn.
  46626. */
  46627. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46628. /**
  46629. * @hidden
  46630. * Defines the actions happening just after a rendering group has been drawn.
  46631. */
  46632. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46633. /**
  46634. * @hidden
  46635. * Defines the actions happening just after the active camera has been drawn.
  46636. */
  46637. _afterCameraDrawStage: Stage<CameraStageAction>;
  46638. /**
  46639. * @hidden
  46640. * Defines the actions happening just after a render target has been drawn.
  46641. */
  46642. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46643. /**
  46644. * @hidden
  46645. * Defines the actions happening just after rendering all cameras and computing intersections.
  46646. */
  46647. _afterRenderStage: Stage<SimpleStageAction>;
  46648. /**
  46649. * @hidden
  46650. * Defines the actions happening when a pointer move event happens.
  46651. */
  46652. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46653. /**
  46654. * @hidden
  46655. * Defines the actions happening when a pointer down event happens.
  46656. */
  46657. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46658. /**
  46659. * @hidden
  46660. * Defines the actions happening when a pointer up event happens.
  46661. */
  46662. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46663. /**
  46664. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46665. */
  46666. private geometriesByUniqueId;
  46667. private _renderBundles;
  46668. /**
  46669. * Creates a new Scene
  46670. * @param engine defines the engine to use to render this scene
  46671. * @param options defines the scene options
  46672. */
  46673. constructor(engine: Engine, options?: SceneOptions);
  46674. /**
  46675. * Gets a string identifying the name of the class
  46676. * @returns "Scene" string
  46677. */
  46678. getClassName(): string;
  46679. private _defaultMeshCandidates;
  46680. /**
  46681. * @hidden
  46682. */
  46683. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46684. private _defaultSubMeshCandidates;
  46685. /**
  46686. * @hidden
  46687. */
  46688. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46689. /**
  46690. * Sets the default candidate providers for the scene.
  46691. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46692. * and getCollidingSubMeshCandidates to their default function
  46693. */
  46694. setDefaultCandidateProviders(): void;
  46695. /**
  46696. * Gets the mesh that is currently under the pointer
  46697. */
  46698. get meshUnderPointer(): Nullable<AbstractMesh>;
  46699. /**
  46700. * Gets or sets the current on-screen X position of the pointer
  46701. */
  46702. get pointerX(): number;
  46703. set pointerX(value: number);
  46704. /**
  46705. * Gets or sets the current on-screen Y position of the pointer
  46706. */
  46707. get pointerY(): number;
  46708. set pointerY(value: number);
  46709. /**
  46710. * Gets the cached material (ie. the latest rendered one)
  46711. * @returns the cached material
  46712. */
  46713. getCachedMaterial(): Nullable<Material>;
  46714. /**
  46715. * Gets the cached effect (ie. the latest rendered one)
  46716. * @returns the cached effect
  46717. */
  46718. getCachedEffect(): Nullable<Effect>;
  46719. /**
  46720. * Gets the cached visibility state (ie. the latest rendered one)
  46721. * @returns the cached visibility state
  46722. */
  46723. getCachedVisibility(): Nullable<number>;
  46724. /**
  46725. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46726. * @param material defines the current material
  46727. * @param effect defines the current effect
  46728. * @param visibility defines the current visibility state
  46729. * @returns true if one parameter is not cached
  46730. */
  46731. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46732. /**
  46733. * Gets the engine associated with the scene
  46734. * @returns an Engine
  46735. */
  46736. getEngine(): Engine;
  46737. /**
  46738. * Gets the total number of vertices rendered per frame
  46739. * @returns the total number of vertices rendered per frame
  46740. */
  46741. getTotalVertices(): number;
  46742. /**
  46743. * Gets the performance counter for total vertices
  46744. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46745. */
  46746. get totalVerticesPerfCounter(): PerfCounter;
  46747. /**
  46748. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46749. * @returns the total number of active indices rendered per frame
  46750. */
  46751. getActiveIndices(): number;
  46752. /**
  46753. * Gets the performance counter for active indices
  46754. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46755. */
  46756. get totalActiveIndicesPerfCounter(): PerfCounter;
  46757. /**
  46758. * Gets the total number of active particles rendered per frame
  46759. * @returns the total number of active particles rendered per frame
  46760. */
  46761. getActiveParticles(): number;
  46762. /**
  46763. * Gets the performance counter for active particles
  46764. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46765. */
  46766. get activeParticlesPerfCounter(): PerfCounter;
  46767. /**
  46768. * Gets the total number of active bones rendered per frame
  46769. * @returns the total number of active bones rendered per frame
  46770. */
  46771. getActiveBones(): number;
  46772. /**
  46773. * Gets the performance counter for active bones
  46774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46775. */
  46776. get activeBonesPerfCounter(): PerfCounter;
  46777. /**
  46778. * Gets the array of active meshes
  46779. * @returns an array of AbstractMesh
  46780. */
  46781. getActiveMeshes(): SmartArray<AbstractMesh>;
  46782. /**
  46783. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46784. * @returns a number
  46785. */
  46786. getAnimationRatio(): number;
  46787. /**
  46788. * Gets an unique Id for the current render phase
  46789. * @returns a number
  46790. */
  46791. getRenderId(): number;
  46792. /**
  46793. * Gets an unique Id for the current frame
  46794. * @returns a number
  46795. */
  46796. getFrameId(): number;
  46797. /** Call this function if you want to manually increment the render Id*/
  46798. incrementRenderId(): void;
  46799. private _createUbo;
  46800. /**
  46801. * Use this method to simulate a pointer move on a mesh
  46802. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46803. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46804. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46805. * @returns the current scene
  46806. */
  46807. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46808. /**
  46809. * Use this method to simulate a pointer down on a mesh
  46810. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46811. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46812. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46813. * @returns the current scene
  46814. */
  46815. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46816. /**
  46817. * Use this method to simulate a pointer up on a mesh
  46818. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46819. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46820. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46821. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46822. * @returns the current scene
  46823. */
  46824. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46825. /**
  46826. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46827. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46828. * @returns true if the pointer was captured
  46829. */
  46830. isPointerCaptured(pointerId?: number): boolean;
  46831. /**
  46832. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46833. * @param attachUp defines if you want to attach events to pointerup
  46834. * @param attachDown defines if you want to attach events to pointerdown
  46835. * @param attachMove defines if you want to attach events to pointermove
  46836. */
  46837. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46838. /** Detaches all event handlers*/
  46839. detachControl(): void;
  46840. /**
  46841. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46842. * Delay loaded resources are not taking in account
  46843. * @return true if all required resources are ready
  46844. */
  46845. isReady(): boolean;
  46846. /** Resets all cached information relative to material (including effect and visibility) */
  46847. resetCachedMaterial(): void;
  46848. /**
  46849. * Registers a function to be called before every frame render
  46850. * @param func defines the function to register
  46851. */
  46852. registerBeforeRender(func: () => void): void;
  46853. /**
  46854. * Unregisters a function called before every frame render
  46855. * @param func defines the function to unregister
  46856. */
  46857. unregisterBeforeRender(func: () => void): void;
  46858. /**
  46859. * Registers a function to be called after every frame render
  46860. * @param func defines the function to register
  46861. */
  46862. registerAfterRender(func: () => void): void;
  46863. /**
  46864. * Unregisters a function called after every frame render
  46865. * @param func defines the function to unregister
  46866. */
  46867. unregisterAfterRender(func: () => void): void;
  46868. private _executeOnceBeforeRender;
  46869. /**
  46870. * The provided function will run before render once and will be disposed afterwards.
  46871. * A timeout delay can be provided so that the function will be executed in N ms.
  46872. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46873. * @param func The function to be executed.
  46874. * @param timeout optional delay in ms
  46875. */
  46876. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46877. /** @hidden */
  46878. _addPendingData(data: any): void;
  46879. /** @hidden */
  46880. _removePendingData(data: any): void;
  46881. /**
  46882. * Returns the number of items waiting to be loaded
  46883. * @returns the number of items waiting to be loaded
  46884. */
  46885. getWaitingItemsCount(): number;
  46886. /**
  46887. * Returns a boolean indicating if the scene is still loading data
  46888. */
  46889. get isLoading(): boolean;
  46890. /**
  46891. * Registers a function to be executed when the scene is ready
  46892. * @param {Function} func - the function to be executed
  46893. */
  46894. executeWhenReady(func: () => void): void;
  46895. /**
  46896. * Returns a promise that resolves when the scene is ready
  46897. * @returns A promise that resolves when the scene is ready
  46898. */
  46899. whenReadyAsync(): Promise<void>;
  46900. /** @hidden */
  46901. _checkIsReady(): void;
  46902. /**
  46903. * Gets all animatable attached to the scene
  46904. */
  46905. get animatables(): Animatable[];
  46906. /**
  46907. * Resets the last animation time frame.
  46908. * Useful to override when animations start running when loading a scene for the first time.
  46909. */
  46910. resetLastAnimationTimeFrame(): void;
  46911. /**
  46912. * Gets the current view matrix
  46913. * @returns a Matrix
  46914. */
  46915. getViewMatrix(): Matrix;
  46916. /**
  46917. * Gets the current projection matrix
  46918. * @returns a Matrix
  46919. */
  46920. getProjectionMatrix(): Matrix;
  46921. /**
  46922. * Gets the current transform matrix
  46923. * @returns a Matrix made of View * Projection
  46924. */
  46925. getTransformMatrix(): Matrix;
  46926. /**
  46927. * Sets the current transform matrix
  46928. * @param viewL defines the View matrix to use
  46929. * @param projectionL defines the Projection matrix to use
  46930. * @param viewR defines the right View matrix to use (if provided)
  46931. * @param projectionR defines the right Projection matrix to use (if provided)
  46932. */
  46933. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  46934. /**
  46935. * Gets the uniform buffer used to store scene data
  46936. * @returns a UniformBuffer
  46937. */
  46938. getSceneUniformBuffer(): UniformBuffer;
  46939. /**
  46940. * Gets an unique (relatively to the current scene) Id
  46941. * @returns an unique number for the scene
  46942. */
  46943. getUniqueId(): number;
  46944. /**
  46945. * Add a mesh to the list of scene's meshes
  46946. * @param newMesh defines the mesh to add
  46947. * @param recursive if all child meshes should also be added to the scene
  46948. */
  46949. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  46950. /**
  46951. * Remove a mesh for the list of scene's meshes
  46952. * @param toRemove defines the mesh to remove
  46953. * @param recursive if all child meshes should also be removed from the scene
  46954. * @returns the index where the mesh was in the mesh list
  46955. */
  46956. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  46957. /**
  46958. * Add a transform node to the list of scene's transform nodes
  46959. * @param newTransformNode defines the transform node to add
  46960. */
  46961. addTransformNode(newTransformNode: TransformNode): void;
  46962. /**
  46963. * Remove a transform node for the list of scene's transform nodes
  46964. * @param toRemove defines the transform node to remove
  46965. * @returns the index where the transform node was in the transform node list
  46966. */
  46967. removeTransformNode(toRemove: TransformNode): number;
  46968. /**
  46969. * Remove a skeleton for the list of scene's skeletons
  46970. * @param toRemove defines the skeleton to remove
  46971. * @returns the index where the skeleton was in the skeleton list
  46972. */
  46973. removeSkeleton(toRemove: Skeleton): number;
  46974. /**
  46975. * Remove a morph target for the list of scene's morph targets
  46976. * @param toRemove defines the morph target to remove
  46977. * @returns the index where the morph target was in the morph target list
  46978. */
  46979. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  46980. /**
  46981. * Remove a light for the list of scene's lights
  46982. * @param toRemove defines the light to remove
  46983. * @returns the index where the light was in the light list
  46984. */
  46985. removeLight(toRemove: Light): number;
  46986. /**
  46987. * Remove a camera for the list of scene's cameras
  46988. * @param toRemove defines the camera to remove
  46989. * @returns the index where the camera was in the camera list
  46990. */
  46991. removeCamera(toRemove: Camera): number;
  46992. /**
  46993. * Remove a particle system for the list of scene's particle systems
  46994. * @param toRemove defines the particle system to remove
  46995. * @returns the index where the particle system was in the particle system list
  46996. */
  46997. removeParticleSystem(toRemove: IParticleSystem): number;
  46998. /**
  46999. * Remove a animation for the list of scene's animations
  47000. * @param toRemove defines the animation to remove
  47001. * @returns the index where the animation was in the animation list
  47002. */
  47003. removeAnimation(toRemove: Animation): number;
  47004. /**
  47005. * Will stop the animation of the given target
  47006. * @param target - the target
  47007. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47008. * @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)
  47009. */
  47010. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47011. /**
  47012. * Removes the given animation group from this scene.
  47013. * @param toRemove The animation group to remove
  47014. * @returns The index of the removed animation group
  47015. */
  47016. removeAnimationGroup(toRemove: AnimationGroup): number;
  47017. /**
  47018. * Removes the given multi-material from this scene.
  47019. * @param toRemove The multi-material to remove
  47020. * @returns The index of the removed multi-material
  47021. */
  47022. removeMultiMaterial(toRemove: MultiMaterial): number;
  47023. /**
  47024. * Removes the given material from this scene.
  47025. * @param toRemove The material to remove
  47026. * @returns The index of the removed material
  47027. */
  47028. removeMaterial(toRemove: Material): number;
  47029. /**
  47030. * Removes the given action manager from this scene.
  47031. * @param toRemove The action manager to remove
  47032. * @returns The index of the removed action manager
  47033. */
  47034. removeActionManager(toRemove: AbstractActionManager): number;
  47035. /**
  47036. * Removes the given texture from this scene.
  47037. * @param toRemove The texture to remove
  47038. * @returns The index of the removed texture
  47039. */
  47040. removeTexture(toRemove: BaseTexture): number;
  47041. /**
  47042. * Adds the given light to this scene
  47043. * @param newLight The light to add
  47044. */
  47045. addLight(newLight: Light): void;
  47046. /**
  47047. * Sorts the list list based on light priorities
  47048. */
  47049. sortLightsByPriority(): void;
  47050. /**
  47051. * Adds the given camera to this scene
  47052. * @param newCamera The camera to add
  47053. */
  47054. addCamera(newCamera: Camera): void;
  47055. /**
  47056. * Adds the given skeleton to this scene
  47057. * @param newSkeleton The skeleton to add
  47058. */
  47059. addSkeleton(newSkeleton: Skeleton): void;
  47060. /**
  47061. * Adds the given particle system to this scene
  47062. * @param newParticleSystem The particle system to add
  47063. */
  47064. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47065. /**
  47066. * Adds the given animation to this scene
  47067. * @param newAnimation The animation to add
  47068. */
  47069. addAnimation(newAnimation: Animation): void;
  47070. /**
  47071. * Adds the given animation group to this scene.
  47072. * @param newAnimationGroup The animation group to add
  47073. */
  47074. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47075. /**
  47076. * Adds the given multi-material to this scene
  47077. * @param newMultiMaterial The multi-material to add
  47078. */
  47079. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47080. /**
  47081. * Adds the given material to this scene
  47082. * @param newMaterial The material to add
  47083. */
  47084. addMaterial(newMaterial: Material): void;
  47085. /**
  47086. * Adds the given morph target to this scene
  47087. * @param newMorphTargetManager The morph target to add
  47088. */
  47089. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47090. /**
  47091. * Adds the given geometry to this scene
  47092. * @param newGeometry The geometry to add
  47093. */
  47094. addGeometry(newGeometry: Geometry): void;
  47095. /**
  47096. * Adds the given action manager to this scene
  47097. * @param newActionManager The action manager to add
  47098. */
  47099. addActionManager(newActionManager: AbstractActionManager): void;
  47100. /**
  47101. * Adds the given texture to this scene.
  47102. * @param newTexture The texture to add
  47103. */
  47104. addTexture(newTexture: BaseTexture): void;
  47105. /**
  47106. * Switch active camera
  47107. * @param newCamera defines the new active camera
  47108. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47109. */
  47110. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47111. /**
  47112. * sets the active camera of the scene using its ID
  47113. * @param id defines the camera's ID
  47114. * @return the new active camera or null if none found.
  47115. */
  47116. setActiveCameraByID(id: string): Nullable<Camera>;
  47117. /**
  47118. * sets the active camera of the scene using its name
  47119. * @param name defines the camera's name
  47120. * @returns the new active camera or null if none found.
  47121. */
  47122. setActiveCameraByName(name: string): Nullable<Camera>;
  47123. /**
  47124. * get an animation group using its name
  47125. * @param name defines the material's name
  47126. * @return the animation group or null if none found.
  47127. */
  47128. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47129. /**
  47130. * Get a material using its unique id
  47131. * @param uniqueId defines the material's unique id
  47132. * @return the material or null if none found.
  47133. */
  47134. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47135. /**
  47136. * get a material using its id
  47137. * @param id defines the material's ID
  47138. * @return the material or null if none found.
  47139. */
  47140. getMaterialByID(id: string): Nullable<Material>;
  47141. /**
  47142. * Gets a the last added material using a given id
  47143. * @param id defines the material's ID
  47144. * @return the last material with the given id or null if none found.
  47145. */
  47146. getLastMaterialByID(id: string): Nullable<Material>;
  47147. /**
  47148. * Gets a material using its name
  47149. * @param name defines the material's name
  47150. * @return the material or null if none found.
  47151. */
  47152. getMaterialByName(name: string): Nullable<Material>;
  47153. /**
  47154. * Get a texture using its unique id
  47155. * @param uniqueId defines the texture's unique id
  47156. * @return the texture or null if none found.
  47157. */
  47158. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47159. /**
  47160. * Gets a camera using its id
  47161. * @param id defines the id to look for
  47162. * @returns the camera or null if not found
  47163. */
  47164. getCameraByID(id: string): Nullable<Camera>;
  47165. /**
  47166. * Gets a camera using its unique id
  47167. * @param uniqueId defines the unique id to look for
  47168. * @returns the camera or null if not found
  47169. */
  47170. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47171. /**
  47172. * Gets a camera using its name
  47173. * @param name defines the camera's name
  47174. * @return the camera or null if none found.
  47175. */
  47176. getCameraByName(name: string): Nullable<Camera>;
  47177. /**
  47178. * Gets a bone using its id
  47179. * @param id defines the bone's id
  47180. * @return the bone or null if not found
  47181. */
  47182. getBoneByID(id: string): Nullable<Bone>;
  47183. /**
  47184. * Gets a bone using its id
  47185. * @param name defines the bone's name
  47186. * @return the bone or null if not found
  47187. */
  47188. getBoneByName(name: string): Nullable<Bone>;
  47189. /**
  47190. * Gets a light node using its name
  47191. * @param name defines the the light's name
  47192. * @return the light or null if none found.
  47193. */
  47194. getLightByName(name: string): Nullable<Light>;
  47195. /**
  47196. * Gets a light node using its id
  47197. * @param id defines the light's id
  47198. * @return the light or null if none found.
  47199. */
  47200. getLightByID(id: string): Nullable<Light>;
  47201. /**
  47202. * Gets a light node using its scene-generated unique ID
  47203. * @param uniqueId defines the light's unique id
  47204. * @return the light or null if none found.
  47205. */
  47206. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47207. /**
  47208. * Gets a particle system by id
  47209. * @param id defines the particle system id
  47210. * @return the corresponding system or null if none found
  47211. */
  47212. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47213. /**
  47214. * Gets a geometry using its ID
  47215. * @param id defines the geometry's id
  47216. * @return the geometry or null if none found.
  47217. */
  47218. getGeometryByID(id: string): Nullable<Geometry>;
  47219. private _getGeometryByUniqueID;
  47220. /**
  47221. * Add a new geometry to this scene
  47222. * @param geometry defines the geometry to be added to the scene.
  47223. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47224. * @return a boolean defining if the geometry was added or not
  47225. */
  47226. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47227. /**
  47228. * Removes an existing geometry
  47229. * @param geometry defines the geometry to be removed from the scene
  47230. * @return a boolean defining if the geometry was removed or not
  47231. */
  47232. removeGeometry(geometry: Geometry): boolean;
  47233. /**
  47234. * Gets the list of geometries attached to the scene
  47235. * @returns an array of Geometry
  47236. */
  47237. getGeometries(): Geometry[];
  47238. /**
  47239. * Gets the first added mesh found of a given ID
  47240. * @param id defines the id to search for
  47241. * @return the mesh found or null if not found at all
  47242. */
  47243. getMeshByID(id: string): Nullable<AbstractMesh>;
  47244. /**
  47245. * Gets a list of meshes using their id
  47246. * @param id defines the id to search for
  47247. * @returns a list of meshes
  47248. */
  47249. getMeshesByID(id: string): Array<AbstractMesh>;
  47250. /**
  47251. * Gets the first added transform node found of a given ID
  47252. * @param id defines the id to search for
  47253. * @return the found transform node or null if not found at all.
  47254. */
  47255. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47256. /**
  47257. * Gets a transform node with its auto-generated unique id
  47258. * @param uniqueId efines the unique id to search for
  47259. * @return the found transform node or null if not found at all.
  47260. */
  47261. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47262. /**
  47263. * Gets a list of transform nodes using their id
  47264. * @param id defines the id to search for
  47265. * @returns a list of transform nodes
  47266. */
  47267. getTransformNodesByID(id: string): Array<TransformNode>;
  47268. /**
  47269. * Gets a mesh with its auto-generated unique id
  47270. * @param uniqueId defines the unique id to search for
  47271. * @return the found mesh or null if not found at all.
  47272. */
  47273. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47274. /**
  47275. * Gets a the last added mesh using a given id
  47276. * @param id defines the id to search for
  47277. * @return the found mesh or null if not found at all.
  47278. */
  47279. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47280. /**
  47281. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47282. * @param id defines the id to search for
  47283. * @return the found node or null if not found at all
  47284. */
  47285. getLastEntryByID(id: string): Nullable<Node>;
  47286. /**
  47287. * Gets a node (Mesh, Camera, Light) using a given id
  47288. * @param id defines the id to search for
  47289. * @return the found node or null if not found at all
  47290. */
  47291. getNodeByID(id: string): Nullable<Node>;
  47292. /**
  47293. * Gets a node (Mesh, Camera, Light) using a given name
  47294. * @param name defines the name to search for
  47295. * @return the found node or null if not found at all.
  47296. */
  47297. getNodeByName(name: string): Nullable<Node>;
  47298. /**
  47299. * Gets a mesh using a given name
  47300. * @param name defines the name to search for
  47301. * @return the found mesh or null if not found at all.
  47302. */
  47303. getMeshByName(name: string): Nullable<AbstractMesh>;
  47304. /**
  47305. * Gets a transform node using a given name
  47306. * @param name defines the name to search for
  47307. * @return the found transform node or null if not found at all.
  47308. */
  47309. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47310. /**
  47311. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47312. * @param id defines the id to search for
  47313. * @return the found skeleton or null if not found at all.
  47314. */
  47315. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47316. /**
  47317. * Gets a skeleton using a given auto generated unique id
  47318. * @param uniqueId defines the unique id to search for
  47319. * @return the found skeleton or null if not found at all.
  47320. */
  47321. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47322. /**
  47323. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47324. * @param id defines the id to search for
  47325. * @return the found skeleton or null if not found at all.
  47326. */
  47327. getSkeletonById(id: string): Nullable<Skeleton>;
  47328. /**
  47329. * Gets a skeleton using a given name
  47330. * @param name defines the name to search for
  47331. * @return the found skeleton or null if not found at all.
  47332. */
  47333. getSkeletonByName(name: string): Nullable<Skeleton>;
  47334. /**
  47335. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47336. * @param id defines the id to search for
  47337. * @return the found morph target manager or null if not found at all.
  47338. */
  47339. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47340. /**
  47341. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47342. * @param id defines the id to search for
  47343. * @return the found morph target or null if not found at all.
  47344. */
  47345. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47346. /**
  47347. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47348. * @param name defines the name to search for
  47349. * @return the found morph target or null if not found at all.
  47350. */
  47351. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47352. /**
  47353. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47354. * @param name defines the name to search for
  47355. * @return the found post process or null if not found at all.
  47356. */
  47357. getPostProcessByName(name: string): Nullable<PostProcess>;
  47358. /**
  47359. * Gets a boolean indicating if the given mesh is active
  47360. * @param mesh defines the mesh to look for
  47361. * @returns true if the mesh is in the active list
  47362. */
  47363. isActiveMesh(mesh: AbstractMesh): boolean;
  47364. /**
  47365. * Return a unique id as a string which can serve as an identifier for the scene
  47366. */
  47367. get uid(): string;
  47368. /**
  47369. * Add an externaly attached data from its key.
  47370. * This method call will fail and return false, if such key already exists.
  47371. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47372. * @param key the unique key that identifies the data
  47373. * @param data the data object to associate to the key for this Engine instance
  47374. * @return true if no such key were already present and the data was added successfully, false otherwise
  47375. */
  47376. addExternalData<T>(key: string, data: T): boolean;
  47377. /**
  47378. * Get an externaly attached data from its key
  47379. * @param key the unique key that identifies the data
  47380. * @return the associated data, if present (can be null), or undefined if not present
  47381. */
  47382. getExternalData<T>(key: string): Nullable<T>;
  47383. /**
  47384. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47385. * @param key the unique key that identifies the data
  47386. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47387. * @return the associated data, can be null if the factory returned null.
  47388. */
  47389. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47390. /**
  47391. * Remove an externaly attached data from the Engine instance
  47392. * @param key the unique key that identifies the data
  47393. * @return true if the data was successfully removed, false if it doesn't exist
  47394. */
  47395. removeExternalData(key: string): boolean;
  47396. private _evaluateSubMesh;
  47397. /**
  47398. * Clear the processed materials smart array preventing retention point in material dispose.
  47399. */
  47400. freeProcessedMaterials(): void;
  47401. private _preventFreeActiveMeshesAndRenderingGroups;
  47402. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47403. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47404. * when disposing several meshes in a row or a hierarchy of meshes.
  47405. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47406. */
  47407. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47408. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47409. /**
  47410. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47411. */
  47412. freeActiveMeshes(): void;
  47413. /**
  47414. * Clear the info related to rendering groups preventing retention points during dispose.
  47415. */
  47416. freeRenderingGroups(): void;
  47417. /** @hidden */
  47418. _isInIntermediateRendering(): boolean;
  47419. /**
  47420. * Lambda returning the list of potentially active meshes.
  47421. */
  47422. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47423. /**
  47424. * Lambda returning the list of potentially active sub meshes.
  47425. */
  47426. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47427. /**
  47428. * Lambda returning the list of potentially intersecting sub meshes.
  47429. */
  47430. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47431. /**
  47432. * Lambda returning the list of potentially colliding sub meshes.
  47433. */
  47434. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47435. /** @hidden */
  47436. _activeMeshesFrozen: boolean;
  47437. private _skipEvaluateActiveMeshesCompletely;
  47438. /**
  47439. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47440. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47441. * @param onSuccess optional success callback
  47442. * @param onError optional error callback
  47443. * @returns the current scene
  47444. */
  47445. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47446. /**
  47447. * Use this function to restart evaluating active meshes on every frame
  47448. * @returns the current scene
  47449. */
  47450. unfreezeActiveMeshes(): Scene;
  47451. private _evaluateActiveMeshes;
  47452. private _activeMesh;
  47453. /**
  47454. * Update the transform matrix to update from the current active camera
  47455. * @param force defines a boolean used to force the update even if cache is up to date
  47456. */
  47457. updateTransformMatrix(force?: boolean): void;
  47458. private _bindFrameBuffer;
  47459. /** @hidden */
  47460. _allowPostProcessClearColor: boolean;
  47461. /** @hidden */
  47462. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47463. private _processSubCameras;
  47464. private _checkIntersections;
  47465. /** @hidden */
  47466. _advancePhysicsEngineStep(step: number): void;
  47467. /**
  47468. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47469. */
  47470. getDeterministicFrameTime: () => number;
  47471. /** @hidden */
  47472. _animate(): void;
  47473. /** Execute all animations (for a frame) */
  47474. animate(): void;
  47475. /**
  47476. * Render the scene
  47477. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47478. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47479. */
  47480. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47481. /**
  47482. * Freeze all materials
  47483. * A frozen material will not be updatable but should be faster to render
  47484. */
  47485. freezeMaterials(): void;
  47486. /**
  47487. * Unfreeze all materials
  47488. * A frozen material will not be updatable but should be faster to render
  47489. */
  47490. unfreezeMaterials(): void;
  47491. /**
  47492. * Releases all held ressources
  47493. */
  47494. dispose(): void;
  47495. /**
  47496. * Gets if the scene is already disposed
  47497. */
  47498. get isDisposed(): boolean;
  47499. /**
  47500. * Call this function to reduce memory footprint of the scene.
  47501. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47502. */
  47503. clearCachedVertexData(): void;
  47504. /**
  47505. * This function will remove the local cached buffer data from texture.
  47506. * It will save memory but will prevent the texture from being rebuilt
  47507. */
  47508. cleanCachedTextureBuffer(): void;
  47509. /**
  47510. * Get the world extend vectors with an optional filter
  47511. *
  47512. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47513. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47514. */
  47515. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47516. min: Vector3;
  47517. max: Vector3;
  47518. };
  47519. /**
  47520. * Creates a ray that can be used to pick in the scene
  47521. * @param x defines the x coordinate of the origin (on-screen)
  47522. * @param y defines the y coordinate of the origin (on-screen)
  47523. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47524. * @param camera defines the camera to use for the picking
  47525. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47526. * @returns a Ray
  47527. */
  47528. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47529. /**
  47530. * Creates a ray that can be used to pick in the scene
  47531. * @param x defines the x coordinate of the origin (on-screen)
  47532. * @param y defines the y coordinate of the origin (on-screen)
  47533. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47534. * @param result defines the ray where to store the picking ray
  47535. * @param camera defines the camera to use for the picking
  47536. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47537. * @returns the current scene
  47538. */
  47539. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47540. /**
  47541. * Creates a ray that can be used to pick in the scene
  47542. * @param x defines the x coordinate of the origin (on-screen)
  47543. * @param y defines the y coordinate of the origin (on-screen)
  47544. * @param camera defines the camera to use for the picking
  47545. * @returns a Ray
  47546. */
  47547. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47548. /**
  47549. * Creates a ray that can be used to pick in the scene
  47550. * @param x defines the x coordinate of the origin (on-screen)
  47551. * @param y defines the y coordinate of the origin (on-screen)
  47552. * @param result defines the ray where to store the picking ray
  47553. * @param camera defines the camera to use for the picking
  47554. * @returns the current scene
  47555. */
  47556. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47557. /** Launch a ray to try to pick a mesh in the scene
  47558. * @param x position on screen
  47559. * @param y position on screen
  47560. * @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
  47561. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47562. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47563. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47564. * @returns a PickingInfo
  47565. */
  47566. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47567. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47568. * @param x position on screen
  47569. * @param y position on screen
  47570. * @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
  47571. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47572. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47573. * @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)
  47574. */
  47575. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47576. /** Use the given ray to pick a mesh in the scene
  47577. * @param ray The ray to use to pick meshes
  47578. * @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
  47579. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47580. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47581. * @returns a PickingInfo
  47582. */
  47583. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47584. /**
  47585. * Launch a ray to try to pick a mesh in the scene
  47586. * @param x X position on screen
  47587. * @param y Y position on screen
  47588. * @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
  47589. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47590. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47591. * @returns an array of PickingInfo
  47592. */
  47593. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47594. /**
  47595. * Launch a ray to try to pick a mesh in the scene
  47596. * @param ray Ray to use
  47597. * @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
  47598. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47599. * @returns an array of PickingInfo
  47600. */
  47601. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47602. /**
  47603. * Force the value of meshUnderPointer
  47604. * @param mesh defines the mesh to use
  47605. * @param pointerId optional pointer id when using more than one pointer
  47606. */
  47607. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47608. /**
  47609. * Gets the mesh under the pointer
  47610. * @returns a Mesh or null if no mesh is under the pointer
  47611. */
  47612. getPointerOverMesh(): Nullable<AbstractMesh>;
  47613. /** @hidden */
  47614. _rebuildGeometries(): void;
  47615. /** @hidden */
  47616. _rebuildTextures(): void;
  47617. private _getByTags;
  47618. /**
  47619. * Get a list of meshes by tags
  47620. * @param tagsQuery defines the tags query to use
  47621. * @param forEach defines a predicate used to filter results
  47622. * @returns an array of Mesh
  47623. */
  47624. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47625. /**
  47626. * Get a list of cameras by tags
  47627. * @param tagsQuery defines the tags query to use
  47628. * @param forEach defines a predicate used to filter results
  47629. * @returns an array of Camera
  47630. */
  47631. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47632. /**
  47633. * Get a list of lights by tags
  47634. * @param tagsQuery defines the tags query to use
  47635. * @param forEach defines a predicate used to filter results
  47636. * @returns an array of Light
  47637. */
  47638. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47639. /**
  47640. * Get a list of materials by tags
  47641. * @param tagsQuery defines the tags query to use
  47642. * @param forEach defines a predicate used to filter results
  47643. * @returns an array of Material
  47644. */
  47645. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47646. /**
  47647. * Get a list of transform nodes by tags
  47648. * @param tagsQuery defines the tags query to use
  47649. * @param forEach defines a predicate used to filter results
  47650. * @returns an array of TransformNode
  47651. */
  47652. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47653. /**
  47654. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47655. * This allowed control for front to back rendering or reversly depending of the special needs.
  47656. *
  47657. * @param renderingGroupId The rendering group id corresponding to its index
  47658. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47659. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47660. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47661. */
  47662. 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;
  47663. /**
  47664. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47665. *
  47666. * @param renderingGroupId The rendering group id corresponding to its index
  47667. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47668. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47669. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47670. */
  47671. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47672. /**
  47673. * Gets the current auto clear configuration for one rendering group of the rendering
  47674. * manager.
  47675. * @param index the rendering group index to get the information for
  47676. * @returns The auto clear setup for the requested rendering group
  47677. */
  47678. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47679. private _blockMaterialDirtyMechanism;
  47680. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47681. get blockMaterialDirtyMechanism(): boolean;
  47682. set blockMaterialDirtyMechanism(value: boolean);
  47683. /**
  47684. * Will flag all materials as dirty to trigger new shader compilation
  47685. * @param flag defines the flag used to specify which material part must be marked as dirty
  47686. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47687. */
  47688. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47689. /** @hidden */
  47690. _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;
  47691. /** @hidden */
  47692. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47693. /** @hidden */
  47694. _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;
  47695. /** @hidden */
  47696. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47697. /** @hidden */
  47698. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47699. /** @hidden */
  47700. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47701. }
  47702. }
  47703. declare module BABYLON {
  47704. /**
  47705. * Set of assets to keep when moving a scene into an asset container.
  47706. */
  47707. export class KeepAssets extends AbstractScene {
  47708. }
  47709. /**
  47710. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47711. */
  47712. export class InstantiatedEntries {
  47713. /**
  47714. * List of new root nodes (eg. nodes with no parent)
  47715. */
  47716. rootNodes: TransformNode[];
  47717. /**
  47718. * List of new skeletons
  47719. */
  47720. skeletons: Skeleton[];
  47721. /**
  47722. * List of new animation groups
  47723. */
  47724. animationGroups: AnimationGroup[];
  47725. }
  47726. /**
  47727. * Container with a set of assets that can be added or removed from a scene.
  47728. */
  47729. export class AssetContainer extends AbstractScene {
  47730. private _wasAddedToScene;
  47731. /**
  47732. * The scene the AssetContainer belongs to.
  47733. */
  47734. scene: Scene;
  47735. /**
  47736. * Instantiates an AssetContainer.
  47737. * @param scene The scene the AssetContainer belongs to.
  47738. */
  47739. constructor(scene: Scene);
  47740. /**
  47741. * Instantiate or clone all meshes and add the new ones to the scene.
  47742. * Skeletons and animation groups will all be cloned
  47743. * @param nameFunction defines an optional function used to get new names for clones
  47744. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47745. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47746. */
  47747. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47748. /**
  47749. * Adds all the assets from the container to the scene.
  47750. */
  47751. addAllToScene(): void;
  47752. /**
  47753. * Removes all the assets in the container from the scene
  47754. */
  47755. removeAllFromScene(): void;
  47756. /**
  47757. * Disposes all the assets in the container
  47758. */
  47759. dispose(): void;
  47760. private _moveAssets;
  47761. /**
  47762. * Removes all the assets contained in the scene and adds them to the container.
  47763. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47764. */
  47765. moveAllFromScene(keepAssets?: KeepAssets): void;
  47766. /**
  47767. * 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.
  47768. * @returns the root mesh
  47769. */
  47770. createRootMesh(): Mesh;
  47771. /**
  47772. * Merge animations (direct and animation groups) from this asset container into a scene
  47773. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47774. * @param animatables set of animatables to retarget to a node from the scene
  47775. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47776. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47777. */
  47778. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47779. }
  47780. }
  47781. declare module BABYLON {
  47782. /**
  47783. * Defines how the parser contract is defined.
  47784. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47785. */
  47786. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47787. /**
  47788. * Defines how the individual parser contract is defined.
  47789. * These parser can parse an individual asset
  47790. */
  47791. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47792. /**
  47793. * Base class of the scene acting as a container for the different elements composing a scene.
  47794. * This class is dynamically extended by the different components of the scene increasing
  47795. * flexibility and reducing coupling
  47796. */
  47797. export abstract class AbstractScene {
  47798. /**
  47799. * Stores the list of available parsers in the application.
  47800. */
  47801. private static _BabylonFileParsers;
  47802. /**
  47803. * Stores the list of available individual parsers in the application.
  47804. */
  47805. private static _IndividualBabylonFileParsers;
  47806. /**
  47807. * Adds a parser in the list of available ones
  47808. * @param name Defines the name of the parser
  47809. * @param parser Defines the parser to add
  47810. */
  47811. static AddParser(name: string, parser: BabylonFileParser): void;
  47812. /**
  47813. * Gets a general parser from the list of avaialble ones
  47814. * @param name Defines the name of the parser
  47815. * @returns the requested parser or null
  47816. */
  47817. static GetParser(name: string): Nullable<BabylonFileParser>;
  47818. /**
  47819. * Adds n individual parser in the list of available ones
  47820. * @param name Defines the name of the parser
  47821. * @param parser Defines the parser to add
  47822. */
  47823. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47824. /**
  47825. * Gets an individual parser from the list of avaialble ones
  47826. * @param name Defines the name of the parser
  47827. * @returns the requested parser or null
  47828. */
  47829. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47830. /**
  47831. * Parser json data and populate both a scene and its associated container object
  47832. * @param jsonData Defines the data to parse
  47833. * @param scene Defines the scene to parse the data for
  47834. * @param container Defines the container attached to the parsing sequence
  47835. * @param rootUrl Defines the root url of the data
  47836. */
  47837. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47838. /**
  47839. * Gets the list of root nodes (ie. nodes with no parent)
  47840. */
  47841. rootNodes: Node[];
  47842. /** All of the cameras added to this scene
  47843. * @see https://doc.babylonjs.com/babylon101/cameras
  47844. */
  47845. cameras: Camera[];
  47846. /**
  47847. * All of the lights added to this scene
  47848. * @see https://doc.babylonjs.com/babylon101/lights
  47849. */
  47850. lights: Light[];
  47851. /**
  47852. * All of the (abstract) meshes added to this scene
  47853. */
  47854. meshes: AbstractMesh[];
  47855. /**
  47856. * The list of skeletons added to the scene
  47857. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47858. */
  47859. skeletons: Skeleton[];
  47860. /**
  47861. * All of the particle systems added to this scene
  47862. * @see https://doc.babylonjs.com/babylon101/particles
  47863. */
  47864. particleSystems: IParticleSystem[];
  47865. /**
  47866. * Gets a list of Animations associated with the scene
  47867. */
  47868. animations: Animation[];
  47869. /**
  47870. * All of the animation groups added to this scene
  47871. * @see https://doc.babylonjs.com/how_to/group
  47872. */
  47873. animationGroups: AnimationGroup[];
  47874. /**
  47875. * All of the multi-materials added to this scene
  47876. * @see https://doc.babylonjs.com/how_to/multi_materials
  47877. */
  47878. multiMaterials: MultiMaterial[];
  47879. /**
  47880. * All of the materials added to this scene
  47881. * In the context of a Scene, it is not supposed to be modified manually.
  47882. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47883. * Note also that the order of the Material within the array is not significant and might change.
  47884. * @see https://doc.babylonjs.com/babylon101/materials
  47885. */
  47886. materials: Material[];
  47887. /**
  47888. * The list of morph target managers added to the scene
  47889. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47890. */
  47891. morphTargetManagers: MorphTargetManager[];
  47892. /**
  47893. * The list of geometries used in the scene.
  47894. */
  47895. geometries: Geometry[];
  47896. /**
  47897. * All of the tranform nodes added to this scene
  47898. * In the context of a Scene, it is not supposed to be modified manually.
  47899. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47900. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47901. * @see https://doc.babylonjs.com/how_to/transformnode
  47902. */
  47903. transformNodes: TransformNode[];
  47904. /**
  47905. * ActionManagers available on the scene.
  47906. */
  47907. actionManagers: AbstractActionManager[];
  47908. /**
  47909. * Textures to keep.
  47910. */
  47911. textures: BaseTexture[];
  47912. /** @hidden */
  47913. protected _environmentTexture: Nullable<BaseTexture>;
  47914. /**
  47915. * Texture used in all pbr material as the reflection texture.
  47916. * As in the majority of the scene they are the same (exception for multi room and so on),
  47917. * this is easier to reference from here than from all the materials.
  47918. */
  47919. get environmentTexture(): Nullable<BaseTexture>;
  47920. set environmentTexture(value: Nullable<BaseTexture>);
  47921. /**
  47922. * The list of postprocesses added to the scene
  47923. */
  47924. postProcesses: PostProcess[];
  47925. /**
  47926. * @returns all meshes, lights, cameras, transformNodes and bones
  47927. */
  47928. getNodes(): Array<Node>;
  47929. }
  47930. }
  47931. declare module BABYLON {
  47932. /**
  47933. * Interface used to define options for Sound class
  47934. */
  47935. export interface ISoundOptions {
  47936. /**
  47937. * Does the sound autoplay once loaded.
  47938. */
  47939. autoplay?: boolean;
  47940. /**
  47941. * Does the sound loop after it finishes playing once.
  47942. */
  47943. loop?: boolean;
  47944. /**
  47945. * Sound's volume
  47946. */
  47947. volume?: number;
  47948. /**
  47949. * Is it a spatial sound?
  47950. */
  47951. spatialSound?: boolean;
  47952. /**
  47953. * Maximum distance to hear that sound
  47954. */
  47955. maxDistance?: number;
  47956. /**
  47957. * Uses user defined attenuation function
  47958. */
  47959. useCustomAttenuation?: boolean;
  47960. /**
  47961. * Define the roll off factor of spatial sounds.
  47962. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47963. */
  47964. rolloffFactor?: number;
  47965. /**
  47966. * Define the reference distance the sound should be heard perfectly.
  47967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47968. */
  47969. refDistance?: number;
  47970. /**
  47971. * Define the distance attenuation model the sound will follow.
  47972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47973. */
  47974. distanceModel?: string;
  47975. /**
  47976. * Defines the playback speed (1 by default)
  47977. */
  47978. playbackRate?: number;
  47979. /**
  47980. * Defines if the sound is from a streaming source
  47981. */
  47982. streaming?: boolean;
  47983. /**
  47984. * Defines an optional length (in seconds) inside the sound file
  47985. */
  47986. length?: number;
  47987. /**
  47988. * Defines an optional offset (in seconds) inside the sound file
  47989. */
  47990. offset?: number;
  47991. /**
  47992. * If true, URLs will not be required to state the audio file codec to use.
  47993. */
  47994. skipCodecCheck?: boolean;
  47995. }
  47996. }
  47997. declare module BABYLON {
  47998. /**
  47999. * Defines a sound that can be played in the application.
  48000. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48001. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48002. */
  48003. export class Sound {
  48004. /**
  48005. * The name of the sound in the scene.
  48006. */
  48007. name: string;
  48008. /**
  48009. * Does the sound autoplay once loaded.
  48010. */
  48011. autoplay: boolean;
  48012. private _loop;
  48013. /**
  48014. * Does the sound loop after it finishes playing once.
  48015. */
  48016. get loop(): boolean;
  48017. set loop(value: boolean);
  48018. /**
  48019. * Does the sound use a custom attenuation curve to simulate the falloff
  48020. * happening when the source gets further away from the camera.
  48021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48022. */
  48023. useCustomAttenuation: boolean;
  48024. /**
  48025. * The sound track id this sound belongs to.
  48026. */
  48027. soundTrackId: number;
  48028. /**
  48029. * Is this sound currently played.
  48030. */
  48031. isPlaying: boolean;
  48032. /**
  48033. * Is this sound currently paused.
  48034. */
  48035. isPaused: boolean;
  48036. /**
  48037. * Does this sound enables spatial sound.
  48038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48039. */
  48040. spatialSound: boolean;
  48041. /**
  48042. * Define the reference distance the sound should be heard perfectly.
  48043. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48044. */
  48045. refDistance: number;
  48046. /**
  48047. * Define the roll off factor of spatial sounds.
  48048. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48049. */
  48050. rolloffFactor: number;
  48051. /**
  48052. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48053. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48054. */
  48055. maxDistance: number;
  48056. /**
  48057. * Define the distance attenuation model the sound will follow.
  48058. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48059. */
  48060. distanceModel: string;
  48061. /**
  48062. * @hidden
  48063. * Back Compat
  48064. **/
  48065. onended: () => any;
  48066. /**
  48067. * Gets or sets an object used to store user defined information for the sound.
  48068. */
  48069. metadata: any;
  48070. /**
  48071. * Observable event when the current playing sound finishes.
  48072. */
  48073. onEndedObservable: Observable<Sound>;
  48074. /**
  48075. * Gets the current time for the sound.
  48076. */
  48077. get currentTime(): number;
  48078. private _panningModel;
  48079. private _playbackRate;
  48080. private _streaming;
  48081. private _startTime;
  48082. private _startOffset;
  48083. private _position;
  48084. /** @hidden */
  48085. _positionInEmitterSpace: boolean;
  48086. private _localDirection;
  48087. private _volume;
  48088. private _isReadyToPlay;
  48089. private _isDirectional;
  48090. private _readyToPlayCallback;
  48091. private _audioBuffer;
  48092. private _soundSource;
  48093. private _streamingSource;
  48094. private _soundPanner;
  48095. private _soundGain;
  48096. private _inputAudioNode;
  48097. private _outputAudioNode;
  48098. private _coneInnerAngle;
  48099. private _coneOuterAngle;
  48100. private _coneOuterGain;
  48101. private _scene;
  48102. private _connectedTransformNode;
  48103. private _customAttenuationFunction;
  48104. private _registerFunc;
  48105. private _isOutputConnected;
  48106. private _htmlAudioElement;
  48107. private _urlType;
  48108. private _length?;
  48109. private _offset?;
  48110. /** @hidden */
  48111. static _SceneComponentInitialization: (scene: Scene) => void;
  48112. /**
  48113. * Create a sound and attach it to a scene
  48114. * @param name Name of your sound
  48115. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48116. * @param scene defines the scene the sound belongs to
  48117. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48118. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48119. */
  48120. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48121. /**
  48122. * Release the sound and its associated resources
  48123. */
  48124. dispose(): void;
  48125. /**
  48126. * Gets if the sounds is ready to be played or not.
  48127. * @returns true if ready, otherwise false
  48128. */
  48129. isReady(): boolean;
  48130. /**
  48131. * Get the current class name.
  48132. * @returns current class name
  48133. */
  48134. getClassName(): string;
  48135. private _soundLoaded;
  48136. /**
  48137. * Sets the data of the sound from an audiobuffer
  48138. * @param audioBuffer The audioBuffer containing the data
  48139. */
  48140. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48141. /**
  48142. * Updates the current sounds options such as maxdistance, loop...
  48143. * @param options A JSON object containing values named as the object properties
  48144. */
  48145. updateOptions(options: ISoundOptions): void;
  48146. private _createSpatialParameters;
  48147. private _updateSpatialParameters;
  48148. /**
  48149. * Switch the panning model to HRTF:
  48150. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48151. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48152. */
  48153. switchPanningModelToHRTF(): void;
  48154. /**
  48155. * Switch the panning model to Equal Power:
  48156. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48157. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48158. */
  48159. switchPanningModelToEqualPower(): void;
  48160. private _switchPanningModel;
  48161. /**
  48162. * Connect this sound to a sound track audio node like gain...
  48163. * @param soundTrackAudioNode the sound track audio node to connect to
  48164. */
  48165. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48166. /**
  48167. * Transform this sound into a directional source
  48168. * @param coneInnerAngle Size of the inner cone in degree
  48169. * @param coneOuterAngle Size of the outer cone in degree
  48170. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48171. */
  48172. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48173. /**
  48174. * Gets or sets the inner angle for the directional cone.
  48175. */
  48176. get directionalConeInnerAngle(): number;
  48177. /**
  48178. * Gets or sets the inner angle for the directional cone.
  48179. */
  48180. set directionalConeInnerAngle(value: number);
  48181. /**
  48182. * Gets or sets the outer angle for the directional cone.
  48183. */
  48184. get directionalConeOuterAngle(): number;
  48185. /**
  48186. * Gets or sets the outer angle for the directional cone.
  48187. */
  48188. set directionalConeOuterAngle(value: number);
  48189. /**
  48190. * Sets the position of the emitter if spatial sound is enabled
  48191. * @param newPosition Defines the new posisiton
  48192. */
  48193. setPosition(newPosition: Vector3): void;
  48194. /**
  48195. * Sets the local direction of the emitter if spatial sound is enabled
  48196. * @param newLocalDirection Defines the new local direction
  48197. */
  48198. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48199. private _updateDirection;
  48200. /** @hidden */
  48201. updateDistanceFromListener(): void;
  48202. /**
  48203. * Sets a new custom attenuation function for the sound.
  48204. * @param callback Defines the function used for the attenuation
  48205. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48206. */
  48207. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48208. /**
  48209. * Play the sound
  48210. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48211. * @param offset (optional) Start the sound at a specific time in seconds
  48212. * @param length (optional) Sound duration (in seconds)
  48213. */
  48214. play(time?: number, offset?: number, length?: number): void;
  48215. private _onended;
  48216. /**
  48217. * Stop the sound
  48218. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48219. */
  48220. stop(time?: number): void;
  48221. /**
  48222. * Put the sound in pause
  48223. */
  48224. pause(): void;
  48225. /**
  48226. * Sets a dedicated volume for this sounds
  48227. * @param newVolume Define the new volume of the sound
  48228. * @param time Define time for gradual change to new volume
  48229. */
  48230. setVolume(newVolume: number, time?: number): void;
  48231. /**
  48232. * Set the sound play back rate
  48233. * @param newPlaybackRate Define the playback rate the sound should be played at
  48234. */
  48235. setPlaybackRate(newPlaybackRate: number): void;
  48236. /**
  48237. * Gets the volume of the sound.
  48238. * @returns the volume of the sound
  48239. */
  48240. getVolume(): number;
  48241. /**
  48242. * Attach the sound to a dedicated mesh
  48243. * @param transformNode The transform node to connect the sound with
  48244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48245. */
  48246. attachToMesh(transformNode: TransformNode): void;
  48247. /**
  48248. * Detach the sound from the previously attached mesh
  48249. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48250. */
  48251. detachFromMesh(): void;
  48252. private _onRegisterAfterWorldMatrixUpdate;
  48253. /**
  48254. * Clone the current sound in the scene.
  48255. * @returns the new sound clone
  48256. */
  48257. clone(): Nullable<Sound>;
  48258. /**
  48259. * Gets the current underlying audio buffer containing the data
  48260. * @returns the audio buffer
  48261. */
  48262. getAudioBuffer(): Nullable<AudioBuffer>;
  48263. /**
  48264. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48265. * @returns the source node
  48266. */
  48267. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48268. /**
  48269. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48270. * @returns the gain node
  48271. */
  48272. getSoundGain(): Nullable<GainNode>;
  48273. /**
  48274. * Serializes the Sound in a JSON representation
  48275. * @returns the JSON representation of the sound
  48276. */
  48277. serialize(): any;
  48278. /**
  48279. * Parse a JSON representation of a sound to innstantiate in a given scene
  48280. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48281. * @param scene Define the scene the new parsed sound should be created in
  48282. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48283. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48284. * @returns the newly parsed sound
  48285. */
  48286. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48287. }
  48288. }
  48289. declare module BABYLON {
  48290. /**
  48291. * This defines an action helpful to play a defined sound on a triggered action.
  48292. */
  48293. export class PlaySoundAction extends Action {
  48294. private _sound;
  48295. /**
  48296. * Instantiate the action
  48297. * @param triggerOptions defines the trigger options
  48298. * @param sound defines the sound to play
  48299. * @param condition defines the trigger related conditions
  48300. */
  48301. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48302. /** @hidden */
  48303. _prepare(): void;
  48304. /**
  48305. * Execute the action and play the sound.
  48306. */
  48307. execute(): void;
  48308. /**
  48309. * Serializes the actions and its related information.
  48310. * @param parent defines the object to serialize in
  48311. * @returns the serialized object
  48312. */
  48313. serialize(parent: any): any;
  48314. }
  48315. /**
  48316. * This defines an action helpful to stop a defined sound on a triggered action.
  48317. */
  48318. export class StopSoundAction extends Action {
  48319. private _sound;
  48320. /**
  48321. * Instantiate the action
  48322. * @param triggerOptions defines the trigger options
  48323. * @param sound defines the sound to stop
  48324. * @param condition defines the trigger related conditions
  48325. */
  48326. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48327. /** @hidden */
  48328. _prepare(): void;
  48329. /**
  48330. * Execute the action and stop the sound.
  48331. */
  48332. execute(): void;
  48333. /**
  48334. * Serializes the actions and its related information.
  48335. * @param parent defines the object to serialize in
  48336. * @returns the serialized object
  48337. */
  48338. serialize(parent: any): any;
  48339. }
  48340. }
  48341. declare module BABYLON {
  48342. /**
  48343. * This defines an action responsible to change the value of a property
  48344. * by interpolating between its current value and the newly set one once triggered.
  48345. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48346. */
  48347. export class InterpolateValueAction extends Action {
  48348. /**
  48349. * Defines the path of the property where the value should be interpolated
  48350. */
  48351. propertyPath: string;
  48352. /**
  48353. * Defines the target value at the end of the interpolation.
  48354. */
  48355. value: any;
  48356. /**
  48357. * Defines the time it will take for the property to interpolate to the value.
  48358. */
  48359. duration: number;
  48360. /**
  48361. * Defines if the other scene animations should be stopped when the action has been triggered
  48362. */
  48363. stopOtherAnimations?: boolean;
  48364. /**
  48365. * Defines a callback raised once the interpolation animation has been done.
  48366. */
  48367. onInterpolationDone?: () => void;
  48368. /**
  48369. * Observable triggered once the interpolation animation has been done.
  48370. */
  48371. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48372. private _target;
  48373. private _effectiveTarget;
  48374. private _property;
  48375. /**
  48376. * Instantiate the action
  48377. * @param triggerOptions defines the trigger options
  48378. * @param target defines the object containing the value to interpolate
  48379. * @param propertyPath defines the path to the property in the target object
  48380. * @param value defines the target value at the end of the interpolation
  48381. * @param duration deines the time it will take for the property to interpolate to the value.
  48382. * @param condition defines the trigger related conditions
  48383. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48384. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48385. */
  48386. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48387. /** @hidden */
  48388. _prepare(): void;
  48389. /**
  48390. * Execute the action starts the value interpolation.
  48391. */
  48392. execute(): void;
  48393. /**
  48394. * Serializes the actions and its related information.
  48395. * @param parent defines the object to serialize in
  48396. * @returns the serialized object
  48397. */
  48398. serialize(parent: any): any;
  48399. }
  48400. }
  48401. declare module BABYLON {
  48402. /**
  48403. * This represents the default audio engine used in babylon.
  48404. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48405. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48406. */
  48407. export class AudioEngine implements IAudioEngine {
  48408. private _audioContext;
  48409. private _audioContextInitialized;
  48410. private _muteButton;
  48411. private _hostElement;
  48412. /**
  48413. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48414. */
  48415. canUseWebAudio: boolean;
  48416. /**
  48417. * The master gain node defines the global audio volume of your audio engine.
  48418. */
  48419. masterGain: GainNode;
  48420. /**
  48421. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48422. * @ignoreNaming
  48423. */
  48424. WarnedWebAudioUnsupported: boolean;
  48425. /**
  48426. * Gets whether or not mp3 are supported by your browser.
  48427. */
  48428. isMP3supported: boolean;
  48429. /**
  48430. * Gets whether or not ogg are supported by your browser.
  48431. */
  48432. isOGGsupported: boolean;
  48433. /**
  48434. * Gets whether audio has been unlocked on the device.
  48435. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48436. * a user interaction has happened.
  48437. */
  48438. unlocked: boolean;
  48439. /**
  48440. * Defines if the audio engine relies on a custom unlocked button.
  48441. * In this case, the embedded button will not be displayed.
  48442. */
  48443. useCustomUnlockedButton: boolean;
  48444. /**
  48445. * Event raised when audio has been unlocked on the browser.
  48446. */
  48447. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48448. /**
  48449. * Event raised when audio has been locked on the browser.
  48450. */
  48451. onAudioLockedObservable: Observable<IAudioEngine>;
  48452. /**
  48453. * Gets the current AudioContext if available.
  48454. */
  48455. get audioContext(): Nullable<AudioContext>;
  48456. private _connectedAnalyser;
  48457. /**
  48458. * Instantiates a new audio engine.
  48459. *
  48460. * There should be only one per page as some browsers restrict the number
  48461. * of audio contexts you can create.
  48462. * @param hostElement defines the host element where to display the mute icon if necessary
  48463. */
  48464. constructor(hostElement?: Nullable<HTMLElement>);
  48465. /**
  48466. * Flags the audio engine in Locked state.
  48467. * This happens due to new browser policies preventing audio to autoplay.
  48468. */
  48469. lock(): void;
  48470. /**
  48471. * Unlocks the audio engine once a user action has been done on the dom.
  48472. * This is helpful to resume play once browser policies have been satisfied.
  48473. */
  48474. unlock(): void;
  48475. private _resumeAudioContext;
  48476. private _initializeAudioContext;
  48477. private _tryToRun;
  48478. private _triggerRunningState;
  48479. private _triggerSuspendedState;
  48480. private _displayMuteButton;
  48481. private _moveButtonToTopLeft;
  48482. private _onResize;
  48483. private _hideMuteButton;
  48484. /**
  48485. * Destroy and release the resources associated with the audio ccontext.
  48486. */
  48487. dispose(): void;
  48488. /**
  48489. * Gets the global volume sets on the master gain.
  48490. * @returns the global volume if set or -1 otherwise
  48491. */
  48492. getGlobalVolume(): number;
  48493. /**
  48494. * Sets the global volume of your experience (sets on the master gain).
  48495. * @param newVolume Defines the new global volume of the application
  48496. */
  48497. setGlobalVolume(newVolume: number): void;
  48498. /**
  48499. * Connect the audio engine to an audio analyser allowing some amazing
  48500. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48501. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48502. * @param analyser The analyser to connect to the engine
  48503. */
  48504. connectToAnalyser(analyser: Analyser): void;
  48505. }
  48506. }
  48507. declare module BABYLON {
  48508. /**
  48509. * Options allowed during the creation of a sound track.
  48510. */
  48511. export interface ISoundTrackOptions {
  48512. /**
  48513. * The volume the sound track should take during creation
  48514. */
  48515. volume?: number;
  48516. /**
  48517. * Define if the sound track is the main sound track of the scene
  48518. */
  48519. mainTrack?: boolean;
  48520. }
  48521. /**
  48522. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48523. * It will be also used in a future release to apply effects on a specific track.
  48524. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48525. */
  48526. export class SoundTrack {
  48527. /**
  48528. * The unique identifier of the sound track in the scene.
  48529. */
  48530. id: number;
  48531. /**
  48532. * The list of sounds included in the sound track.
  48533. */
  48534. soundCollection: Array<Sound>;
  48535. private _outputAudioNode;
  48536. private _scene;
  48537. private _connectedAnalyser;
  48538. private _options;
  48539. private _isInitialized;
  48540. /**
  48541. * Creates a new sound track.
  48542. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48543. * @param scene Define the scene the sound track belongs to
  48544. * @param options
  48545. */
  48546. constructor(scene: Scene, options?: ISoundTrackOptions);
  48547. private _initializeSoundTrackAudioGraph;
  48548. /**
  48549. * Release the sound track and its associated resources
  48550. */
  48551. dispose(): void;
  48552. /**
  48553. * Adds a sound to this sound track
  48554. * @param sound define the cound to add
  48555. * @ignoreNaming
  48556. */
  48557. addSound(sound: Sound): void;
  48558. /**
  48559. * Removes a sound to this sound track
  48560. * @param sound define the cound to remove
  48561. * @ignoreNaming
  48562. */
  48563. removeSound(sound: Sound): void;
  48564. /**
  48565. * Set a global volume for the full sound track.
  48566. * @param newVolume Define the new volume of the sound track
  48567. */
  48568. setVolume(newVolume: number): void;
  48569. /**
  48570. * Switch the panning model to HRTF:
  48571. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48572. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48573. */
  48574. switchPanningModelToHRTF(): void;
  48575. /**
  48576. * Switch the panning model to Equal Power:
  48577. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48579. */
  48580. switchPanningModelToEqualPower(): void;
  48581. /**
  48582. * Connect the sound track to an audio analyser allowing some amazing
  48583. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48584. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48585. * @param analyser The analyser to connect to the engine
  48586. */
  48587. connectToAnalyser(analyser: Analyser): void;
  48588. }
  48589. }
  48590. declare module BABYLON {
  48591. interface AbstractScene {
  48592. /**
  48593. * The list of sounds used in the scene.
  48594. */
  48595. sounds: Nullable<Array<Sound>>;
  48596. }
  48597. interface Scene {
  48598. /**
  48599. * @hidden
  48600. * Backing field
  48601. */
  48602. _mainSoundTrack: SoundTrack;
  48603. /**
  48604. * The main sound track played by the scene.
  48605. * It cotains your primary collection of sounds.
  48606. */
  48607. mainSoundTrack: SoundTrack;
  48608. /**
  48609. * The list of sound tracks added to the scene
  48610. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48611. */
  48612. soundTracks: Nullable<Array<SoundTrack>>;
  48613. /**
  48614. * Gets a sound using a given name
  48615. * @param name defines the name to search for
  48616. * @return the found sound or null if not found at all.
  48617. */
  48618. getSoundByName(name: string): Nullable<Sound>;
  48619. /**
  48620. * Gets or sets if audio support is enabled
  48621. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48622. */
  48623. audioEnabled: boolean;
  48624. /**
  48625. * Gets or sets if audio will be output to headphones
  48626. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48627. */
  48628. headphone: boolean;
  48629. /**
  48630. * Gets or sets custom audio listener position provider
  48631. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48632. */
  48633. audioListenerPositionProvider: Nullable<() => Vector3>;
  48634. /**
  48635. * Gets or sets a refresh rate when using 3D audio positioning
  48636. */
  48637. audioPositioningRefreshRate: number;
  48638. }
  48639. /**
  48640. * Defines the sound scene component responsible to manage any sounds
  48641. * in a given scene.
  48642. */
  48643. export class AudioSceneComponent implements ISceneSerializableComponent {
  48644. private static _CameraDirectionLH;
  48645. private static _CameraDirectionRH;
  48646. /**
  48647. * The component name helpfull to identify the component in the list of scene components.
  48648. */
  48649. readonly name: string;
  48650. /**
  48651. * The scene the component belongs to.
  48652. */
  48653. scene: Scene;
  48654. private _audioEnabled;
  48655. /**
  48656. * Gets whether audio is enabled or not.
  48657. * Please use related enable/disable method to switch state.
  48658. */
  48659. get audioEnabled(): boolean;
  48660. private _headphone;
  48661. /**
  48662. * Gets whether audio is outputing to headphone or not.
  48663. * Please use the according Switch methods to change output.
  48664. */
  48665. get headphone(): boolean;
  48666. /**
  48667. * Gets or sets a refresh rate when using 3D audio positioning
  48668. */
  48669. audioPositioningRefreshRate: number;
  48670. private _audioListenerPositionProvider;
  48671. /**
  48672. * Gets the current audio listener position provider
  48673. */
  48674. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48675. /**
  48676. * Sets a custom listener position for all sounds in the scene
  48677. * By default, this is the position of the first active camera
  48678. */
  48679. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48680. /**
  48681. * Creates a new instance of the component for the given scene
  48682. * @param scene Defines the scene to register the component in
  48683. */
  48684. constructor(scene: Scene);
  48685. /**
  48686. * Registers the component in a given scene
  48687. */
  48688. register(): void;
  48689. /**
  48690. * Rebuilds the elements related to this component in case of
  48691. * context lost for instance.
  48692. */
  48693. rebuild(): void;
  48694. /**
  48695. * Serializes the component data to the specified json object
  48696. * @param serializationObject The object to serialize to
  48697. */
  48698. serialize(serializationObject: any): void;
  48699. /**
  48700. * Adds all the elements from the container to the scene
  48701. * @param container the container holding the elements
  48702. */
  48703. addFromContainer(container: AbstractScene): void;
  48704. /**
  48705. * Removes all the elements in the container from the scene
  48706. * @param container contains the elements to remove
  48707. * @param dispose if the removed element should be disposed (default: false)
  48708. */
  48709. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48710. /**
  48711. * Disposes the component and the associated ressources.
  48712. */
  48713. dispose(): void;
  48714. /**
  48715. * Disables audio in the associated scene.
  48716. */
  48717. disableAudio(): void;
  48718. /**
  48719. * Enables audio in the associated scene.
  48720. */
  48721. enableAudio(): void;
  48722. /**
  48723. * Switch audio to headphone output.
  48724. */
  48725. switchAudioModeForHeadphones(): void;
  48726. /**
  48727. * Switch audio to normal speakers.
  48728. */
  48729. switchAudioModeForNormalSpeakers(): void;
  48730. private _cachedCameraDirection;
  48731. private _cachedCameraPosition;
  48732. private _lastCheck;
  48733. private _afterRender;
  48734. }
  48735. }
  48736. declare module BABYLON {
  48737. /**
  48738. * Wraps one or more Sound objects and selects one with random weight for playback.
  48739. */
  48740. export class WeightedSound {
  48741. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48742. loop: boolean;
  48743. private _coneInnerAngle;
  48744. private _coneOuterAngle;
  48745. private _volume;
  48746. /** A Sound is currently playing. */
  48747. isPlaying: boolean;
  48748. /** A Sound is currently paused. */
  48749. isPaused: boolean;
  48750. private _sounds;
  48751. private _weights;
  48752. private _currentIndex?;
  48753. /**
  48754. * Creates a new WeightedSound from the list of sounds given.
  48755. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48756. * @param sounds Array of Sounds that will be selected from.
  48757. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48758. */
  48759. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48760. /**
  48761. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48762. */
  48763. get directionalConeInnerAngle(): number;
  48764. /**
  48765. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48766. */
  48767. set directionalConeInnerAngle(value: number);
  48768. /**
  48769. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48770. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48771. */
  48772. get directionalConeOuterAngle(): number;
  48773. /**
  48774. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48775. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48776. */
  48777. set directionalConeOuterAngle(value: number);
  48778. /**
  48779. * Playback volume.
  48780. */
  48781. get volume(): number;
  48782. /**
  48783. * Playback volume.
  48784. */
  48785. set volume(value: number);
  48786. private _onended;
  48787. /**
  48788. * Suspend playback
  48789. */
  48790. pause(): void;
  48791. /**
  48792. * Stop playback
  48793. */
  48794. stop(): void;
  48795. /**
  48796. * Start playback.
  48797. * @param startOffset Position the clip head at a specific time in seconds.
  48798. */
  48799. play(startOffset?: number): void;
  48800. }
  48801. }
  48802. declare module BABYLON {
  48803. /**
  48804. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48805. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48806. */
  48807. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48808. /**
  48809. * Gets the name of the behavior.
  48810. */
  48811. get name(): string;
  48812. /**
  48813. * The easing function used by animations
  48814. */
  48815. static EasingFunction: BackEase;
  48816. /**
  48817. * The easing mode used by animations
  48818. */
  48819. static EasingMode: number;
  48820. /**
  48821. * The duration of the animation, in milliseconds
  48822. */
  48823. transitionDuration: number;
  48824. /**
  48825. * Length of the distance animated by the transition when lower radius is reached
  48826. */
  48827. lowerRadiusTransitionRange: number;
  48828. /**
  48829. * Length of the distance animated by the transition when upper radius is reached
  48830. */
  48831. upperRadiusTransitionRange: number;
  48832. private _autoTransitionRange;
  48833. /**
  48834. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48835. */
  48836. get autoTransitionRange(): boolean;
  48837. /**
  48838. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48839. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48840. */
  48841. set autoTransitionRange(value: boolean);
  48842. private _attachedCamera;
  48843. private _onAfterCheckInputsObserver;
  48844. private _onMeshTargetChangedObserver;
  48845. /**
  48846. * Initializes the behavior.
  48847. */
  48848. init(): void;
  48849. /**
  48850. * Attaches the behavior to its arc rotate camera.
  48851. * @param camera Defines the camera to attach the behavior to
  48852. */
  48853. attach(camera: ArcRotateCamera): void;
  48854. /**
  48855. * Detaches the behavior from its current arc rotate camera.
  48856. */
  48857. detach(): void;
  48858. private _radiusIsAnimating;
  48859. private _radiusBounceTransition;
  48860. private _animatables;
  48861. private _cachedWheelPrecision;
  48862. /**
  48863. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48864. * @param radiusLimit The limit to check against.
  48865. * @return Bool to indicate if at limit.
  48866. */
  48867. private _isRadiusAtLimit;
  48868. /**
  48869. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48870. * @param radiusDelta The delta by which to animate to. Can be negative.
  48871. */
  48872. private _applyBoundRadiusAnimation;
  48873. /**
  48874. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48875. */
  48876. protected _clearAnimationLocks(): void;
  48877. /**
  48878. * Stops and removes all animations that have been applied to the camera
  48879. */
  48880. stopAllAnimations(): void;
  48881. }
  48882. }
  48883. declare module BABYLON {
  48884. /**
  48885. * 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.
  48886. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48887. */
  48888. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48889. /**
  48890. * Gets the name of the behavior.
  48891. */
  48892. get name(): string;
  48893. private _mode;
  48894. private _radiusScale;
  48895. private _positionScale;
  48896. private _defaultElevation;
  48897. private _elevationReturnTime;
  48898. private _elevationReturnWaitTime;
  48899. private _zoomStopsAnimation;
  48900. private _framingTime;
  48901. /**
  48902. * The easing function used by animations
  48903. */
  48904. static EasingFunction: ExponentialEase;
  48905. /**
  48906. * The easing mode used by animations
  48907. */
  48908. static EasingMode: number;
  48909. /**
  48910. * Sets the current mode used by the behavior
  48911. */
  48912. set mode(mode: number);
  48913. /**
  48914. * Gets current mode used by the behavior.
  48915. */
  48916. get mode(): number;
  48917. /**
  48918. * Sets the scale applied to the radius (1 by default)
  48919. */
  48920. set radiusScale(radius: number);
  48921. /**
  48922. * Gets the scale applied to the radius
  48923. */
  48924. get radiusScale(): number;
  48925. /**
  48926. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48927. */
  48928. set positionScale(scale: number);
  48929. /**
  48930. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48931. */
  48932. get positionScale(): number;
  48933. /**
  48934. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48935. * behaviour is triggered, in radians.
  48936. */
  48937. set defaultElevation(elevation: number);
  48938. /**
  48939. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48940. * behaviour is triggered, in radians.
  48941. */
  48942. get defaultElevation(): number;
  48943. /**
  48944. * Sets the time (in milliseconds) taken to return to the default beta position.
  48945. * Negative value indicates camera should not return to default.
  48946. */
  48947. set elevationReturnTime(speed: number);
  48948. /**
  48949. * Gets the time (in milliseconds) taken to return to the default beta position.
  48950. * Negative value indicates camera should not return to default.
  48951. */
  48952. get elevationReturnTime(): number;
  48953. /**
  48954. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48955. */
  48956. set elevationReturnWaitTime(time: number);
  48957. /**
  48958. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48959. */
  48960. get elevationReturnWaitTime(): number;
  48961. /**
  48962. * Sets the flag that indicates if user zooming should stop animation.
  48963. */
  48964. set zoomStopsAnimation(flag: boolean);
  48965. /**
  48966. * Gets the flag that indicates if user zooming should stop animation.
  48967. */
  48968. get zoomStopsAnimation(): boolean;
  48969. /**
  48970. * Sets the transition time when framing the mesh, in milliseconds
  48971. */
  48972. set framingTime(time: number);
  48973. /**
  48974. * Gets the transition time when framing the mesh, in milliseconds
  48975. */
  48976. get framingTime(): number;
  48977. /**
  48978. * Define if the behavior should automatically change the configured
  48979. * camera limits and sensibilities.
  48980. */
  48981. autoCorrectCameraLimitsAndSensibility: boolean;
  48982. private _onPrePointerObservableObserver;
  48983. private _onAfterCheckInputsObserver;
  48984. private _onMeshTargetChangedObserver;
  48985. private _attachedCamera;
  48986. private _isPointerDown;
  48987. private _lastInteractionTime;
  48988. /**
  48989. * Initializes the behavior.
  48990. */
  48991. init(): void;
  48992. /**
  48993. * Attaches the behavior to its arc rotate camera.
  48994. * @param camera Defines the camera to attach the behavior to
  48995. */
  48996. attach(camera: ArcRotateCamera): void;
  48997. /**
  48998. * Detaches the behavior from its current arc rotate camera.
  48999. */
  49000. detach(): void;
  49001. private _animatables;
  49002. private _betaIsAnimating;
  49003. private _betaTransition;
  49004. private _radiusTransition;
  49005. private _vectorTransition;
  49006. /**
  49007. * Targets the given mesh and updates zoom level accordingly.
  49008. * @param mesh The mesh to target.
  49009. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49010. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49011. */
  49012. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49013. /**
  49014. * Targets the given mesh with its children and updates zoom level accordingly.
  49015. * @param mesh The mesh to target.
  49016. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49017. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49018. */
  49019. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49020. /**
  49021. * Targets the given meshes with their children and updates zoom level accordingly.
  49022. * @param meshes The mesh to target.
  49023. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49024. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49025. */
  49026. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49027. /**
  49028. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49029. * @param minimumWorld Determines the smaller position of the bounding box extend
  49030. * @param maximumWorld Determines the bigger position of the bounding box extend
  49031. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49032. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49033. */
  49034. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49035. /**
  49036. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49037. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49038. * frustum width.
  49039. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49040. * to fully enclose the mesh in the viewing frustum.
  49041. */
  49042. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49043. /**
  49044. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49045. * is automatically returned to its default position (expected to be above ground plane).
  49046. */
  49047. private _maintainCameraAboveGround;
  49048. /**
  49049. * Returns the frustum slope based on the canvas ratio and camera FOV
  49050. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49051. */
  49052. private _getFrustumSlope;
  49053. /**
  49054. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49055. */
  49056. private _clearAnimationLocks;
  49057. /**
  49058. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49059. */
  49060. private _applyUserInteraction;
  49061. /**
  49062. * Stops and removes all animations that have been applied to the camera
  49063. */
  49064. stopAllAnimations(): void;
  49065. /**
  49066. * Gets a value indicating if the user is moving the camera
  49067. */
  49068. get isUserIsMoving(): boolean;
  49069. /**
  49070. * The camera can move all the way towards the mesh.
  49071. */
  49072. static IgnoreBoundsSizeMode: number;
  49073. /**
  49074. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49075. */
  49076. static FitFrustumSidesMode: number;
  49077. }
  49078. }
  49079. declare module BABYLON {
  49080. /**
  49081. * Base class for Camera Pointer Inputs.
  49082. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49083. * for example usage.
  49084. */
  49085. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49086. /**
  49087. * Defines the camera the input is attached to.
  49088. */
  49089. abstract camera: Camera;
  49090. /**
  49091. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49092. */
  49093. protected _altKey: boolean;
  49094. protected _ctrlKey: boolean;
  49095. protected _metaKey: boolean;
  49096. protected _shiftKey: boolean;
  49097. /**
  49098. * Which mouse buttons were pressed at time of last mouse event.
  49099. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49100. */
  49101. protected _buttonsPressed: number;
  49102. /**
  49103. * Defines the buttons associated with the input to handle camera move.
  49104. */
  49105. buttons: number[];
  49106. /**
  49107. * Attach the input controls to a specific dom element to get the input from.
  49108. * @param element Defines the element the controls should be listened from
  49109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49110. */
  49111. attachControl(noPreventDefault?: boolean): void;
  49112. /**
  49113. * Detach the current controls from the specified dom element.
  49114. */
  49115. detachControl(): void;
  49116. /**
  49117. * Gets the class name of the current input.
  49118. * @returns the class name
  49119. */
  49120. getClassName(): string;
  49121. /**
  49122. * Get the friendly name associated with the input class.
  49123. * @returns the input friendly name
  49124. */
  49125. getSimpleName(): string;
  49126. /**
  49127. * Called on pointer POINTERDOUBLETAP event.
  49128. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49129. */
  49130. protected onDoubleTap(type: string): void;
  49131. /**
  49132. * Called on pointer POINTERMOVE event if only a single touch is active.
  49133. * Override this method to provide functionality.
  49134. */
  49135. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49136. /**
  49137. * Called on pointer POINTERMOVE event if multiple touches are active.
  49138. * Override this method to provide functionality.
  49139. */
  49140. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49141. /**
  49142. * Called on JS contextmenu event.
  49143. * Override this method to provide functionality.
  49144. */
  49145. protected onContextMenu(evt: PointerEvent): void;
  49146. /**
  49147. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49148. * press.
  49149. * Override this method to provide functionality.
  49150. */
  49151. protected onButtonDown(evt: PointerEvent): void;
  49152. /**
  49153. * Called each time a new POINTERUP event occurs. Ie, for each button
  49154. * release.
  49155. * Override this method to provide functionality.
  49156. */
  49157. protected onButtonUp(evt: PointerEvent): void;
  49158. /**
  49159. * Called when window becomes inactive.
  49160. * Override this method to provide functionality.
  49161. */
  49162. protected onLostFocus(): void;
  49163. private _pointerInput;
  49164. private _observer;
  49165. private _onLostFocus;
  49166. private pointA;
  49167. private pointB;
  49168. }
  49169. }
  49170. declare module BABYLON {
  49171. /**
  49172. * Manage the pointers inputs to control an arc rotate camera.
  49173. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49174. */
  49175. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49176. /**
  49177. * Defines the camera the input is attached to.
  49178. */
  49179. camera: ArcRotateCamera;
  49180. /**
  49181. * Gets the class name of the current input.
  49182. * @returns the class name
  49183. */
  49184. getClassName(): string;
  49185. /**
  49186. * Defines the buttons associated with the input to handle camera move.
  49187. */
  49188. buttons: number[];
  49189. /**
  49190. * Defines the pointer angular sensibility along the X axis or how fast is
  49191. * the camera rotating.
  49192. */
  49193. angularSensibilityX: number;
  49194. /**
  49195. * Defines the pointer angular sensibility along the Y axis or how fast is
  49196. * the camera rotating.
  49197. */
  49198. angularSensibilityY: number;
  49199. /**
  49200. * Defines the pointer pinch precision or how fast is the camera zooming.
  49201. */
  49202. pinchPrecision: number;
  49203. /**
  49204. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49205. * from 0.
  49206. * It defines the percentage of current camera.radius to use as delta when
  49207. * pinch zoom is used.
  49208. */
  49209. pinchDeltaPercentage: number;
  49210. /**
  49211. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49212. * that any object in the plane at the camera's target point will scale
  49213. * perfectly with finger motion.
  49214. * Overrides pinchDeltaPercentage and pinchPrecision.
  49215. */
  49216. useNaturalPinchZoom: boolean;
  49217. /**
  49218. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49219. */
  49220. pinchZoom: boolean;
  49221. /**
  49222. * Defines the pointer panning sensibility or how fast is the camera moving.
  49223. */
  49224. panningSensibility: number;
  49225. /**
  49226. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49227. */
  49228. multiTouchPanning: boolean;
  49229. /**
  49230. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49231. * zoom (pinch) through multitouch.
  49232. */
  49233. multiTouchPanAndZoom: boolean;
  49234. /**
  49235. * Revers pinch action direction.
  49236. */
  49237. pinchInwards: boolean;
  49238. private _isPanClick;
  49239. private _twoFingerActivityCount;
  49240. private _isPinching;
  49241. /**
  49242. * Move camera from multi touch panning positions.
  49243. */
  49244. private _computeMultiTouchPanning;
  49245. /**
  49246. * Move camera from pinch zoom distances.
  49247. */
  49248. private _computePinchZoom;
  49249. /**
  49250. * Called on pointer POINTERMOVE event if only a single touch is active.
  49251. */
  49252. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49253. /**
  49254. * Called on pointer POINTERDOUBLETAP event.
  49255. */
  49256. protected onDoubleTap(type: string): void;
  49257. /**
  49258. * Called on pointer POINTERMOVE event if multiple touches are active.
  49259. */
  49260. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49261. /**
  49262. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49263. * press.
  49264. */
  49265. protected onButtonDown(evt: PointerEvent): void;
  49266. /**
  49267. * Called each time a new POINTERUP event occurs. Ie, for each button
  49268. * release.
  49269. */
  49270. protected onButtonUp(evt: PointerEvent): void;
  49271. /**
  49272. * Called when window becomes inactive.
  49273. */
  49274. protected onLostFocus(): void;
  49275. }
  49276. }
  49277. declare module BABYLON {
  49278. /**
  49279. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49280. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49281. */
  49282. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49283. /**
  49284. * Defines the camera the input is attached to.
  49285. */
  49286. camera: ArcRotateCamera;
  49287. /**
  49288. * Defines the list of key codes associated with the up action (increase alpha)
  49289. */
  49290. keysUp: number[];
  49291. /**
  49292. * Defines the list of key codes associated with the down action (decrease alpha)
  49293. */
  49294. keysDown: number[];
  49295. /**
  49296. * Defines the list of key codes associated with the left action (increase beta)
  49297. */
  49298. keysLeft: number[];
  49299. /**
  49300. * Defines the list of key codes associated with the right action (decrease beta)
  49301. */
  49302. keysRight: number[];
  49303. /**
  49304. * Defines the list of key codes associated with the reset action.
  49305. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49306. */
  49307. keysReset: number[];
  49308. /**
  49309. * Defines the panning sensibility of the inputs.
  49310. * (How fast is the camera panning)
  49311. */
  49312. panningSensibility: number;
  49313. /**
  49314. * Defines the zooming sensibility of the inputs.
  49315. * (How fast is the camera zooming)
  49316. */
  49317. zoomingSensibility: number;
  49318. /**
  49319. * Defines whether maintaining the alt key down switch the movement mode from
  49320. * orientation to zoom.
  49321. */
  49322. useAltToZoom: boolean;
  49323. /**
  49324. * Rotation speed of the camera
  49325. */
  49326. angularSpeed: number;
  49327. private _keys;
  49328. private _ctrlPressed;
  49329. private _altPressed;
  49330. private _onCanvasBlurObserver;
  49331. private _onKeyboardObserver;
  49332. private _engine;
  49333. private _scene;
  49334. /**
  49335. * Attach the input controls to a specific dom element to get the input from.
  49336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49337. */
  49338. attachControl(noPreventDefault?: boolean): void;
  49339. /**
  49340. * Detach the current controls from the specified dom element.
  49341. */
  49342. detachControl(): void;
  49343. /**
  49344. * Update the current camera state depending on the inputs that have been used this frame.
  49345. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49346. */
  49347. checkInputs(): void;
  49348. /**
  49349. * Gets the class name of the current intput.
  49350. * @returns the class name
  49351. */
  49352. getClassName(): string;
  49353. /**
  49354. * Get the friendly name associated with the input class.
  49355. * @returns the input friendly name
  49356. */
  49357. getSimpleName(): string;
  49358. }
  49359. }
  49360. declare module BABYLON {
  49361. /**
  49362. * Manage the mouse wheel inputs to control an arc rotate camera.
  49363. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49364. */
  49365. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49366. /**
  49367. * Defines the camera the input is attached to.
  49368. */
  49369. camera: ArcRotateCamera;
  49370. /**
  49371. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49372. */
  49373. wheelPrecision: number;
  49374. /**
  49375. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49376. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49377. */
  49378. wheelDeltaPercentage: number;
  49379. private _wheel;
  49380. private _observer;
  49381. private computeDeltaFromMouseWheelLegacyEvent;
  49382. /**
  49383. * Attach the input controls to a specific dom element to get the input from.
  49384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49385. */
  49386. attachControl(noPreventDefault?: boolean): void;
  49387. /**
  49388. * Detach the current controls from the specified dom element.
  49389. */
  49390. detachControl(): void;
  49391. /**
  49392. * Gets the class name of the current intput.
  49393. * @returns the class name
  49394. */
  49395. getClassName(): string;
  49396. /**
  49397. * Get the friendly name associated with the input class.
  49398. * @returns the input friendly name
  49399. */
  49400. getSimpleName(): string;
  49401. }
  49402. }
  49403. declare module BABYLON {
  49404. /**
  49405. * Default Inputs manager for the ArcRotateCamera.
  49406. * It groups all the default supported inputs for ease of use.
  49407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49408. */
  49409. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49410. /**
  49411. * Instantiates a new ArcRotateCameraInputsManager.
  49412. * @param camera Defines the camera the inputs belong to
  49413. */
  49414. constructor(camera: ArcRotateCamera);
  49415. /**
  49416. * Add mouse wheel input support to the input manager.
  49417. * @returns the current input manager
  49418. */
  49419. addMouseWheel(): ArcRotateCameraInputsManager;
  49420. /**
  49421. * Add pointers input support to the input manager.
  49422. * @returns the current input manager
  49423. */
  49424. addPointers(): ArcRotateCameraInputsManager;
  49425. /**
  49426. * Add keyboard input support to the input manager.
  49427. * @returns the current input manager
  49428. */
  49429. addKeyboard(): ArcRotateCameraInputsManager;
  49430. }
  49431. }
  49432. declare module BABYLON {
  49433. /**
  49434. * This represents an orbital type of camera.
  49435. *
  49436. * 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.
  49437. * 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.
  49438. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49439. */
  49440. export class ArcRotateCamera extends TargetCamera {
  49441. /**
  49442. * Defines the rotation angle of the camera along the longitudinal axis.
  49443. */
  49444. alpha: number;
  49445. /**
  49446. * Defines the rotation angle of the camera along the latitudinal axis.
  49447. */
  49448. beta: number;
  49449. /**
  49450. * Defines the radius of the camera from it s target point.
  49451. */
  49452. radius: number;
  49453. protected _target: Vector3;
  49454. protected _targetHost: Nullable<AbstractMesh>;
  49455. /**
  49456. * Defines the target point of the camera.
  49457. * The camera looks towards it form the radius distance.
  49458. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49459. */
  49460. get target(): Vector3;
  49461. set target(value: Vector3);
  49462. /**
  49463. * Define the current local position of the camera in the scene
  49464. */
  49465. get position(): Vector3;
  49466. set position(newPosition: Vector3);
  49467. protected _upToYMatrix: Matrix;
  49468. protected _YToUpMatrix: Matrix;
  49469. /**
  49470. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49471. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49472. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49473. */
  49474. set upVector(vec: Vector3);
  49475. get upVector(): Vector3;
  49476. /**
  49477. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49478. */
  49479. setMatUp(): void;
  49480. /**
  49481. * Current inertia value on the longitudinal axis.
  49482. * The bigger this number the longer it will take for the camera to stop.
  49483. */
  49484. inertialAlphaOffset: number;
  49485. /**
  49486. * Current inertia value on the latitudinal axis.
  49487. * The bigger this number the longer it will take for the camera to stop.
  49488. */
  49489. inertialBetaOffset: number;
  49490. /**
  49491. * Current inertia value on the radius axis.
  49492. * The bigger this number the longer it will take for the camera to stop.
  49493. */
  49494. inertialRadiusOffset: number;
  49495. /**
  49496. * Minimum allowed angle on the longitudinal axis.
  49497. * This can help limiting how the Camera is able to move in the scene.
  49498. */
  49499. lowerAlphaLimit: Nullable<number>;
  49500. /**
  49501. * Maximum allowed angle on the longitudinal axis.
  49502. * This can help limiting how the Camera is able to move in the scene.
  49503. */
  49504. upperAlphaLimit: Nullable<number>;
  49505. /**
  49506. * Minimum allowed angle on the latitudinal axis.
  49507. * This can help limiting how the Camera is able to move in the scene.
  49508. */
  49509. lowerBetaLimit: number;
  49510. /**
  49511. * Maximum allowed angle on the latitudinal axis.
  49512. * This can help limiting how the Camera is able to move in the scene.
  49513. */
  49514. upperBetaLimit: number;
  49515. /**
  49516. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49517. * This can help limiting how the Camera is able to move in the scene.
  49518. */
  49519. lowerRadiusLimit: Nullable<number>;
  49520. /**
  49521. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49522. * This can help limiting how the Camera is able to move in the scene.
  49523. */
  49524. upperRadiusLimit: Nullable<number>;
  49525. /**
  49526. * Defines the current inertia value used during panning of the camera along the X axis.
  49527. */
  49528. inertialPanningX: number;
  49529. /**
  49530. * Defines the current inertia value used during panning of the camera along the Y axis.
  49531. */
  49532. inertialPanningY: number;
  49533. /**
  49534. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49535. * Basically if your fingers moves away from more than this distance you will be considered
  49536. * in pinch mode.
  49537. */
  49538. pinchToPanMaxDistance: number;
  49539. /**
  49540. * Defines the maximum distance the camera can pan.
  49541. * This could help keeping the cammera always in your scene.
  49542. */
  49543. panningDistanceLimit: Nullable<number>;
  49544. /**
  49545. * Defines the target of the camera before paning.
  49546. */
  49547. panningOriginTarget: Vector3;
  49548. /**
  49549. * Defines the value of the inertia used during panning.
  49550. * 0 would mean stop inertia and one would mean no decelleration at all.
  49551. */
  49552. panningInertia: number;
  49553. /**
  49554. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49555. */
  49556. get angularSensibilityX(): number;
  49557. set angularSensibilityX(value: number);
  49558. /**
  49559. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49560. */
  49561. get angularSensibilityY(): number;
  49562. set angularSensibilityY(value: number);
  49563. /**
  49564. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49565. */
  49566. get pinchPrecision(): number;
  49567. set pinchPrecision(value: number);
  49568. /**
  49569. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49570. * It will be used instead of pinchDeltaPrecision if different from 0.
  49571. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49572. */
  49573. get pinchDeltaPercentage(): number;
  49574. set pinchDeltaPercentage(value: number);
  49575. /**
  49576. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49577. * and pinch delta percentage.
  49578. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49579. * that any object in the plane at the camera's target point will scale
  49580. * perfectly with finger motion.
  49581. */
  49582. get useNaturalPinchZoom(): boolean;
  49583. set useNaturalPinchZoom(value: boolean);
  49584. /**
  49585. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49586. */
  49587. get panningSensibility(): number;
  49588. set panningSensibility(value: number);
  49589. /**
  49590. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49591. */
  49592. get keysUp(): number[];
  49593. set keysUp(value: number[]);
  49594. /**
  49595. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49596. */
  49597. get keysDown(): number[];
  49598. set keysDown(value: number[]);
  49599. /**
  49600. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49601. */
  49602. get keysLeft(): number[];
  49603. set keysLeft(value: number[]);
  49604. /**
  49605. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49606. */
  49607. get keysRight(): number[];
  49608. set keysRight(value: number[]);
  49609. /**
  49610. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49611. */
  49612. get wheelPrecision(): number;
  49613. set wheelPrecision(value: number);
  49614. /**
  49615. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49616. * It will be used instead of pinchDeltaPrecision if different from 0.
  49617. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49618. */
  49619. get wheelDeltaPercentage(): number;
  49620. set wheelDeltaPercentage(value: number);
  49621. /**
  49622. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49623. */
  49624. zoomOnFactor: number;
  49625. /**
  49626. * Defines a screen offset for the camera position.
  49627. */
  49628. targetScreenOffset: Vector2;
  49629. /**
  49630. * Allows the camera to be completely reversed.
  49631. * If false the camera can not arrive upside down.
  49632. */
  49633. allowUpsideDown: boolean;
  49634. /**
  49635. * Define if double tap/click is used to restore the previously saved state of the camera.
  49636. */
  49637. useInputToRestoreState: boolean;
  49638. /** @hidden */
  49639. _viewMatrix: Matrix;
  49640. /** @hidden */
  49641. _useCtrlForPanning: boolean;
  49642. /** @hidden */
  49643. _panningMouseButton: number;
  49644. /**
  49645. * Defines the input associated to the camera.
  49646. */
  49647. inputs: ArcRotateCameraInputsManager;
  49648. /** @hidden */
  49649. _reset: () => void;
  49650. /**
  49651. * Defines the allowed panning axis.
  49652. */
  49653. panningAxis: Vector3;
  49654. protected _transformedDirection: Vector3;
  49655. private _bouncingBehavior;
  49656. /**
  49657. * Gets the bouncing behavior of the camera if it has been enabled.
  49658. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49659. */
  49660. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49661. /**
  49662. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49663. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49664. */
  49665. get useBouncingBehavior(): boolean;
  49666. set useBouncingBehavior(value: boolean);
  49667. private _framingBehavior;
  49668. /**
  49669. * Gets the framing behavior of the camera if it has been enabled.
  49670. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49671. */
  49672. get framingBehavior(): Nullable<FramingBehavior>;
  49673. /**
  49674. * Defines if the framing behavior of the camera is enabled on the camera.
  49675. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49676. */
  49677. get useFramingBehavior(): boolean;
  49678. set useFramingBehavior(value: boolean);
  49679. private _autoRotationBehavior;
  49680. /**
  49681. * Gets the auto rotation behavior of the camera if it has been enabled.
  49682. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49683. */
  49684. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49685. /**
  49686. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49687. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49688. */
  49689. get useAutoRotationBehavior(): boolean;
  49690. set useAutoRotationBehavior(value: boolean);
  49691. /**
  49692. * Observable triggered when the mesh target has been changed on the camera.
  49693. */
  49694. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49695. /**
  49696. * Event raised when the camera is colliding with a mesh.
  49697. */
  49698. onCollide: (collidedMesh: AbstractMesh) => void;
  49699. /**
  49700. * Defines whether the camera should check collision with the objects oh the scene.
  49701. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49702. */
  49703. checkCollisions: boolean;
  49704. /**
  49705. * Defines the collision radius of the camera.
  49706. * This simulates a sphere around the camera.
  49707. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49708. */
  49709. collisionRadius: Vector3;
  49710. protected _collider: Collider;
  49711. protected _previousPosition: Vector3;
  49712. protected _collisionVelocity: Vector3;
  49713. protected _newPosition: Vector3;
  49714. protected _previousAlpha: number;
  49715. protected _previousBeta: number;
  49716. protected _previousRadius: number;
  49717. protected _collisionTriggered: boolean;
  49718. protected _targetBoundingCenter: Nullable<Vector3>;
  49719. private _computationVector;
  49720. /**
  49721. * Instantiates a new ArcRotateCamera in a given scene
  49722. * @param name Defines the name of the camera
  49723. * @param alpha Defines the camera rotation along the logitudinal axis
  49724. * @param beta Defines the camera rotation along the latitudinal axis
  49725. * @param radius Defines the camera distance from its target
  49726. * @param target Defines the camera target
  49727. * @param scene Defines the scene the camera belongs to
  49728. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49729. */
  49730. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49731. /** @hidden */
  49732. _initCache(): void;
  49733. /** @hidden */
  49734. _updateCache(ignoreParentClass?: boolean): void;
  49735. protected _getTargetPosition(): Vector3;
  49736. private _storedAlpha;
  49737. private _storedBeta;
  49738. private _storedRadius;
  49739. private _storedTarget;
  49740. private _storedTargetScreenOffset;
  49741. /**
  49742. * Stores the current state of the camera (alpha, beta, radius and target)
  49743. * @returns the camera itself
  49744. */
  49745. storeState(): Camera;
  49746. /**
  49747. * @hidden
  49748. * Restored camera state. You must call storeState() first
  49749. */
  49750. _restoreStateValues(): boolean;
  49751. /** @hidden */
  49752. _isSynchronizedViewMatrix(): boolean;
  49753. /**
  49754. * Attach the input controls to a specific dom element to get the input from.
  49755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49756. */
  49757. attachControl(noPreventDefault?: boolean): void;
  49758. /**
  49759. * Attach the input controls to a specific dom element to get the input from.
  49760. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  49761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49762. */
  49763. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49764. /**
  49765. * Attached controls to the current camera.
  49766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49767. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49768. */
  49769. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49770. /**
  49771. * Attached controls to the current camera.
  49772. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  49773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49774. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49775. */
  49776. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49777. /**
  49778. * Attached controls to the current camera.
  49779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49780. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49781. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49782. */
  49783. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49784. /**
  49785. * Detach the current controls from the specified dom element.
  49786. */
  49787. detachControl(): void;
  49788. /**
  49789. * Detach the current controls from the specified dom element.
  49790. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  49791. */
  49792. detachControl(ignored: any): void;
  49793. /** @hidden */
  49794. _checkInputs(): void;
  49795. protected _checkLimits(): void;
  49796. /**
  49797. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49798. */
  49799. rebuildAnglesAndRadius(): void;
  49800. /**
  49801. * Use a position to define the current camera related information like alpha, beta and radius
  49802. * @param position Defines the position to set the camera at
  49803. */
  49804. setPosition(position: Vector3): void;
  49805. /**
  49806. * Defines the target the camera should look at.
  49807. * This will automatically adapt alpha beta and radius to fit within the new target.
  49808. * @param target Defines the new target as a Vector or a mesh
  49809. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49810. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49811. */
  49812. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49813. /** @hidden */
  49814. _getViewMatrix(): Matrix;
  49815. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49816. /**
  49817. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49818. * @param meshes Defines the mesh to zoom on
  49819. * @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)
  49820. */
  49821. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49822. /**
  49823. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49824. * The target will be changed but the radius
  49825. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49826. * @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)
  49827. */
  49828. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49829. min: Vector3;
  49830. max: Vector3;
  49831. distance: number;
  49832. }, doNotUpdateMaxZ?: boolean): void;
  49833. /**
  49834. * @override
  49835. * Override Camera.createRigCamera
  49836. */
  49837. createRigCamera(name: string, cameraIndex: number): Camera;
  49838. /**
  49839. * @hidden
  49840. * @override
  49841. * Override Camera._updateRigCameras
  49842. */
  49843. _updateRigCameras(): void;
  49844. /**
  49845. * Destroy the camera and release the current resources hold by it.
  49846. */
  49847. dispose(): void;
  49848. /**
  49849. * Gets the current object class name.
  49850. * @return the class name
  49851. */
  49852. getClassName(): string;
  49853. }
  49854. }
  49855. declare module BABYLON {
  49856. /**
  49857. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49858. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49859. */
  49860. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49861. /**
  49862. * Gets the name of the behavior.
  49863. */
  49864. get name(): string;
  49865. private _zoomStopsAnimation;
  49866. private _idleRotationSpeed;
  49867. private _idleRotationWaitTime;
  49868. private _idleRotationSpinupTime;
  49869. /**
  49870. * Sets the flag that indicates if user zooming should stop animation.
  49871. */
  49872. set zoomStopsAnimation(flag: boolean);
  49873. /**
  49874. * Gets the flag that indicates if user zooming should stop animation.
  49875. */
  49876. get zoomStopsAnimation(): boolean;
  49877. /**
  49878. * Sets the default speed at which the camera rotates around the model.
  49879. */
  49880. set idleRotationSpeed(speed: number);
  49881. /**
  49882. * Gets the default speed at which the camera rotates around the model.
  49883. */
  49884. get idleRotationSpeed(): number;
  49885. /**
  49886. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49887. */
  49888. set idleRotationWaitTime(time: number);
  49889. /**
  49890. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49891. */
  49892. get idleRotationWaitTime(): number;
  49893. /**
  49894. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49895. */
  49896. set idleRotationSpinupTime(time: number);
  49897. /**
  49898. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49899. */
  49900. get idleRotationSpinupTime(): number;
  49901. /**
  49902. * Gets a value indicating if the camera is currently rotating because of this behavior
  49903. */
  49904. get rotationInProgress(): boolean;
  49905. private _onPrePointerObservableObserver;
  49906. private _onAfterCheckInputsObserver;
  49907. private _attachedCamera;
  49908. private _isPointerDown;
  49909. private _lastFrameTime;
  49910. private _lastInteractionTime;
  49911. private _cameraRotationSpeed;
  49912. /**
  49913. * Initializes the behavior.
  49914. */
  49915. init(): void;
  49916. /**
  49917. * Attaches the behavior to its arc rotate camera.
  49918. * @param camera Defines the camera to attach the behavior to
  49919. */
  49920. attach(camera: ArcRotateCamera): void;
  49921. /**
  49922. * Detaches the behavior from its current arc rotate camera.
  49923. */
  49924. detach(): void;
  49925. /**
  49926. * Returns true if user is scrolling.
  49927. * @return true if user is scrolling.
  49928. */
  49929. private _userIsZooming;
  49930. private _lastFrameRadius;
  49931. private _shouldAnimationStopForInteraction;
  49932. /**
  49933. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49934. */
  49935. private _applyUserInteraction;
  49936. private _userIsMoving;
  49937. }
  49938. }
  49939. declare module BABYLON {
  49940. /**
  49941. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  49942. */
  49943. export class AttachToBoxBehavior implements Behavior<Mesh> {
  49944. private ui;
  49945. /**
  49946. * The name of the behavior
  49947. */
  49948. name: string;
  49949. /**
  49950. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  49951. */
  49952. distanceAwayFromFace: number;
  49953. /**
  49954. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  49955. */
  49956. distanceAwayFromBottomOfFace: number;
  49957. private _faceVectors;
  49958. private _target;
  49959. private _scene;
  49960. private _onRenderObserver;
  49961. private _tmpMatrix;
  49962. private _tmpVector;
  49963. /**
  49964. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  49965. * @param ui The transform node that should be attched to the mesh
  49966. */
  49967. constructor(ui: TransformNode);
  49968. /**
  49969. * Initializes the behavior
  49970. */
  49971. init(): void;
  49972. private _closestFace;
  49973. private _zeroVector;
  49974. private _lookAtTmpMatrix;
  49975. private _lookAtToRef;
  49976. /**
  49977. * Attaches the AttachToBoxBehavior to the passed in mesh
  49978. * @param target The mesh that the specified node will be attached to
  49979. */
  49980. attach(target: Mesh): void;
  49981. /**
  49982. * Detaches the behavior from the mesh
  49983. */
  49984. detach(): void;
  49985. }
  49986. }
  49987. declare module BABYLON {
  49988. /**
  49989. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  49990. */
  49991. export class FadeInOutBehavior implements Behavior<Mesh> {
  49992. /**
  49993. * Time in milliseconds to delay before fading in (Default: 0)
  49994. */
  49995. delay: number;
  49996. /**
  49997. * Time in milliseconds for the mesh to fade in (Default: 300)
  49998. */
  49999. fadeInTime: number;
  50000. private _millisecondsPerFrame;
  50001. private _hovered;
  50002. private _hoverValue;
  50003. private _ownerNode;
  50004. /**
  50005. * Instatiates the FadeInOutBehavior
  50006. */
  50007. constructor();
  50008. /**
  50009. * The name of the behavior
  50010. */
  50011. get name(): string;
  50012. /**
  50013. * Initializes the behavior
  50014. */
  50015. init(): void;
  50016. /**
  50017. * Attaches the fade behavior on the passed in mesh
  50018. * @param ownerNode The mesh that will be faded in/out once attached
  50019. */
  50020. attach(ownerNode: Mesh): void;
  50021. /**
  50022. * Detaches the behavior from the mesh
  50023. */
  50024. detach(): void;
  50025. /**
  50026. * Triggers the mesh to begin fading in or out
  50027. * @param value if the object should fade in or out (true to fade in)
  50028. */
  50029. fadeIn(value: boolean): void;
  50030. private _update;
  50031. private _setAllVisibility;
  50032. }
  50033. }
  50034. declare module BABYLON {
  50035. /**
  50036. * Class containing a set of static utilities functions for managing Pivots
  50037. * @hidden
  50038. */
  50039. export class PivotTools {
  50040. private static _PivotCached;
  50041. private static _OldPivotPoint;
  50042. private static _PivotTranslation;
  50043. private static _PivotTmpVector;
  50044. private static _PivotPostMultiplyPivotMatrix;
  50045. /** @hidden */
  50046. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50047. /** @hidden */
  50048. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50049. }
  50050. }
  50051. declare module BABYLON {
  50052. /**
  50053. * Class containing static functions to help procedurally build meshes
  50054. */
  50055. export class PlaneBuilder {
  50056. /**
  50057. * Creates a plane mesh
  50058. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50059. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50060. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50062. * * 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
  50063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50064. * @param name defines the name of the mesh
  50065. * @param options defines the options used to create the mesh
  50066. * @param scene defines the hosting scene
  50067. * @returns the plane mesh
  50068. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50069. */
  50070. static CreatePlane(name: string, options: {
  50071. size?: number;
  50072. width?: number;
  50073. height?: number;
  50074. sideOrientation?: number;
  50075. frontUVs?: Vector4;
  50076. backUVs?: Vector4;
  50077. updatable?: boolean;
  50078. sourcePlane?: Plane;
  50079. }, scene?: Nullable<Scene>): Mesh;
  50080. }
  50081. }
  50082. declare module BABYLON {
  50083. /**
  50084. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50085. */
  50086. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50087. private static _AnyMouseID;
  50088. /**
  50089. * Abstract mesh the behavior is set on
  50090. */
  50091. attachedNode: AbstractMesh;
  50092. private _dragPlane;
  50093. private _scene;
  50094. private _pointerObserver;
  50095. private _beforeRenderObserver;
  50096. private static _planeScene;
  50097. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50098. /**
  50099. * 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)
  50100. */
  50101. maxDragAngle: number;
  50102. /**
  50103. * @hidden
  50104. */
  50105. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50106. /**
  50107. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50108. */
  50109. currentDraggingPointerID: number;
  50110. /**
  50111. * The last position where the pointer hit the drag plane in world space
  50112. */
  50113. lastDragPosition: Vector3;
  50114. /**
  50115. * If the behavior is currently in a dragging state
  50116. */
  50117. dragging: boolean;
  50118. /**
  50119. * 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)
  50120. */
  50121. dragDeltaRatio: number;
  50122. /**
  50123. * If the drag plane orientation should be updated during the dragging (Default: true)
  50124. */
  50125. updateDragPlane: boolean;
  50126. private _debugMode;
  50127. private _moving;
  50128. /**
  50129. * Fires each time the attached mesh is dragged with the pointer
  50130. * * delta between last drag position and current drag position in world space
  50131. * * dragDistance along the drag axis
  50132. * * dragPlaneNormal normal of the current drag plane used during the drag
  50133. * * dragPlanePoint in world space where the drag intersects the drag plane
  50134. */
  50135. onDragObservable: Observable<{
  50136. delta: Vector3;
  50137. dragPlanePoint: Vector3;
  50138. dragPlaneNormal: Vector3;
  50139. dragDistance: number;
  50140. pointerId: number;
  50141. }>;
  50142. /**
  50143. * Fires each time a drag begins (eg. mouse down on mesh)
  50144. */
  50145. onDragStartObservable: Observable<{
  50146. dragPlanePoint: Vector3;
  50147. pointerId: number;
  50148. }>;
  50149. /**
  50150. * Fires each time a drag ends (eg. mouse release after drag)
  50151. */
  50152. onDragEndObservable: Observable<{
  50153. dragPlanePoint: Vector3;
  50154. pointerId: number;
  50155. }>;
  50156. /**
  50157. * If the attached mesh should be moved when dragged
  50158. */
  50159. moveAttached: boolean;
  50160. /**
  50161. * If the drag behavior will react to drag events (Default: true)
  50162. */
  50163. enabled: boolean;
  50164. /**
  50165. * If pointer events should start and release the drag (Default: true)
  50166. */
  50167. startAndReleaseDragOnPointerEvents: boolean;
  50168. /**
  50169. * If camera controls should be detached during the drag
  50170. */
  50171. detachCameraControls: boolean;
  50172. /**
  50173. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50174. */
  50175. useObjectOrientationForDragging: boolean;
  50176. private _options;
  50177. /**
  50178. * Gets the options used by the behavior
  50179. */
  50180. get options(): {
  50181. dragAxis?: Vector3;
  50182. dragPlaneNormal?: Vector3;
  50183. };
  50184. /**
  50185. * Sets the options used by the behavior
  50186. */
  50187. set options(options: {
  50188. dragAxis?: Vector3;
  50189. dragPlaneNormal?: Vector3;
  50190. });
  50191. /**
  50192. * Creates a pointer drag behavior that can be attached to a mesh
  50193. * @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)
  50194. */
  50195. constructor(options?: {
  50196. dragAxis?: Vector3;
  50197. dragPlaneNormal?: Vector3;
  50198. });
  50199. /**
  50200. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50201. */
  50202. validateDrag: (targetPosition: Vector3) => boolean;
  50203. /**
  50204. * The name of the behavior
  50205. */
  50206. get name(): string;
  50207. /**
  50208. * Initializes the behavior
  50209. */
  50210. init(): void;
  50211. private _tmpVector;
  50212. private _alternatePickedPoint;
  50213. private _worldDragAxis;
  50214. private _targetPosition;
  50215. private _attachedToElement;
  50216. /**
  50217. * Attaches the drag behavior the passed in mesh
  50218. * @param ownerNode The mesh that will be dragged around once attached
  50219. * @param predicate Predicate to use for pick filtering
  50220. */
  50221. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50222. /**
  50223. * Force relase the drag action by code.
  50224. */
  50225. releaseDrag(): void;
  50226. private _startDragRay;
  50227. private _lastPointerRay;
  50228. /**
  50229. * Simulates the start of a pointer drag event on the behavior
  50230. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50231. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50232. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50233. */
  50234. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50235. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50236. private _dragDelta;
  50237. protected _moveDrag(ray: Ray): void;
  50238. private _pickWithRayOnDragPlane;
  50239. private _pointA;
  50240. private _pointC;
  50241. private _localAxis;
  50242. private _lookAt;
  50243. private _updateDragPlanePosition;
  50244. /**
  50245. * Detaches the behavior from the mesh
  50246. */
  50247. detach(): void;
  50248. }
  50249. }
  50250. declare module BABYLON {
  50251. /**
  50252. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50253. */
  50254. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50255. private _dragBehaviorA;
  50256. private _dragBehaviorB;
  50257. private _startDistance;
  50258. private _initialScale;
  50259. private _targetScale;
  50260. private _ownerNode;
  50261. private _sceneRenderObserver;
  50262. /**
  50263. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50264. */
  50265. constructor();
  50266. /**
  50267. * The name of the behavior
  50268. */
  50269. get name(): string;
  50270. /**
  50271. * Initializes the behavior
  50272. */
  50273. init(): void;
  50274. private _getCurrentDistance;
  50275. /**
  50276. * Attaches the scale behavior the passed in mesh
  50277. * @param ownerNode The mesh that will be scaled around once attached
  50278. */
  50279. attach(ownerNode: Mesh): void;
  50280. /**
  50281. * Detaches the behavior from the mesh
  50282. */
  50283. detach(): void;
  50284. }
  50285. }
  50286. declare module BABYLON {
  50287. /**
  50288. * 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
  50289. */
  50290. export class SixDofDragBehavior implements Behavior<Mesh> {
  50291. private static _virtualScene;
  50292. private _ownerNode;
  50293. private _sceneRenderObserver;
  50294. private _scene;
  50295. private _targetPosition;
  50296. private _virtualOriginMesh;
  50297. private _virtualDragMesh;
  50298. private _pointerObserver;
  50299. private _moving;
  50300. private _startingOrientation;
  50301. private _attachedToElement;
  50302. /**
  50303. * 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)
  50304. */
  50305. private zDragFactor;
  50306. /**
  50307. * If the object should rotate to face the drag origin
  50308. */
  50309. rotateDraggedObject: boolean;
  50310. /**
  50311. * If the behavior is currently in a dragging state
  50312. */
  50313. dragging: boolean;
  50314. /**
  50315. * 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)
  50316. */
  50317. dragDeltaRatio: number;
  50318. /**
  50319. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50320. */
  50321. currentDraggingPointerID: number;
  50322. /**
  50323. * If camera controls should be detached during the drag
  50324. */
  50325. detachCameraControls: boolean;
  50326. /**
  50327. * Fires each time a drag starts
  50328. */
  50329. onDragStartObservable: Observable<{}>;
  50330. /**
  50331. * Fires each time a drag happens
  50332. */
  50333. onDragObservable: Observable<void>;
  50334. /**
  50335. * Fires each time a drag ends (eg. mouse release after drag)
  50336. */
  50337. onDragEndObservable: Observable<{}>;
  50338. /**
  50339. * 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
  50340. */
  50341. constructor();
  50342. /**
  50343. * The name of the behavior
  50344. */
  50345. get name(): string;
  50346. /**
  50347. * Initializes the behavior
  50348. */
  50349. init(): void;
  50350. /**
  50351. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50352. */
  50353. private get _pointerCamera();
  50354. /**
  50355. * Attaches the scale behavior the passed in mesh
  50356. * @param ownerNode The mesh that will be scaled around once attached
  50357. */
  50358. attach(ownerNode: Mesh): void;
  50359. /**
  50360. * Detaches the behavior from the mesh
  50361. */
  50362. detach(): void;
  50363. }
  50364. }
  50365. declare module BABYLON {
  50366. /**
  50367. * Class used to apply inverse kinematics to bones
  50368. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50369. */
  50370. export class BoneIKController {
  50371. private static _tmpVecs;
  50372. private static _tmpQuat;
  50373. private static _tmpMats;
  50374. /**
  50375. * Gets or sets the target mesh
  50376. */
  50377. targetMesh: AbstractMesh;
  50378. /** Gets or sets the mesh used as pole */
  50379. poleTargetMesh: AbstractMesh;
  50380. /**
  50381. * Gets or sets the bone used as pole
  50382. */
  50383. poleTargetBone: Nullable<Bone>;
  50384. /**
  50385. * Gets or sets the target position
  50386. */
  50387. targetPosition: Vector3;
  50388. /**
  50389. * Gets or sets the pole target position
  50390. */
  50391. poleTargetPosition: Vector3;
  50392. /**
  50393. * Gets or sets the pole target local offset
  50394. */
  50395. poleTargetLocalOffset: Vector3;
  50396. /**
  50397. * Gets or sets the pole angle
  50398. */
  50399. poleAngle: number;
  50400. /**
  50401. * Gets or sets the mesh associated with the controller
  50402. */
  50403. mesh: AbstractMesh;
  50404. /**
  50405. * 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)
  50406. */
  50407. slerpAmount: number;
  50408. private _bone1Quat;
  50409. private _bone1Mat;
  50410. private _bone2Ang;
  50411. private _bone1;
  50412. private _bone2;
  50413. private _bone1Length;
  50414. private _bone2Length;
  50415. private _maxAngle;
  50416. private _maxReach;
  50417. private _rightHandedSystem;
  50418. private _bendAxis;
  50419. private _slerping;
  50420. private _adjustRoll;
  50421. /**
  50422. * Gets or sets maximum allowed angle
  50423. */
  50424. get maxAngle(): number;
  50425. set maxAngle(value: number);
  50426. /**
  50427. * Creates a new BoneIKController
  50428. * @param mesh defines the mesh to control
  50429. * @param bone defines the bone to control
  50430. * @param options defines options to set up the controller
  50431. */
  50432. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50433. targetMesh?: AbstractMesh;
  50434. poleTargetMesh?: AbstractMesh;
  50435. poleTargetBone?: Bone;
  50436. poleTargetLocalOffset?: Vector3;
  50437. poleAngle?: number;
  50438. bendAxis?: Vector3;
  50439. maxAngle?: number;
  50440. slerpAmount?: number;
  50441. });
  50442. private _setMaxAngle;
  50443. /**
  50444. * Force the controller to update the bones
  50445. */
  50446. update(): void;
  50447. }
  50448. }
  50449. declare module BABYLON {
  50450. /**
  50451. * Class used to make a bone look toward a point in space
  50452. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50453. */
  50454. export class BoneLookController {
  50455. private static _tmpVecs;
  50456. private static _tmpQuat;
  50457. private static _tmpMats;
  50458. /**
  50459. * The target Vector3 that the bone will look at
  50460. */
  50461. target: Vector3;
  50462. /**
  50463. * The mesh that the bone is attached to
  50464. */
  50465. mesh: AbstractMesh;
  50466. /**
  50467. * The bone that will be looking to the target
  50468. */
  50469. bone: Bone;
  50470. /**
  50471. * The up axis of the coordinate system that is used when the bone is rotated
  50472. */
  50473. upAxis: Vector3;
  50474. /**
  50475. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50476. */
  50477. upAxisSpace: Space;
  50478. /**
  50479. * Used to make an adjustment to the yaw of the bone
  50480. */
  50481. adjustYaw: number;
  50482. /**
  50483. * Used to make an adjustment to the pitch of the bone
  50484. */
  50485. adjustPitch: number;
  50486. /**
  50487. * Used to make an adjustment to the roll of the bone
  50488. */
  50489. adjustRoll: number;
  50490. /**
  50491. * 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)
  50492. */
  50493. slerpAmount: number;
  50494. private _minYaw;
  50495. private _maxYaw;
  50496. private _minPitch;
  50497. private _maxPitch;
  50498. private _minYawSin;
  50499. private _minYawCos;
  50500. private _maxYawSin;
  50501. private _maxYawCos;
  50502. private _midYawConstraint;
  50503. private _minPitchTan;
  50504. private _maxPitchTan;
  50505. private _boneQuat;
  50506. private _slerping;
  50507. private _transformYawPitch;
  50508. private _transformYawPitchInv;
  50509. private _firstFrameSkipped;
  50510. private _yawRange;
  50511. private _fowardAxis;
  50512. /**
  50513. * Gets or sets the minimum yaw angle that the bone can look to
  50514. */
  50515. get minYaw(): number;
  50516. set minYaw(value: number);
  50517. /**
  50518. * Gets or sets the maximum yaw angle that the bone can look to
  50519. */
  50520. get maxYaw(): number;
  50521. set maxYaw(value: number);
  50522. /**
  50523. * Gets or sets the minimum pitch angle that the bone can look to
  50524. */
  50525. get minPitch(): number;
  50526. set minPitch(value: number);
  50527. /**
  50528. * Gets or sets the maximum pitch angle that the bone can look to
  50529. */
  50530. get maxPitch(): number;
  50531. set maxPitch(value: number);
  50532. /**
  50533. * Create a BoneLookController
  50534. * @param mesh the mesh that the bone belongs to
  50535. * @param bone the bone that will be looking to the target
  50536. * @param target the target Vector3 to look at
  50537. * @param options optional settings:
  50538. * * maxYaw: the maximum angle the bone will yaw to
  50539. * * minYaw: the minimum angle the bone will yaw to
  50540. * * maxPitch: the maximum angle the bone will pitch to
  50541. * * minPitch: the minimum angle the bone will yaw to
  50542. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50543. * * upAxis: the up axis of the coordinate system
  50544. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50545. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50546. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50547. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50548. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50549. * * adjustRoll: used to make an adjustment to the roll of the bone
  50550. **/
  50551. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50552. maxYaw?: number;
  50553. minYaw?: number;
  50554. maxPitch?: number;
  50555. minPitch?: number;
  50556. slerpAmount?: number;
  50557. upAxis?: Vector3;
  50558. upAxisSpace?: Space;
  50559. yawAxis?: Vector3;
  50560. pitchAxis?: Vector3;
  50561. adjustYaw?: number;
  50562. adjustPitch?: number;
  50563. adjustRoll?: number;
  50564. });
  50565. /**
  50566. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50567. */
  50568. update(): void;
  50569. private _getAngleDiff;
  50570. private _getAngleBetween;
  50571. private _isAngleBetween;
  50572. }
  50573. }
  50574. declare module BABYLON {
  50575. /**
  50576. * Manage the gamepad inputs to control an arc rotate camera.
  50577. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50578. */
  50579. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50580. /**
  50581. * Defines the camera the input is attached to.
  50582. */
  50583. camera: ArcRotateCamera;
  50584. /**
  50585. * Defines the gamepad the input is gathering event from.
  50586. */
  50587. gamepad: Nullable<Gamepad>;
  50588. /**
  50589. * Defines the gamepad rotation sensiblity.
  50590. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50591. */
  50592. gamepadRotationSensibility: number;
  50593. /**
  50594. * Defines the gamepad move sensiblity.
  50595. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50596. */
  50597. gamepadMoveSensibility: number;
  50598. private _yAxisScale;
  50599. /**
  50600. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50601. */
  50602. get invertYAxis(): boolean;
  50603. set invertYAxis(value: boolean);
  50604. private _onGamepadConnectedObserver;
  50605. private _onGamepadDisconnectedObserver;
  50606. /**
  50607. * Attach the input controls to a specific dom element to get the input from.
  50608. */
  50609. attachControl(): void;
  50610. /**
  50611. * Detach the current controls from the specified dom element.
  50612. */
  50613. detachControl(): void;
  50614. /**
  50615. * Update the current camera state depending on the inputs that have been used this frame.
  50616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50617. */
  50618. checkInputs(): void;
  50619. /**
  50620. * Gets the class name of the current intput.
  50621. * @returns the class name
  50622. */
  50623. getClassName(): string;
  50624. /**
  50625. * Get the friendly name associated with the input class.
  50626. * @returns the input friendly name
  50627. */
  50628. getSimpleName(): string;
  50629. }
  50630. }
  50631. declare module BABYLON {
  50632. interface ArcRotateCameraInputsManager {
  50633. /**
  50634. * Add orientation input support to the input manager.
  50635. * @returns the current input manager
  50636. */
  50637. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50638. }
  50639. /**
  50640. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50641. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50642. */
  50643. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50644. /**
  50645. * Defines the camera the input is attached to.
  50646. */
  50647. camera: ArcRotateCamera;
  50648. /**
  50649. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50650. */
  50651. alphaCorrection: number;
  50652. /**
  50653. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50654. */
  50655. gammaCorrection: number;
  50656. private _alpha;
  50657. private _gamma;
  50658. private _dirty;
  50659. private _deviceOrientationHandler;
  50660. /**
  50661. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50662. */
  50663. constructor();
  50664. /**
  50665. * Attach the input controls to a specific dom element to get the input from.
  50666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50667. */
  50668. attachControl(noPreventDefault?: boolean): void;
  50669. /** @hidden */
  50670. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50671. /**
  50672. * Update the current camera state depending on the inputs that have been used this frame.
  50673. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50674. */
  50675. checkInputs(): void;
  50676. /**
  50677. * Detach the current controls from the specified dom element.
  50678. */
  50679. detachControl(): void;
  50680. /**
  50681. * Gets the class name of the current intput.
  50682. * @returns the class name
  50683. */
  50684. getClassName(): string;
  50685. /**
  50686. * Get the friendly name associated with the input class.
  50687. * @returns the input friendly name
  50688. */
  50689. getSimpleName(): string;
  50690. }
  50691. }
  50692. declare module BABYLON {
  50693. /**
  50694. * Listen to mouse events to control the camera.
  50695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50696. */
  50697. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50698. /**
  50699. * Defines the camera the input is attached to.
  50700. */
  50701. camera: FlyCamera;
  50702. /**
  50703. * Defines if touch is enabled. (Default is true.)
  50704. */
  50705. touchEnabled: boolean;
  50706. /**
  50707. * Defines the buttons associated with the input to handle camera rotation.
  50708. */
  50709. buttons: number[];
  50710. /**
  50711. * Assign buttons for Yaw control.
  50712. */
  50713. buttonsYaw: number[];
  50714. /**
  50715. * Assign buttons for Pitch control.
  50716. */
  50717. buttonsPitch: number[];
  50718. /**
  50719. * Assign buttons for Roll control.
  50720. */
  50721. buttonsRoll: number[];
  50722. /**
  50723. * Detect if any button is being pressed while mouse is moved.
  50724. * -1 = Mouse locked.
  50725. * 0 = Left button.
  50726. * 1 = Middle Button.
  50727. * 2 = Right Button.
  50728. */
  50729. activeButton: number;
  50730. /**
  50731. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50732. * Higher values reduce its sensitivity.
  50733. */
  50734. angularSensibility: number;
  50735. private _observer;
  50736. private _rollObserver;
  50737. private previousPosition;
  50738. private noPreventDefault;
  50739. private element;
  50740. /**
  50741. * Listen to mouse events to control the camera.
  50742. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50743. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50744. */
  50745. constructor(touchEnabled?: boolean);
  50746. /**
  50747. * Attach the mouse control to the HTML DOM element.
  50748. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50749. */
  50750. attachControl(noPreventDefault?: boolean): void;
  50751. /**
  50752. * Detach the current controls from the specified dom element.
  50753. */
  50754. detachControl(): void;
  50755. /**
  50756. * Gets the class name of the current input.
  50757. * @returns the class name.
  50758. */
  50759. getClassName(): string;
  50760. /**
  50761. * Get the friendly name associated with the input class.
  50762. * @returns the input's friendly name.
  50763. */
  50764. getSimpleName(): string;
  50765. private _pointerInput;
  50766. private _onMouseMove;
  50767. /**
  50768. * Rotate camera by mouse offset.
  50769. */
  50770. private rotateCamera;
  50771. }
  50772. }
  50773. declare module BABYLON {
  50774. /**
  50775. * Default Inputs manager for the FlyCamera.
  50776. * It groups all the default supported inputs for ease of use.
  50777. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50778. */
  50779. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50780. /**
  50781. * Instantiates a new FlyCameraInputsManager.
  50782. * @param camera Defines the camera the inputs belong to.
  50783. */
  50784. constructor(camera: FlyCamera);
  50785. /**
  50786. * Add keyboard input support to the input manager.
  50787. * @returns the new FlyCameraKeyboardMoveInput().
  50788. */
  50789. addKeyboard(): FlyCameraInputsManager;
  50790. /**
  50791. * Add mouse input support to the input manager.
  50792. * @param touchEnabled Enable touch screen support.
  50793. * @returns the new FlyCameraMouseInput().
  50794. */
  50795. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50796. }
  50797. }
  50798. declare module BABYLON {
  50799. /**
  50800. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50801. * such as in a 3D Space Shooter or a Flight Simulator.
  50802. */
  50803. export class FlyCamera extends TargetCamera {
  50804. /**
  50805. * Define the collision ellipsoid of the camera.
  50806. * This is helpful for simulating a camera body, like a player's body.
  50807. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50808. */
  50809. ellipsoid: Vector3;
  50810. /**
  50811. * Define an offset for the position of the ellipsoid around the camera.
  50812. * This can be helpful if the camera is attached away from the player's body center,
  50813. * such as at its head.
  50814. */
  50815. ellipsoidOffset: Vector3;
  50816. /**
  50817. * Enable or disable collisions of the camera with the rest of the scene objects.
  50818. */
  50819. checkCollisions: boolean;
  50820. /**
  50821. * Enable or disable gravity on the camera.
  50822. */
  50823. applyGravity: boolean;
  50824. /**
  50825. * Define the current direction the camera is moving to.
  50826. */
  50827. cameraDirection: Vector3;
  50828. /**
  50829. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50830. * This overrides and empties cameraRotation.
  50831. */
  50832. rotationQuaternion: Quaternion;
  50833. /**
  50834. * Track Roll to maintain the wanted Rolling when looking around.
  50835. */
  50836. _trackRoll: number;
  50837. /**
  50838. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50839. */
  50840. rollCorrect: number;
  50841. /**
  50842. * Mimic a banked turn, Rolling the camera when Yawing.
  50843. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50844. */
  50845. bankedTurn: boolean;
  50846. /**
  50847. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50848. */
  50849. bankedTurnLimit: number;
  50850. /**
  50851. * Value of 0 disables the banked Roll.
  50852. * Value of 1 is equal to the Yaw angle in radians.
  50853. */
  50854. bankedTurnMultiplier: number;
  50855. /**
  50856. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50857. */
  50858. inputs: FlyCameraInputsManager;
  50859. /**
  50860. * Gets the input sensibility for mouse input.
  50861. * Higher values reduce sensitivity.
  50862. */
  50863. get angularSensibility(): number;
  50864. /**
  50865. * Sets the input sensibility for a mouse input.
  50866. * Higher values reduce sensitivity.
  50867. */
  50868. set angularSensibility(value: number);
  50869. /**
  50870. * Get the keys for camera movement forward.
  50871. */
  50872. get keysForward(): number[];
  50873. /**
  50874. * Set the keys for camera movement forward.
  50875. */
  50876. set keysForward(value: number[]);
  50877. /**
  50878. * Get the keys for camera movement backward.
  50879. */
  50880. get keysBackward(): number[];
  50881. set keysBackward(value: number[]);
  50882. /**
  50883. * Get the keys for camera movement up.
  50884. */
  50885. get keysUp(): number[];
  50886. /**
  50887. * Set the keys for camera movement up.
  50888. */
  50889. set keysUp(value: number[]);
  50890. /**
  50891. * Get the keys for camera movement down.
  50892. */
  50893. get keysDown(): number[];
  50894. /**
  50895. * Set the keys for camera movement down.
  50896. */
  50897. set keysDown(value: number[]);
  50898. /**
  50899. * Get the keys for camera movement left.
  50900. */
  50901. get keysLeft(): number[];
  50902. /**
  50903. * Set the keys for camera movement left.
  50904. */
  50905. set keysLeft(value: number[]);
  50906. /**
  50907. * Set the keys for camera movement right.
  50908. */
  50909. get keysRight(): number[];
  50910. /**
  50911. * Set the keys for camera movement right.
  50912. */
  50913. set keysRight(value: number[]);
  50914. /**
  50915. * Event raised when the camera collides with a mesh in the scene.
  50916. */
  50917. onCollide: (collidedMesh: AbstractMesh) => void;
  50918. private _collider;
  50919. private _needMoveForGravity;
  50920. private _oldPosition;
  50921. private _diffPosition;
  50922. private _newPosition;
  50923. /** @hidden */
  50924. _localDirection: Vector3;
  50925. /** @hidden */
  50926. _transformedDirection: Vector3;
  50927. /**
  50928. * Instantiates a FlyCamera.
  50929. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50930. * such as in a 3D Space Shooter or a Flight Simulator.
  50931. * @param name Define the name of the camera in the scene.
  50932. * @param position Define the starting position of the camera in the scene.
  50933. * @param scene Define the scene the camera belongs to.
  50934. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  50935. */
  50936. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50937. /**
  50938. * Attach the input controls to a specific dom element to get the input from.
  50939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50940. */
  50941. attachControl(noPreventDefault?: boolean): void;
  50942. /**
  50943. * Detach a control from the HTML DOM element.
  50944. * The camera will stop reacting to that input.
  50945. */
  50946. detachControl(): void;
  50947. private _collisionMask;
  50948. /**
  50949. * Get the mask that the camera ignores in collision events.
  50950. */
  50951. get collisionMask(): number;
  50952. /**
  50953. * Set the mask that the camera ignores in collision events.
  50954. */
  50955. set collisionMask(mask: number);
  50956. /** @hidden */
  50957. _collideWithWorld(displacement: Vector3): void;
  50958. /** @hidden */
  50959. private _onCollisionPositionChange;
  50960. /** @hidden */
  50961. _checkInputs(): void;
  50962. /** @hidden */
  50963. _decideIfNeedsToMove(): boolean;
  50964. /** @hidden */
  50965. _updatePosition(): void;
  50966. /**
  50967. * Restore the Roll to its target value at the rate specified.
  50968. * @param rate - Higher means slower restoring.
  50969. * @hidden
  50970. */
  50971. restoreRoll(rate: number): void;
  50972. /**
  50973. * Destroy the camera and release the current resources held by it.
  50974. */
  50975. dispose(): void;
  50976. /**
  50977. * Get the current object class name.
  50978. * @returns the class name.
  50979. */
  50980. getClassName(): string;
  50981. }
  50982. }
  50983. declare module BABYLON {
  50984. /**
  50985. * Listen to keyboard events to control the camera.
  50986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50987. */
  50988. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  50989. /**
  50990. * Defines the camera the input is attached to.
  50991. */
  50992. camera: FlyCamera;
  50993. /**
  50994. * The list of keyboard keys used to control the forward move of the camera.
  50995. */
  50996. keysForward: number[];
  50997. /**
  50998. * The list of keyboard keys used to control the backward move of the camera.
  50999. */
  51000. keysBackward: number[];
  51001. /**
  51002. * The list of keyboard keys used to control the forward move of the camera.
  51003. */
  51004. keysUp: number[];
  51005. /**
  51006. * The list of keyboard keys used to control the backward move of the camera.
  51007. */
  51008. keysDown: number[];
  51009. /**
  51010. * The list of keyboard keys used to control the right strafe move of the camera.
  51011. */
  51012. keysRight: number[];
  51013. /**
  51014. * The list of keyboard keys used to control the left strafe move of the camera.
  51015. */
  51016. keysLeft: number[];
  51017. private _keys;
  51018. private _onCanvasBlurObserver;
  51019. private _onKeyboardObserver;
  51020. private _engine;
  51021. private _scene;
  51022. /**
  51023. * Attach the input controls to a specific dom element to get the input from.
  51024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51025. */
  51026. attachControl(noPreventDefault?: boolean): void;
  51027. /**
  51028. * Detach the current controls from the specified dom element.
  51029. */
  51030. detachControl(): void;
  51031. /**
  51032. * Gets the class name of the current intput.
  51033. * @returns the class name
  51034. */
  51035. getClassName(): string;
  51036. /** @hidden */
  51037. _onLostFocus(e: FocusEvent): void;
  51038. /**
  51039. * Get the friendly name associated with the input class.
  51040. * @returns the input friendly name
  51041. */
  51042. getSimpleName(): string;
  51043. /**
  51044. * Update the current camera state depending on the inputs that have been used this frame.
  51045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51046. */
  51047. checkInputs(): void;
  51048. }
  51049. }
  51050. declare module BABYLON {
  51051. /**
  51052. * Manage the mouse wheel inputs to control a follow camera.
  51053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51054. */
  51055. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51056. /**
  51057. * Defines the camera the input is attached to.
  51058. */
  51059. camera: FollowCamera;
  51060. /**
  51061. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51062. */
  51063. axisControlRadius: boolean;
  51064. /**
  51065. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51066. */
  51067. axisControlHeight: boolean;
  51068. /**
  51069. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51070. */
  51071. axisControlRotation: boolean;
  51072. /**
  51073. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51074. * relation to mouseWheel events.
  51075. */
  51076. wheelPrecision: number;
  51077. /**
  51078. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51079. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51080. */
  51081. wheelDeltaPercentage: number;
  51082. private _wheel;
  51083. private _observer;
  51084. /**
  51085. * Attach the input controls to a specific dom element to get the input from.
  51086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51087. */
  51088. attachControl(noPreventDefault?: boolean): void;
  51089. /**
  51090. * Detach the current controls from the specified dom element.
  51091. */
  51092. detachControl(): void;
  51093. /**
  51094. * Gets the class name of the current intput.
  51095. * @returns the class name
  51096. */
  51097. getClassName(): string;
  51098. /**
  51099. * Get the friendly name associated with the input class.
  51100. * @returns the input friendly name
  51101. */
  51102. getSimpleName(): string;
  51103. }
  51104. }
  51105. declare module BABYLON {
  51106. /**
  51107. * Manage the pointers inputs to control an follow camera.
  51108. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51109. */
  51110. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51111. /**
  51112. * Defines the camera the input is attached to.
  51113. */
  51114. camera: FollowCamera;
  51115. /**
  51116. * Gets the class name of the current input.
  51117. * @returns the class name
  51118. */
  51119. getClassName(): string;
  51120. /**
  51121. * Defines the pointer angular sensibility along the X axis or how fast is
  51122. * the camera rotating.
  51123. * A negative number will reverse the axis direction.
  51124. */
  51125. angularSensibilityX: number;
  51126. /**
  51127. * Defines the pointer angular sensibility along the Y axis or how fast is
  51128. * the camera rotating.
  51129. * A negative number will reverse the axis direction.
  51130. */
  51131. angularSensibilityY: number;
  51132. /**
  51133. * Defines the pointer pinch precision or how fast is the camera zooming.
  51134. * A negative number will reverse the axis direction.
  51135. */
  51136. pinchPrecision: number;
  51137. /**
  51138. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51139. * from 0.
  51140. * It defines the percentage of current camera.radius to use as delta when
  51141. * pinch zoom is used.
  51142. */
  51143. pinchDeltaPercentage: number;
  51144. /**
  51145. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51146. */
  51147. axisXControlRadius: boolean;
  51148. /**
  51149. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51150. */
  51151. axisXControlHeight: boolean;
  51152. /**
  51153. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51154. */
  51155. axisXControlRotation: boolean;
  51156. /**
  51157. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51158. */
  51159. axisYControlRadius: boolean;
  51160. /**
  51161. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51162. */
  51163. axisYControlHeight: boolean;
  51164. /**
  51165. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51166. */
  51167. axisYControlRotation: boolean;
  51168. /**
  51169. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51170. */
  51171. axisPinchControlRadius: boolean;
  51172. /**
  51173. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51174. */
  51175. axisPinchControlHeight: boolean;
  51176. /**
  51177. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51178. */
  51179. axisPinchControlRotation: boolean;
  51180. /**
  51181. * Log error messages if basic misconfiguration has occurred.
  51182. */
  51183. warningEnable: boolean;
  51184. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51185. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51186. private _warningCounter;
  51187. private _warning;
  51188. }
  51189. }
  51190. declare module BABYLON {
  51191. /**
  51192. * Default Inputs manager for the FollowCamera.
  51193. * It groups all the default supported inputs for ease of use.
  51194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51195. */
  51196. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51197. /**
  51198. * Instantiates a new FollowCameraInputsManager.
  51199. * @param camera Defines the camera the inputs belong to
  51200. */
  51201. constructor(camera: FollowCamera);
  51202. /**
  51203. * Add keyboard input support to the input manager.
  51204. * @returns the current input manager
  51205. */
  51206. addKeyboard(): FollowCameraInputsManager;
  51207. /**
  51208. * Add mouse wheel input support to the input manager.
  51209. * @returns the current input manager
  51210. */
  51211. addMouseWheel(): FollowCameraInputsManager;
  51212. /**
  51213. * Add pointers input support to the input manager.
  51214. * @returns the current input manager
  51215. */
  51216. addPointers(): FollowCameraInputsManager;
  51217. /**
  51218. * Add orientation input support to the input manager.
  51219. * @returns the current input manager
  51220. */
  51221. addVRDeviceOrientation(): FollowCameraInputsManager;
  51222. }
  51223. }
  51224. declare module BABYLON {
  51225. /**
  51226. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51227. * an arc rotate version arcFollowCamera are available.
  51228. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51229. */
  51230. export class FollowCamera extends TargetCamera {
  51231. /**
  51232. * Distance the follow camera should follow an object at
  51233. */
  51234. radius: number;
  51235. /**
  51236. * Minimum allowed distance of the camera to the axis of rotation
  51237. * (The camera can not get closer).
  51238. * This can help limiting how the Camera is able to move in the scene.
  51239. */
  51240. lowerRadiusLimit: Nullable<number>;
  51241. /**
  51242. * Maximum allowed distance of the camera to the axis of rotation
  51243. * (The camera can not get further).
  51244. * This can help limiting how the Camera is able to move in the scene.
  51245. */
  51246. upperRadiusLimit: Nullable<number>;
  51247. /**
  51248. * Define a rotation offset between the camera and the object it follows
  51249. */
  51250. rotationOffset: number;
  51251. /**
  51252. * Minimum allowed angle to camera position relative to target object.
  51253. * This can help limiting how the Camera is able to move in the scene.
  51254. */
  51255. lowerRotationOffsetLimit: Nullable<number>;
  51256. /**
  51257. * Maximum allowed angle to camera position relative to target object.
  51258. * This can help limiting how the Camera is able to move in the scene.
  51259. */
  51260. upperRotationOffsetLimit: Nullable<number>;
  51261. /**
  51262. * Define a height offset between the camera and the object it follows.
  51263. * It can help following an object from the top (like a car chaing a plane)
  51264. */
  51265. heightOffset: number;
  51266. /**
  51267. * Minimum allowed height of camera position relative to target object.
  51268. * This can help limiting how the Camera is able to move in the scene.
  51269. */
  51270. lowerHeightOffsetLimit: Nullable<number>;
  51271. /**
  51272. * Maximum allowed height of camera position relative to target object.
  51273. * This can help limiting how the Camera is able to move in the scene.
  51274. */
  51275. upperHeightOffsetLimit: Nullable<number>;
  51276. /**
  51277. * Define how fast the camera can accelerate to follow it s target.
  51278. */
  51279. cameraAcceleration: number;
  51280. /**
  51281. * Define the speed limit of the camera following an object.
  51282. */
  51283. maxCameraSpeed: number;
  51284. /**
  51285. * Define the target of the camera.
  51286. */
  51287. lockedTarget: Nullable<AbstractMesh>;
  51288. /**
  51289. * Defines the input associated with the camera.
  51290. */
  51291. inputs: FollowCameraInputsManager;
  51292. /**
  51293. * Instantiates the follow camera.
  51294. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51295. * @param name Define the name of the camera in the scene
  51296. * @param position Define the position of the camera
  51297. * @param scene Define the scene the camera belong to
  51298. * @param lockedTarget Define the target of the camera
  51299. */
  51300. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51301. private _follow;
  51302. /**
  51303. * Attach the input controls to a specific dom element to get the input from.
  51304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51305. */
  51306. attachControl(noPreventDefault?: boolean): void;
  51307. /**
  51308. * Detach the current controls from the specified dom element.
  51309. */
  51310. detachControl(): void;
  51311. /** @hidden */
  51312. _checkInputs(): void;
  51313. private _checkLimits;
  51314. /**
  51315. * Gets the camera class name.
  51316. * @returns the class name
  51317. */
  51318. getClassName(): string;
  51319. }
  51320. /**
  51321. * Arc Rotate version of the follow camera.
  51322. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51323. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51324. */
  51325. export class ArcFollowCamera extends TargetCamera {
  51326. /** The longitudinal angle of the camera */
  51327. alpha: number;
  51328. /** The latitudinal angle of the camera */
  51329. beta: number;
  51330. /** The radius of the camera from its target */
  51331. radius: number;
  51332. private _cartesianCoordinates;
  51333. /** Define the camera target (the mesh it should follow) */
  51334. private _meshTarget;
  51335. /**
  51336. * Instantiates a new ArcFollowCamera
  51337. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51338. * @param name Define the name of the camera
  51339. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51340. * @param beta Define the rotation angle of the camera around the elevation axis
  51341. * @param radius Define the radius of the camera from its target point
  51342. * @param target Define the target of the camera
  51343. * @param scene Define the scene the camera belongs to
  51344. */
  51345. constructor(name: string,
  51346. /** The longitudinal angle of the camera */
  51347. alpha: number,
  51348. /** The latitudinal angle of the camera */
  51349. beta: number,
  51350. /** The radius of the camera from its target */
  51351. radius: number,
  51352. /** Define the camera target (the mesh it should follow) */
  51353. target: Nullable<AbstractMesh>, scene: Scene);
  51354. private _follow;
  51355. /** @hidden */
  51356. _checkInputs(): void;
  51357. /**
  51358. * Returns the class name of the object.
  51359. * It is mostly used internally for serialization purposes.
  51360. */
  51361. getClassName(): string;
  51362. }
  51363. }
  51364. declare module BABYLON {
  51365. /**
  51366. * Manage the keyboard inputs to control the movement of a follow camera.
  51367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51368. */
  51369. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51370. /**
  51371. * Defines the camera the input is attached to.
  51372. */
  51373. camera: FollowCamera;
  51374. /**
  51375. * Defines the list of key codes associated with the up action (increase heightOffset)
  51376. */
  51377. keysHeightOffsetIncr: number[];
  51378. /**
  51379. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51380. */
  51381. keysHeightOffsetDecr: number[];
  51382. /**
  51383. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51384. */
  51385. keysHeightOffsetModifierAlt: boolean;
  51386. /**
  51387. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51388. */
  51389. keysHeightOffsetModifierCtrl: boolean;
  51390. /**
  51391. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51392. */
  51393. keysHeightOffsetModifierShift: boolean;
  51394. /**
  51395. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51396. */
  51397. keysRotationOffsetIncr: number[];
  51398. /**
  51399. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51400. */
  51401. keysRotationOffsetDecr: number[];
  51402. /**
  51403. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51404. */
  51405. keysRotationOffsetModifierAlt: boolean;
  51406. /**
  51407. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51408. */
  51409. keysRotationOffsetModifierCtrl: boolean;
  51410. /**
  51411. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51412. */
  51413. keysRotationOffsetModifierShift: boolean;
  51414. /**
  51415. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51416. */
  51417. keysRadiusIncr: number[];
  51418. /**
  51419. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51420. */
  51421. keysRadiusDecr: number[];
  51422. /**
  51423. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51424. */
  51425. keysRadiusModifierAlt: boolean;
  51426. /**
  51427. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51428. */
  51429. keysRadiusModifierCtrl: boolean;
  51430. /**
  51431. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51432. */
  51433. keysRadiusModifierShift: boolean;
  51434. /**
  51435. * Defines the rate of change of heightOffset.
  51436. */
  51437. heightSensibility: number;
  51438. /**
  51439. * Defines the rate of change of rotationOffset.
  51440. */
  51441. rotationSensibility: number;
  51442. /**
  51443. * Defines the rate of change of radius.
  51444. */
  51445. radiusSensibility: number;
  51446. private _keys;
  51447. private _ctrlPressed;
  51448. private _altPressed;
  51449. private _shiftPressed;
  51450. private _onCanvasBlurObserver;
  51451. private _onKeyboardObserver;
  51452. private _engine;
  51453. private _scene;
  51454. /**
  51455. * Attach the input controls to a specific dom element to get the input from.
  51456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51457. */
  51458. attachControl(noPreventDefault?: boolean): void;
  51459. /**
  51460. * Detach the current controls from the specified dom element.
  51461. */
  51462. detachControl(): void;
  51463. /**
  51464. * Update the current camera state depending on the inputs that have been used this frame.
  51465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51466. */
  51467. checkInputs(): void;
  51468. /**
  51469. * Gets the class name of the current input.
  51470. * @returns the class name
  51471. */
  51472. getClassName(): string;
  51473. /**
  51474. * Get the friendly name associated with the input class.
  51475. * @returns the input friendly name
  51476. */
  51477. getSimpleName(): string;
  51478. /**
  51479. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51480. * allow modification of the heightOffset value.
  51481. */
  51482. private _modifierHeightOffset;
  51483. /**
  51484. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51485. * allow modification of the rotationOffset value.
  51486. */
  51487. private _modifierRotationOffset;
  51488. /**
  51489. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51490. * allow modification of the radius value.
  51491. */
  51492. private _modifierRadius;
  51493. }
  51494. }
  51495. declare module BABYLON {
  51496. interface FreeCameraInputsManager {
  51497. /**
  51498. * @hidden
  51499. */
  51500. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51501. /**
  51502. * Add orientation input support to the input manager.
  51503. * @returns the current input manager
  51504. */
  51505. addDeviceOrientation(): FreeCameraInputsManager;
  51506. }
  51507. /**
  51508. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51509. * Screen rotation is taken into account.
  51510. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51511. */
  51512. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51513. private _camera;
  51514. private _screenOrientationAngle;
  51515. private _constantTranform;
  51516. private _screenQuaternion;
  51517. private _alpha;
  51518. private _beta;
  51519. private _gamma;
  51520. /**
  51521. * Can be used to detect if a device orientation sensor is available on a device
  51522. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51523. * @returns a promise that will resolve on orientation change
  51524. */
  51525. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51526. /**
  51527. * @hidden
  51528. */
  51529. _onDeviceOrientationChangedObservable: Observable<void>;
  51530. /**
  51531. * Instantiates a new input
  51532. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51533. */
  51534. constructor();
  51535. /**
  51536. * Define the camera controlled by the input.
  51537. */
  51538. get camera(): FreeCamera;
  51539. set camera(camera: FreeCamera);
  51540. /**
  51541. * Attach the input controls to a specific dom element to get the input from.
  51542. */
  51543. attachControl(): void;
  51544. private _orientationChanged;
  51545. private _deviceOrientation;
  51546. /**
  51547. * Detach the current controls from the specified dom element.
  51548. */
  51549. detachControl(): void;
  51550. /**
  51551. * Update the current camera state depending on the inputs that have been used this frame.
  51552. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51553. */
  51554. checkInputs(): void;
  51555. /**
  51556. * Gets the class name of the current intput.
  51557. * @returns the class name
  51558. */
  51559. getClassName(): string;
  51560. /**
  51561. * Get the friendly name associated with the input class.
  51562. * @returns the input friendly name
  51563. */
  51564. getSimpleName(): string;
  51565. }
  51566. }
  51567. declare module BABYLON {
  51568. /**
  51569. * Manage the gamepad inputs to control a free camera.
  51570. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51571. */
  51572. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51573. /**
  51574. * Define the camera the input is attached to.
  51575. */
  51576. camera: FreeCamera;
  51577. /**
  51578. * Define the Gamepad controlling the input
  51579. */
  51580. gamepad: Nullable<Gamepad>;
  51581. /**
  51582. * Defines the gamepad rotation sensiblity.
  51583. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51584. */
  51585. gamepadAngularSensibility: number;
  51586. /**
  51587. * Defines the gamepad move sensiblity.
  51588. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51589. */
  51590. gamepadMoveSensibility: number;
  51591. private _yAxisScale;
  51592. /**
  51593. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51594. */
  51595. get invertYAxis(): boolean;
  51596. set invertYAxis(value: boolean);
  51597. private _onGamepadConnectedObserver;
  51598. private _onGamepadDisconnectedObserver;
  51599. private _cameraTransform;
  51600. private _deltaTransform;
  51601. private _vector3;
  51602. private _vector2;
  51603. /**
  51604. * Attach the input controls to a specific dom element to get the input from.
  51605. */
  51606. attachControl(): void;
  51607. /**
  51608. * Detach the current controls from the specified dom element.
  51609. */
  51610. detachControl(): void;
  51611. /**
  51612. * Update the current camera state depending on the inputs that have been used this frame.
  51613. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51614. */
  51615. checkInputs(): void;
  51616. /**
  51617. * Gets the class name of the current intput.
  51618. * @returns the class name
  51619. */
  51620. getClassName(): string;
  51621. /**
  51622. * Get the friendly name associated with the input class.
  51623. * @returns the input friendly name
  51624. */
  51625. getSimpleName(): string;
  51626. }
  51627. }
  51628. declare module BABYLON {
  51629. /**
  51630. * Defines the potential axis of a Joystick
  51631. */
  51632. export enum JoystickAxis {
  51633. /** X axis */
  51634. X = 0,
  51635. /** Y axis */
  51636. Y = 1,
  51637. /** Z axis */
  51638. Z = 2
  51639. }
  51640. /**
  51641. * Represents the different customization options available
  51642. * for VirtualJoystick
  51643. */
  51644. interface VirtualJoystickCustomizations {
  51645. /**
  51646. * Size of the joystick's puck
  51647. */
  51648. puckSize: number;
  51649. /**
  51650. * Size of the joystick's container
  51651. */
  51652. containerSize: number;
  51653. /**
  51654. * Color of the joystick && puck
  51655. */
  51656. color: string;
  51657. /**
  51658. * Image URL for the joystick's puck
  51659. */
  51660. puckImage?: string;
  51661. /**
  51662. * Image URL for the joystick's container
  51663. */
  51664. containerImage?: string;
  51665. /**
  51666. * Defines the unmoving position of the joystick container
  51667. */
  51668. position?: {
  51669. x: number;
  51670. y: number;
  51671. };
  51672. /**
  51673. * Defines whether or not the joystick container is always visible
  51674. */
  51675. alwaysVisible: boolean;
  51676. /**
  51677. * Defines whether or not to limit the movement of the puck to the joystick's container
  51678. */
  51679. limitToContainer: boolean;
  51680. }
  51681. /**
  51682. * Class used to define virtual joystick (used in touch mode)
  51683. */
  51684. export class VirtualJoystick {
  51685. /**
  51686. * Gets or sets a boolean indicating that left and right values must be inverted
  51687. */
  51688. reverseLeftRight: boolean;
  51689. /**
  51690. * Gets or sets a boolean indicating that up and down values must be inverted
  51691. */
  51692. reverseUpDown: boolean;
  51693. /**
  51694. * Gets the offset value for the position (ie. the change of the position value)
  51695. */
  51696. deltaPosition: Vector3;
  51697. /**
  51698. * Gets a boolean indicating if the virtual joystick was pressed
  51699. */
  51700. pressed: boolean;
  51701. /**
  51702. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51703. */
  51704. static Canvas: Nullable<HTMLCanvasElement>;
  51705. /**
  51706. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51707. */
  51708. limitToContainer: boolean;
  51709. private static _globalJoystickIndex;
  51710. private static _alwaysVisibleSticks;
  51711. private static vjCanvasContext;
  51712. private static vjCanvasWidth;
  51713. private static vjCanvasHeight;
  51714. private static halfWidth;
  51715. private static _GetDefaultOptions;
  51716. private _action;
  51717. private _axisTargetedByLeftAndRight;
  51718. private _axisTargetedByUpAndDown;
  51719. private _joystickSensibility;
  51720. private _inversedSensibility;
  51721. private _joystickPointerID;
  51722. private _joystickColor;
  51723. private _joystickPointerPos;
  51724. private _joystickPreviousPointerPos;
  51725. private _joystickPointerStartPos;
  51726. private _deltaJoystickVector;
  51727. private _leftJoystick;
  51728. private _touches;
  51729. private _joystickPosition;
  51730. private _alwaysVisible;
  51731. private _puckImage;
  51732. private _containerImage;
  51733. private _joystickPuckSize;
  51734. private _joystickContainerSize;
  51735. private _clearPuckSize;
  51736. private _clearContainerSize;
  51737. private _clearPuckSizeOffset;
  51738. private _clearContainerSizeOffset;
  51739. private _onPointerDownHandlerRef;
  51740. private _onPointerMoveHandlerRef;
  51741. private _onPointerUpHandlerRef;
  51742. private _onResize;
  51743. /**
  51744. * Creates a new virtual joystick
  51745. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51746. * @param customizations Defines the options we want to customize the VirtualJoystick
  51747. */
  51748. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51749. /**
  51750. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51751. * @param newJoystickSensibility defines the new sensibility
  51752. */
  51753. setJoystickSensibility(newJoystickSensibility: number): void;
  51754. private _onPointerDown;
  51755. private _onPointerMove;
  51756. private _onPointerUp;
  51757. /**
  51758. * Change the color of the virtual joystick
  51759. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51760. */
  51761. setJoystickColor(newColor: string): void;
  51762. /**
  51763. * Size of the joystick's container
  51764. */
  51765. set containerSize(newSize: number);
  51766. get containerSize(): number;
  51767. /**
  51768. * Size of the joystick's puck
  51769. */
  51770. set puckSize(newSize: number);
  51771. get puckSize(): number;
  51772. /**
  51773. * Clears the set position of the joystick
  51774. */
  51775. clearPosition(): void;
  51776. /**
  51777. * Defines whether or not the joystick container is always visible
  51778. */
  51779. set alwaysVisible(value: boolean);
  51780. get alwaysVisible(): boolean;
  51781. /**
  51782. * Sets the constant position of the Joystick container
  51783. * @param x X axis coordinate
  51784. * @param y Y axis coordinate
  51785. */
  51786. setPosition(x: number, y: number): void;
  51787. /**
  51788. * Defines a callback to call when the joystick is touched
  51789. * @param action defines the callback
  51790. */
  51791. setActionOnTouch(action: () => any): void;
  51792. /**
  51793. * Defines which axis you'd like to control for left & right
  51794. * @param axis defines the axis to use
  51795. */
  51796. setAxisForLeftRight(axis: JoystickAxis): void;
  51797. /**
  51798. * Defines which axis you'd like to control for up & down
  51799. * @param axis defines the axis to use
  51800. */
  51801. setAxisForUpDown(axis: JoystickAxis): void;
  51802. /**
  51803. * Clears the canvas from the previous puck / container draw
  51804. */
  51805. private _clearPreviousDraw;
  51806. /**
  51807. * Loads `urlPath` to be used for the container's image
  51808. * @param urlPath defines the urlPath of an image to use
  51809. */
  51810. setContainerImage(urlPath: string): void;
  51811. /**
  51812. * Loads `urlPath` to be used for the puck's image
  51813. * @param urlPath defines the urlPath of an image to use
  51814. */
  51815. setPuckImage(urlPath: string): void;
  51816. /**
  51817. * Draws the Virtual Joystick's container
  51818. */
  51819. private _drawContainer;
  51820. /**
  51821. * Draws the Virtual Joystick's puck
  51822. */
  51823. private _drawPuck;
  51824. private _drawVirtualJoystick;
  51825. /**
  51826. * Release internal HTML canvas
  51827. */
  51828. releaseCanvas(): void;
  51829. }
  51830. }
  51831. declare module BABYLON {
  51832. interface FreeCameraInputsManager {
  51833. /**
  51834. * Add virtual joystick input support to the input manager.
  51835. * @returns the current input manager
  51836. */
  51837. addVirtualJoystick(): FreeCameraInputsManager;
  51838. }
  51839. /**
  51840. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51841. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51842. */
  51843. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51844. /**
  51845. * Defines the camera the input is attached to.
  51846. */
  51847. camera: FreeCamera;
  51848. private _leftjoystick;
  51849. private _rightjoystick;
  51850. /**
  51851. * Gets the left stick of the virtual joystick.
  51852. * @returns The virtual Joystick
  51853. */
  51854. getLeftJoystick(): VirtualJoystick;
  51855. /**
  51856. * Gets the right stick of the virtual joystick.
  51857. * @returns The virtual Joystick
  51858. */
  51859. getRightJoystick(): VirtualJoystick;
  51860. /**
  51861. * Update the current camera state depending on the inputs that have been used this frame.
  51862. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51863. */
  51864. checkInputs(): void;
  51865. /**
  51866. * Attach the input controls to a specific dom element to get the input from.
  51867. */
  51868. attachControl(): void;
  51869. /**
  51870. * Detach the current controls from the specified dom element.
  51871. */
  51872. detachControl(): void;
  51873. /**
  51874. * Gets the class name of the current intput.
  51875. * @returns the class name
  51876. */
  51877. getClassName(): string;
  51878. /**
  51879. * Get the friendly name associated with the input class.
  51880. * @returns the input friendly name
  51881. */
  51882. getSimpleName(): string;
  51883. }
  51884. }
  51885. declare module BABYLON {
  51886. /**
  51887. * This represents a FPS type of camera controlled by touch.
  51888. * This is like a universal camera minus the Gamepad controls.
  51889. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51890. */
  51891. export class TouchCamera extends FreeCamera {
  51892. /**
  51893. * Defines the touch sensibility for rotation.
  51894. * The higher the faster.
  51895. */
  51896. get touchAngularSensibility(): number;
  51897. set touchAngularSensibility(value: number);
  51898. /**
  51899. * Defines the touch sensibility for move.
  51900. * The higher the faster.
  51901. */
  51902. get touchMoveSensibility(): number;
  51903. set touchMoveSensibility(value: number);
  51904. /**
  51905. * Instantiates a new touch camera.
  51906. * This represents a FPS type of camera controlled by touch.
  51907. * This is like a universal camera minus the Gamepad controls.
  51908. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51909. * @param name Define the name of the camera in the scene
  51910. * @param position Define the start position of the camera in the scene
  51911. * @param scene Define the scene the camera belongs to
  51912. */
  51913. constructor(name: string, position: Vector3, scene: Scene);
  51914. /**
  51915. * Gets the current object class name.
  51916. * @return the class name
  51917. */
  51918. getClassName(): string;
  51919. /** @hidden */
  51920. _setupInputs(): void;
  51921. }
  51922. }
  51923. declare module BABYLON {
  51924. /**
  51925. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  51926. * being tilted forward or back and left or right.
  51927. */
  51928. export class DeviceOrientationCamera extends FreeCamera {
  51929. private _initialQuaternion;
  51930. private _quaternionCache;
  51931. private _tmpDragQuaternion;
  51932. private _disablePointerInputWhenUsingDeviceOrientation;
  51933. /**
  51934. * Creates a new device orientation camera
  51935. * @param name The name of the camera
  51936. * @param position The start position camera
  51937. * @param scene The scene the camera belongs to
  51938. */
  51939. constructor(name: string, position: Vector3, scene: Scene);
  51940. /**
  51941. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  51942. */
  51943. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  51944. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  51945. private _dragFactor;
  51946. /**
  51947. * Enabled turning on the y axis when the orientation sensor is active
  51948. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  51949. */
  51950. enableHorizontalDragging(dragFactor?: number): void;
  51951. /**
  51952. * Gets the current instance class name ("DeviceOrientationCamera").
  51953. * This helps avoiding instanceof at run time.
  51954. * @returns the class name
  51955. */
  51956. getClassName(): string;
  51957. /**
  51958. * @hidden
  51959. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  51960. */
  51961. _checkInputs(): void;
  51962. /**
  51963. * Reset the camera to its default orientation on the specified axis only.
  51964. * @param axis The axis to reset
  51965. */
  51966. resetToCurrentRotation(axis?: Axis): void;
  51967. }
  51968. }
  51969. declare module BABYLON {
  51970. /**
  51971. * Defines supported buttons for XBox360 compatible gamepads
  51972. */
  51973. export enum Xbox360Button {
  51974. /** A */
  51975. A = 0,
  51976. /** B */
  51977. B = 1,
  51978. /** X */
  51979. X = 2,
  51980. /** Y */
  51981. Y = 3,
  51982. /** Left button */
  51983. LB = 4,
  51984. /** Right button */
  51985. RB = 5,
  51986. /** Back */
  51987. Back = 8,
  51988. /** Start */
  51989. Start = 9,
  51990. /** Left stick */
  51991. LeftStick = 10,
  51992. /** Right stick */
  51993. RightStick = 11
  51994. }
  51995. /** Defines values for XBox360 DPad */
  51996. export enum Xbox360Dpad {
  51997. /** Up */
  51998. Up = 12,
  51999. /** Down */
  52000. Down = 13,
  52001. /** Left */
  52002. Left = 14,
  52003. /** Right */
  52004. Right = 15
  52005. }
  52006. /**
  52007. * Defines a XBox360 gamepad
  52008. */
  52009. export class Xbox360Pad extends Gamepad {
  52010. private _leftTrigger;
  52011. private _rightTrigger;
  52012. private _onlefttriggerchanged;
  52013. private _onrighttriggerchanged;
  52014. private _onbuttondown;
  52015. private _onbuttonup;
  52016. private _ondpaddown;
  52017. private _ondpadup;
  52018. /** Observable raised when a button is pressed */
  52019. onButtonDownObservable: Observable<Xbox360Button>;
  52020. /** Observable raised when a button is released */
  52021. onButtonUpObservable: Observable<Xbox360Button>;
  52022. /** Observable raised when a pad is pressed */
  52023. onPadDownObservable: Observable<Xbox360Dpad>;
  52024. /** Observable raised when a pad is released */
  52025. onPadUpObservable: Observable<Xbox360Dpad>;
  52026. private _buttonA;
  52027. private _buttonB;
  52028. private _buttonX;
  52029. private _buttonY;
  52030. private _buttonBack;
  52031. private _buttonStart;
  52032. private _buttonLB;
  52033. private _buttonRB;
  52034. private _buttonLeftStick;
  52035. private _buttonRightStick;
  52036. private _dPadUp;
  52037. private _dPadDown;
  52038. private _dPadLeft;
  52039. private _dPadRight;
  52040. private _isXboxOnePad;
  52041. /**
  52042. * Creates a new XBox360 gamepad object
  52043. * @param id defines the id of this gamepad
  52044. * @param index defines its index
  52045. * @param gamepad defines the internal HTML gamepad object
  52046. * @param xboxOne defines if it is a XBox One gamepad
  52047. */
  52048. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52049. /**
  52050. * Defines the callback to call when left trigger is pressed
  52051. * @param callback defines the callback to use
  52052. */
  52053. onlefttriggerchanged(callback: (value: number) => void): void;
  52054. /**
  52055. * Defines the callback to call when right trigger is pressed
  52056. * @param callback defines the callback to use
  52057. */
  52058. onrighttriggerchanged(callback: (value: number) => void): void;
  52059. /**
  52060. * Gets the left trigger value
  52061. */
  52062. get leftTrigger(): number;
  52063. /**
  52064. * Sets the left trigger value
  52065. */
  52066. set leftTrigger(newValue: number);
  52067. /**
  52068. * Gets the right trigger value
  52069. */
  52070. get rightTrigger(): number;
  52071. /**
  52072. * Sets the right trigger value
  52073. */
  52074. set rightTrigger(newValue: number);
  52075. /**
  52076. * Defines the callback to call when a button is pressed
  52077. * @param callback defines the callback to use
  52078. */
  52079. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52080. /**
  52081. * Defines the callback to call when a button is released
  52082. * @param callback defines the callback to use
  52083. */
  52084. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52085. /**
  52086. * Defines the callback to call when a pad is pressed
  52087. * @param callback defines the callback to use
  52088. */
  52089. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52090. /**
  52091. * Defines the callback to call when a pad is released
  52092. * @param callback defines the callback to use
  52093. */
  52094. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52095. private _setButtonValue;
  52096. private _setDPadValue;
  52097. /**
  52098. * Gets the value of the `A` button
  52099. */
  52100. get buttonA(): number;
  52101. /**
  52102. * Sets the value of the `A` button
  52103. */
  52104. set buttonA(value: number);
  52105. /**
  52106. * Gets the value of the `B` button
  52107. */
  52108. get buttonB(): number;
  52109. /**
  52110. * Sets the value of the `B` button
  52111. */
  52112. set buttonB(value: number);
  52113. /**
  52114. * Gets the value of the `X` button
  52115. */
  52116. get buttonX(): number;
  52117. /**
  52118. * Sets the value of the `X` button
  52119. */
  52120. set buttonX(value: number);
  52121. /**
  52122. * Gets the value of the `Y` button
  52123. */
  52124. get buttonY(): number;
  52125. /**
  52126. * Sets the value of the `Y` button
  52127. */
  52128. set buttonY(value: number);
  52129. /**
  52130. * Gets the value of the `Start` button
  52131. */
  52132. get buttonStart(): number;
  52133. /**
  52134. * Sets the value of the `Start` button
  52135. */
  52136. set buttonStart(value: number);
  52137. /**
  52138. * Gets the value of the `Back` button
  52139. */
  52140. get buttonBack(): number;
  52141. /**
  52142. * Sets the value of the `Back` button
  52143. */
  52144. set buttonBack(value: number);
  52145. /**
  52146. * Gets the value of the `Left` button
  52147. */
  52148. get buttonLB(): number;
  52149. /**
  52150. * Sets the value of the `Left` button
  52151. */
  52152. set buttonLB(value: number);
  52153. /**
  52154. * Gets the value of the `Right` button
  52155. */
  52156. get buttonRB(): number;
  52157. /**
  52158. * Sets the value of the `Right` button
  52159. */
  52160. set buttonRB(value: number);
  52161. /**
  52162. * Gets the value of the Left joystick
  52163. */
  52164. get buttonLeftStick(): number;
  52165. /**
  52166. * Sets the value of the Left joystick
  52167. */
  52168. set buttonLeftStick(value: number);
  52169. /**
  52170. * Gets the value of the Right joystick
  52171. */
  52172. get buttonRightStick(): number;
  52173. /**
  52174. * Sets the value of the Right joystick
  52175. */
  52176. set buttonRightStick(value: number);
  52177. /**
  52178. * Gets the value of D-pad up
  52179. */
  52180. get dPadUp(): number;
  52181. /**
  52182. * Sets the value of D-pad up
  52183. */
  52184. set dPadUp(value: number);
  52185. /**
  52186. * Gets the value of D-pad down
  52187. */
  52188. get dPadDown(): number;
  52189. /**
  52190. * Sets the value of D-pad down
  52191. */
  52192. set dPadDown(value: number);
  52193. /**
  52194. * Gets the value of D-pad left
  52195. */
  52196. get dPadLeft(): number;
  52197. /**
  52198. * Sets the value of D-pad left
  52199. */
  52200. set dPadLeft(value: number);
  52201. /**
  52202. * Gets the value of D-pad right
  52203. */
  52204. get dPadRight(): number;
  52205. /**
  52206. * Sets the value of D-pad right
  52207. */
  52208. set dPadRight(value: number);
  52209. /**
  52210. * Force the gamepad to synchronize with device values
  52211. */
  52212. update(): void;
  52213. /**
  52214. * Disposes the gamepad
  52215. */
  52216. dispose(): void;
  52217. }
  52218. }
  52219. declare module BABYLON {
  52220. /**
  52221. * Defines supported buttons for DualShock compatible gamepads
  52222. */
  52223. export enum DualShockButton {
  52224. /** Cross */
  52225. Cross = 0,
  52226. /** Circle */
  52227. Circle = 1,
  52228. /** Square */
  52229. Square = 2,
  52230. /** Triangle */
  52231. Triangle = 3,
  52232. /** L1 */
  52233. L1 = 4,
  52234. /** R1 */
  52235. R1 = 5,
  52236. /** Share */
  52237. Share = 8,
  52238. /** Options */
  52239. Options = 9,
  52240. /** Left stick */
  52241. LeftStick = 10,
  52242. /** Right stick */
  52243. RightStick = 11
  52244. }
  52245. /** Defines values for DualShock DPad */
  52246. export enum DualShockDpad {
  52247. /** Up */
  52248. Up = 12,
  52249. /** Down */
  52250. Down = 13,
  52251. /** Left */
  52252. Left = 14,
  52253. /** Right */
  52254. Right = 15
  52255. }
  52256. /**
  52257. * Defines a DualShock gamepad
  52258. */
  52259. export class DualShockPad extends Gamepad {
  52260. private _leftTrigger;
  52261. private _rightTrigger;
  52262. private _onlefttriggerchanged;
  52263. private _onrighttriggerchanged;
  52264. private _onbuttondown;
  52265. private _onbuttonup;
  52266. private _ondpaddown;
  52267. private _ondpadup;
  52268. /** Observable raised when a button is pressed */
  52269. onButtonDownObservable: Observable<DualShockButton>;
  52270. /** Observable raised when a button is released */
  52271. onButtonUpObservable: Observable<DualShockButton>;
  52272. /** Observable raised when a pad is pressed */
  52273. onPadDownObservable: Observable<DualShockDpad>;
  52274. /** Observable raised when a pad is released */
  52275. onPadUpObservable: Observable<DualShockDpad>;
  52276. private _buttonCross;
  52277. private _buttonCircle;
  52278. private _buttonSquare;
  52279. private _buttonTriangle;
  52280. private _buttonShare;
  52281. private _buttonOptions;
  52282. private _buttonL1;
  52283. private _buttonR1;
  52284. private _buttonLeftStick;
  52285. private _buttonRightStick;
  52286. private _dPadUp;
  52287. private _dPadDown;
  52288. private _dPadLeft;
  52289. private _dPadRight;
  52290. /**
  52291. * Creates a new DualShock gamepad object
  52292. * @param id defines the id of this gamepad
  52293. * @param index defines its index
  52294. * @param gamepad defines the internal HTML gamepad object
  52295. */
  52296. constructor(id: string, index: number, gamepad: any);
  52297. /**
  52298. * Defines the callback to call when left trigger is pressed
  52299. * @param callback defines the callback to use
  52300. */
  52301. onlefttriggerchanged(callback: (value: number) => void): void;
  52302. /**
  52303. * Defines the callback to call when right trigger is pressed
  52304. * @param callback defines the callback to use
  52305. */
  52306. onrighttriggerchanged(callback: (value: number) => void): void;
  52307. /**
  52308. * Gets the left trigger value
  52309. */
  52310. get leftTrigger(): number;
  52311. /**
  52312. * Sets the left trigger value
  52313. */
  52314. set leftTrigger(newValue: number);
  52315. /**
  52316. * Gets the right trigger value
  52317. */
  52318. get rightTrigger(): number;
  52319. /**
  52320. * Sets the right trigger value
  52321. */
  52322. set rightTrigger(newValue: number);
  52323. /**
  52324. * Defines the callback to call when a button is pressed
  52325. * @param callback defines the callback to use
  52326. */
  52327. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52328. /**
  52329. * Defines the callback to call when a button is released
  52330. * @param callback defines the callback to use
  52331. */
  52332. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52333. /**
  52334. * Defines the callback to call when a pad is pressed
  52335. * @param callback defines the callback to use
  52336. */
  52337. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52338. /**
  52339. * Defines the callback to call when a pad is released
  52340. * @param callback defines the callback to use
  52341. */
  52342. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52343. private _setButtonValue;
  52344. private _setDPadValue;
  52345. /**
  52346. * Gets the value of the `Cross` button
  52347. */
  52348. get buttonCross(): number;
  52349. /**
  52350. * Sets the value of the `Cross` button
  52351. */
  52352. set buttonCross(value: number);
  52353. /**
  52354. * Gets the value of the `Circle` button
  52355. */
  52356. get buttonCircle(): number;
  52357. /**
  52358. * Sets the value of the `Circle` button
  52359. */
  52360. set buttonCircle(value: number);
  52361. /**
  52362. * Gets the value of the `Square` button
  52363. */
  52364. get buttonSquare(): number;
  52365. /**
  52366. * Sets the value of the `Square` button
  52367. */
  52368. set buttonSquare(value: number);
  52369. /**
  52370. * Gets the value of the `Triangle` button
  52371. */
  52372. get buttonTriangle(): number;
  52373. /**
  52374. * Sets the value of the `Triangle` button
  52375. */
  52376. set buttonTriangle(value: number);
  52377. /**
  52378. * Gets the value of the `Options` button
  52379. */
  52380. get buttonOptions(): number;
  52381. /**
  52382. * Sets the value of the `Options` button
  52383. */
  52384. set buttonOptions(value: number);
  52385. /**
  52386. * Gets the value of the `Share` button
  52387. */
  52388. get buttonShare(): number;
  52389. /**
  52390. * Sets the value of the `Share` button
  52391. */
  52392. set buttonShare(value: number);
  52393. /**
  52394. * Gets the value of the `L1` button
  52395. */
  52396. get buttonL1(): number;
  52397. /**
  52398. * Sets the value of the `L1` button
  52399. */
  52400. set buttonL1(value: number);
  52401. /**
  52402. * Gets the value of the `R1` button
  52403. */
  52404. get buttonR1(): number;
  52405. /**
  52406. * Sets the value of the `R1` button
  52407. */
  52408. set buttonR1(value: number);
  52409. /**
  52410. * Gets the value of the Left joystick
  52411. */
  52412. get buttonLeftStick(): number;
  52413. /**
  52414. * Sets the value of the Left joystick
  52415. */
  52416. set buttonLeftStick(value: number);
  52417. /**
  52418. * Gets the value of the Right joystick
  52419. */
  52420. get buttonRightStick(): number;
  52421. /**
  52422. * Sets the value of the Right joystick
  52423. */
  52424. set buttonRightStick(value: number);
  52425. /**
  52426. * Gets the value of D-pad up
  52427. */
  52428. get dPadUp(): number;
  52429. /**
  52430. * Sets the value of D-pad up
  52431. */
  52432. set dPadUp(value: number);
  52433. /**
  52434. * Gets the value of D-pad down
  52435. */
  52436. get dPadDown(): number;
  52437. /**
  52438. * Sets the value of D-pad down
  52439. */
  52440. set dPadDown(value: number);
  52441. /**
  52442. * Gets the value of D-pad left
  52443. */
  52444. get dPadLeft(): number;
  52445. /**
  52446. * Sets the value of D-pad left
  52447. */
  52448. set dPadLeft(value: number);
  52449. /**
  52450. * Gets the value of D-pad right
  52451. */
  52452. get dPadRight(): number;
  52453. /**
  52454. * Sets the value of D-pad right
  52455. */
  52456. set dPadRight(value: number);
  52457. /**
  52458. * Force the gamepad to synchronize with device values
  52459. */
  52460. update(): void;
  52461. /**
  52462. * Disposes the gamepad
  52463. */
  52464. dispose(): void;
  52465. }
  52466. }
  52467. declare module BABYLON {
  52468. /**
  52469. * Manager for handling gamepads
  52470. */
  52471. export class GamepadManager {
  52472. private _scene?;
  52473. private _babylonGamepads;
  52474. private _oneGamepadConnected;
  52475. /** @hidden */
  52476. _isMonitoring: boolean;
  52477. private _gamepadEventSupported;
  52478. private _gamepadSupport?;
  52479. /**
  52480. * observable to be triggered when the gamepad controller has been connected
  52481. */
  52482. onGamepadConnectedObservable: Observable<Gamepad>;
  52483. /**
  52484. * observable to be triggered when the gamepad controller has been disconnected
  52485. */
  52486. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52487. private _onGamepadConnectedEvent;
  52488. private _onGamepadDisconnectedEvent;
  52489. /**
  52490. * Initializes the gamepad manager
  52491. * @param _scene BabylonJS scene
  52492. */
  52493. constructor(_scene?: Scene | undefined);
  52494. /**
  52495. * The gamepads in the game pad manager
  52496. */
  52497. get gamepads(): Gamepad[];
  52498. /**
  52499. * Get the gamepad controllers based on type
  52500. * @param type The type of gamepad controller
  52501. * @returns Nullable gamepad
  52502. */
  52503. getGamepadByType(type?: number): Nullable<Gamepad>;
  52504. /**
  52505. * Disposes the gamepad manager
  52506. */
  52507. dispose(): void;
  52508. private _addNewGamepad;
  52509. private _startMonitoringGamepads;
  52510. private _stopMonitoringGamepads;
  52511. /** @hidden */
  52512. _checkGamepadsStatus(): void;
  52513. private _updateGamepadObjects;
  52514. }
  52515. }
  52516. declare module BABYLON {
  52517. interface Scene {
  52518. /** @hidden */
  52519. _gamepadManager: Nullable<GamepadManager>;
  52520. /**
  52521. * Gets the gamepad manager associated with the scene
  52522. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52523. */
  52524. gamepadManager: GamepadManager;
  52525. }
  52526. /**
  52527. * Interface representing a free camera inputs manager
  52528. */
  52529. interface FreeCameraInputsManager {
  52530. /**
  52531. * Adds gamepad input support to the FreeCameraInputsManager.
  52532. * @returns the FreeCameraInputsManager
  52533. */
  52534. addGamepad(): FreeCameraInputsManager;
  52535. }
  52536. /**
  52537. * Interface representing an arc rotate camera inputs manager
  52538. */
  52539. interface ArcRotateCameraInputsManager {
  52540. /**
  52541. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52542. * @returns the camera inputs manager
  52543. */
  52544. addGamepad(): ArcRotateCameraInputsManager;
  52545. }
  52546. /**
  52547. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52548. */
  52549. export class GamepadSystemSceneComponent implements ISceneComponent {
  52550. /**
  52551. * The component name helpfull to identify the component in the list of scene components.
  52552. */
  52553. readonly name: string;
  52554. /**
  52555. * The scene the component belongs to.
  52556. */
  52557. scene: Scene;
  52558. /**
  52559. * Creates a new instance of the component for the given scene
  52560. * @param scene Defines the scene to register the component in
  52561. */
  52562. constructor(scene: Scene);
  52563. /**
  52564. * Registers the component in a given scene
  52565. */
  52566. register(): void;
  52567. /**
  52568. * Rebuilds the elements related to this component in case of
  52569. * context lost for instance.
  52570. */
  52571. rebuild(): void;
  52572. /**
  52573. * Disposes the component and the associated ressources
  52574. */
  52575. dispose(): void;
  52576. private _beforeCameraUpdate;
  52577. }
  52578. }
  52579. declare module BABYLON {
  52580. /**
  52581. * 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,
  52582. * which still works and will still be found in many Playgrounds.
  52583. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52584. */
  52585. export class UniversalCamera extends TouchCamera {
  52586. /**
  52587. * Defines the gamepad rotation sensiblity.
  52588. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52589. */
  52590. get gamepadAngularSensibility(): number;
  52591. set gamepadAngularSensibility(value: number);
  52592. /**
  52593. * Defines the gamepad move sensiblity.
  52594. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52595. */
  52596. get gamepadMoveSensibility(): number;
  52597. set gamepadMoveSensibility(value: number);
  52598. /**
  52599. * 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,
  52600. * which still works and will still be found in many Playgrounds.
  52601. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52602. * @param name Define the name of the camera in the scene
  52603. * @param position Define the start position of the camera in the scene
  52604. * @param scene Define the scene the camera belongs to
  52605. */
  52606. constructor(name: string, position: Vector3, scene: Scene);
  52607. /**
  52608. * Gets the current object class name.
  52609. * @return the class name
  52610. */
  52611. getClassName(): string;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * This represents a FPS type of camera. This is only here for back compat purpose.
  52617. * Please use the UniversalCamera instead as both are identical.
  52618. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52619. */
  52620. export class GamepadCamera extends UniversalCamera {
  52621. /**
  52622. * Instantiates a new Gamepad Camera
  52623. * This represents a FPS type of camera. This is only here for back compat purpose.
  52624. * Please use the UniversalCamera instead as both are identical.
  52625. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52626. * @param name Define the name of the camera in the scene
  52627. * @param position Define the start position of the camera in the scene
  52628. * @param scene Define the scene the camera belongs to
  52629. */
  52630. constructor(name: string, position: Vector3, scene: Scene);
  52631. /**
  52632. * Gets the current object class name.
  52633. * @return the class name
  52634. */
  52635. getClassName(): string;
  52636. }
  52637. }
  52638. declare module BABYLON {
  52639. /** @hidden */
  52640. export var anaglyphPixelShader: {
  52641. name: string;
  52642. shader: string;
  52643. };
  52644. }
  52645. declare module BABYLON {
  52646. /**
  52647. * Postprocess used to generate anaglyphic rendering
  52648. */
  52649. export class AnaglyphPostProcess extends PostProcess {
  52650. private _passedProcess;
  52651. /**
  52652. * Gets a string identifying the name of the class
  52653. * @returns "AnaglyphPostProcess" string
  52654. */
  52655. getClassName(): string;
  52656. /**
  52657. * Creates a new AnaglyphPostProcess
  52658. * @param name defines postprocess name
  52659. * @param options defines creation options or target ratio scale
  52660. * @param rigCameras defines cameras using this postprocess
  52661. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52662. * @param engine defines hosting engine
  52663. * @param reusable defines if the postprocess will be reused multiple times per frame
  52664. */
  52665. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52666. }
  52667. }
  52668. declare module BABYLON {
  52669. /**
  52670. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52671. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52672. */
  52673. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52674. /**
  52675. * Creates a new AnaglyphArcRotateCamera
  52676. * @param name defines camera name
  52677. * @param alpha defines alpha angle (in radians)
  52678. * @param beta defines beta angle (in radians)
  52679. * @param radius defines radius
  52680. * @param target defines camera target
  52681. * @param interaxialDistance defines distance between each color axis
  52682. * @param scene defines the hosting scene
  52683. */
  52684. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52685. /**
  52686. * Gets camera class name
  52687. * @returns AnaglyphArcRotateCamera
  52688. */
  52689. getClassName(): string;
  52690. }
  52691. }
  52692. declare module BABYLON {
  52693. /**
  52694. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52695. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52696. */
  52697. export class AnaglyphFreeCamera extends FreeCamera {
  52698. /**
  52699. * Creates a new AnaglyphFreeCamera
  52700. * @param name defines camera name
  52701. * @param position defines initial position
  52702. * @param interaxialDistance defines distance between each color axis
  52703. * @param scene defines the hosting scene
  52704. */
  52705. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52706. /**
  52707. * Gets camera class name
  52708. * @returns AnaglyphFreeCamera
  52709. */
  52710. getClassName(): string;
  52711. }
  52712. }
  52713. declare module BABYLON {
  52714. /**
  52715. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52716. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52717. */
  52718. export class AnaglyphGamepadCamera extends GamepadCamera {
  52719. /**
  52720. * Creates a new AnaglyphGamepadCamera
  52721. * @param name defines camera name
  52722. * @param position defines initial position
  52723. * @param interaxialDistance defines distance between each color axis
  52724. * @param scene defines the hosting scene
  52725. */
  52726. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52727. /**
  52728. * Gets camera class name
  52729. * @returns AnaglyphGamepadCamera
  52730. */
  52731. getClassName(): string;
  52732. }
  52733. }
  52734. declare module BABYLON {
  52735. /**
  52736. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52737. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52738. */
  52739. export class AnaglyphUniversalCamera extends UniversalCamera {
  52740. /**
  52741. * Creates a new AnaglyphUniversalCamera
  52742. * @param name defines camera name
  52743. * @param position defines initial position
  52744. * @param interaxialDistance defines distance between each color axis
  52745. * @param scene defines the hosting scene
  52746. */
  52747. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52748. /**
  52749. * Gets camera class name
  52750. * @returns AnaglyphUniversalCamera
  52751. */
  52752. getClassName(): string;
  52753. }
  52754. }
  52755. declare module BABYLON {
  52756. /** @hidden */
  52757. export var stereoscopicInterlacePixelShader: {
  52758. name: string;
  52759. shader: string;
  52760. };
  52761. }
  52762. declare module BABYLON {
  52763. /**
  52764. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  52765. */
  52766. export class StereoscopicInterlacePostProcessI extends PostProcess {
  52767. private _stepSize;
  52768. private _passedProcess;
  52769. /**
  52770. * Gets a string identifying the name of the class
  52771. * @returns "StereoscopicInterlacePostProcessI" string
  52772. */
  52773. getClassName(): string;
  52774. /**
  52775. * Initializes a StereoscopicInterlacePostProcessI
  52776. * @param name The name of the effect.
  52777. * @param rigCameras The rig cameras to be appled to the post process
  52778. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  52779. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  52780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52781. * @param engine The engine which the post process will be applied. (default: current engine)
  52782. * @param reusable If the post process can be reused on the same frame. (default: false)
  52783. */
  52784. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52785. }
  52786. /**
  52787. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  52788. */
  52789. export class StereoscopicInterlacePostProcess extends PostProcess {
  52790. private _stepSize;
  52791. private _passedProcess;
  52792. /**
  52793. * Gets a string identifying the name of the class
  52794. * @returns "StereoscopicInterlacePostProcess" string
  52795. */
  52796. getClassName(): string;
  52797. /**
  52798. * Initializes a StereoscopicInterlacePostProcess
  52799. * @param name The name of the effect.
  52800. * @param rigCameras The rig cameras to be appled to the post process
  52801. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  52802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52803. * @param engine The engine which the post process will be applied. (default: current engine)
  52804. * @param reusable If the post process can be reused on the same frame. (default: false)
  52805. */
  52806. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52807. }
  52808. }
  52809. declare module BABYLON {
  52810. /**
  52811. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52812. * @see https://doc.babylonjs.com/features/cameras
  52813. */
  52814. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52815. /**
  52816. * Creates a new StereoscopicArcRotateCamera
  52817. * @param name defines camera name
  52818. * @param alpha defines alpha angle (in radians)
  52819. * @param beta defines beta angle (in radians)
  52820. * @param radius defines radius
  52821. * @param target defines camera target
  52822. * @param interaxialDistance defines distance between each color axis
  52823. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52824. * @param scene defines the hosting scene
  52825. */
  52826. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52827. /**
  52828. * Gets camera class name
  52829. * @returns StereoscopicArcRotateCamera
  52830. */
  52831. getClassName(): string;
  52832. }
  52833. }
  52834. declare module BABYLON {
  52835. /**
  52836. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52837. * @see https://doc.babylonjs.com/features/cameras
  52838. */
  52839. export class StereoscopicFreeCamera extends FreeCamera {
  52840. /**
  52841. * Creates a new StereoscopicFreeCamera
  52842. * @param name defines camera name
  52843. * @param position defines initial position
  52844. * @param interaxialDistance defines distance between each color axis
  52845. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52846. * @param scene defines the hosting scene
  52847. */
  52848. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52849. /**
  52850. * Gets camera class name
  52851. * @returns StereoscopicFreeCamera
  52852. */
  52853. getClassName(): string;
  52854. }
  52855. }
  52856. declare module BABYLON {
  52857. /**
  52858. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52859. * @see https://doc.babylonjs.com/features/cameras
  52860. */
  52861. export class StereoscopicGamepadCamera extends GamepadCamera {
  52862. /**
  52863. * Creates a new StereoscopicGamepadCamera
  52864. * @param name defines camera name
  52865. * @param position defines initial position
  52866. * @param interaxialDistance defines distance between each color axis
  52867. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52868. * @param scene defines the hosting scene
  52869. */
  52870. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52871. /**
  52872. * Gets camera class name
  52873. * @returns StereoscopicGamepadCamera
  52874. */
  52875. getClassName(): string;
  52876. }
  52877. }
  52878. declare module BABYLON {
  52879. /**
  52880. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52881. * @see https://doc.babylonjs.com/features/cameras
  52882. */
  52883. export class StereoscopicUniversalCamera extends UniversalCamera {
  52884. /**
  52885. * Creates a new StereoscopicUniversalCamera
  52886. * @param name defines camera name
  52887. * @param position defines initial position
  52888. * @param interaxialDistance defines distance between each color axis
  52889. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52890. * @param scene defines the hosting scene
  52891. */
  52892. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52893. /**
  52894. * Gets camera class name
  52895. * @returns StereoscopicUniversalCamera
  52896. */
  52897. getClassName(): string;
  52898. }
  52899. }
  52900. declare module BABYLON {
  52901. /**
  52902. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52903. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52904. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52905. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52906. */
  52907. export class VirtualJoysticksCamera extends FreeCamera {
  52908. /**
  52909. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52910. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52911. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52912. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52913. * @param name Define the name of the camera in the scene
  52914. * @param position Define the start position of the camera in the scene
  52915. * @param scene Define the scene the camera belongs to
  52916. */
  52917. constructor(name: string, position: Vector3, scene: Scene);
  52918. /**
  52919. * Gets the current object class name.
  52920. * @return the class name
  52921. */
  52922. getClassName(): string;
  52923. }
  52924. }
  52925. declare module BABYLON {
  52926. /**
  52927. * This represents all the required metrics to create a VR camera.
  52928. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  52929. */
  52930. export class VRCameraMetrics {
  52931. /**
  52932. * Define the horizontal resolution off the screen.
  52933. */
  52934. hResolution: number;
  52935. /**
  52936. * Define the vertical resolution off the screen.
  52937. */
  52938. vResolution: number;
  52939. /**
  52940. * Define the horizontal screen size.
  52941. */
  52942. hScreenSize: number;
  52943. /**
  52944. * Define the vertical screen size.
  52945. */
  52946. vScreenSize: number;
  52947. /**
  52948. * Define the vertical screen center position.
  52949. */
  52950. vScreenCenter: number;
  52951. /**
  52952. * Define the distance of the eyes to the screen.
  52953. */
  52954. eyeToScreenDistance: number;
  52955. /**
  52956. * Define the distance between both lenses
  52957. */
  52958. lensSeparationDistance: number;
  52959. /**
  52960. * Define the distance between both viewer's eyes.
  52961. */
  52962. interpupillaryDistance: number;
  52963. /**
  52964. * Define the distortion factor of the VR postprocess.
  52965. * Please, touch with care.
  52966. */
  52967. distortionK: number[];
  52968. /**
  52969. * Define the chromatic aberration correction factors for the VR post process.
  52970. */
  52971. chromaAbCorrection: number[];
  52972. /**
  52973. * Define the scale factor of the post process.
  52974. * The smaller the better but the slower.
  52975. */
  52976. postProcessScaleFactor: number;
  52977. /**
  52978. * Define an offset for the lens center.
  52979. */
  52980. lensCenterOffset: number;
  52981. /**
  52982. * Define if the current vr camera should compensate the distortion of the lense or not.
  52983. */
  52984. compensateDistortion: boolean;
  52985. /**
  52986. * Defines if multiview should be enabled when rendering (Default: false)
  52987. */
  52988. multiviewEnabled: boolean;
  52989. /**
  52990. * Gets the rendering aspect ratio based on the provided resolutions.
  52991. */
  52992. get aspectRatio(): number;
  52993. /**
  52994. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52995. */
  52996. get aspectRatioFov(): number;
  52997. /**
  52998. * @hidden
  52999. */
  53000. get leftHMatrix(): Matrix;
  53001. /**
  53002. * @hidden
  53003. */
  53004. get rightHMatrix(): Matrix;
  53005. /**
  53006. * @hidden
  53007. */
  53008. get leftPreViewMatrix(): Matrix;
  53009. /**
  53010. * @hidden
  53011. */
  53012. get rightPreViewMatrix(): Matrix;
  53013. /**
  53014. * Get the default VRMetrics based on the most generic setup.
  53015. * @returns the default vr metrics
  53016. */
  53017. static GetDefault(): VRCameraMetrics;
  53018. }
  53019. }
  53020. declare module BABYLON {
  53021. /** @hidden */
  53022. export var vrDistortionCorrectionPixelShader: {
  53023. name: string;
  53024. shader: string;
  53025. };
  53026. }
  53027. declare module BABYLON {
  53028. /**
  53029. * VRDistortionCorrectionPostProcess used for mobile VR
  53030. */
  53031. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53032. private _isRightEye;
  53033. private _distortionFactors;
  53034. private _postProcessScaleFactor;
  53035. private _lensCenterOffset;
  53036. private _scaleIn;
  53037. private _scaleFactor;
  53038. private _lensCenter;
  53039. /**
  53040. * Gets a string identifying the name of the class
  53041. * @returns "VRDistortionCorrectionPostProcess" string
  53042. */
  53043. getClassName(): string;
  53044. /**
  53045. * Initializes the VRDistortionCorrectionPostProcess
  53046. * @param name The name of the effect.
  53047. * @param camera The camera to apply the render pass to.
  53048. * @param isRightEye If this is for the right eye distortion
  53049. * @param vrMetrics All the required metrics for the VR camera
  53050. */
  53051. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53052. }
  53053. }
  53054. declare module BABYLON {
  53055. /**
  53056. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53057. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53058. */
  53059. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53060. /**
  53061. * Creates a new VRDeviceOrientationArcRotateCamera
  53062. * @param name defines camera name
  53063. * @param alpha defines the camera rotation along the logitudinal axis
  53064. * @param beta defines the camera rotation along the latitudinal axis
  53065. * @param radius defines the camera distance from its target
  53066. * @param target defines the camera target
  53067. * @param scene defines the scene the camera belongs to
  53068. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53069. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53070. */
  53071. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53072. /**
  53073. * Gets camera class name
  53074. * @returns VRDeviceOrientationArcRotateCamera
  53075. */
  53076. getClassName(): string;
  53077. }
  53078. }
  53079. declare module BABYLON {
  53080. /**
  53081. * Camera used to simulate VR rendering (based on FreeCamera)
  53082. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53083. */
  53084. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53085. /**
  53086. * Creates a new VRDeviceOrientationFreeCamera
  53087. * @param name defines camera name
  53088. * @param position defines the start position of the camera
  53089. * @param scene defines the scene the camera belongs to
  53090. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53091. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53092. */
  53093. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53094. /**
  53095. * Gets camera class name
  53096. * @returns VRDeviceOrientationFreeCamera
  53097. */
  53098. getClassName(): string;
  53099. }
  53100. }
  53101. declare module BABYLON {
  53102. /**
  53103. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53104. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53105. */
  53106. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53107. /**
  53108. * Creates a new VRDeviceOrientationGamepadCamera
  53109. * @param name defines camera name
  53110. * @param position defines the start position of the camera
  53111. * @param scene defines the scene the camera belongs to
  53112. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  53113. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53114. */
  53115. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53116. /**
  53117. * Gets camera class name
  53118. * @returns VRDeviceOrientationGamepadCamera
  53119. */
  53120. getClassName(): string;
  53121. }
  53122. }
  53123. declare module BABYLON {
  53124. /**
  53125. * A class extending Texture allowing drawing on a texture
  53126. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53127. */
  53128. export class DynamicTexture extends Texture {
  53129. private _generateMipMaps;
  53130. private _canvas;
  53131. private _context;
  53132. /**
  53133. * Creates a DynamicTexture
  53134. * @param name defines the name of the texture
  53135. * @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
  53136. * @param scene defines the scene where you want the texture
  53137. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53138. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53139. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53140. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53141. */
  53142. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53143. /**
  53144. * Get the current class name of the texture useful for serialization or dynamic coding.
  53145. * @returns "DynamicTexture"
  53146. */
  53147. getClassName(): string;
  53148. /**
  53149. * Gets the current state of canRescale
  53150. */
  53151. get canRescale(): boolean;
  53152. private _recreate;
  53153. /**
  53154. * Scales the texture
  53155. * @param ratio the scale factor to apply to both width and height
  53156. */
  53157. scale(ratio: number): void;
  53158. /**
  53159. * Resizes the texture
  53160. * @param width the new width
  53161. * @param height the new height
  53162. */
  53163. scaleTo(width: number, height: number): void;
  53164. /**
  53165. * Gets the context of the canvas used by the texture
  53166. * @returns the canvas context of the dynamic texture
  53167. */
  53168. getContext(): CanvasRenderingContext2D;
  53169. /**
  53170. * Clears the texture
  53171. */
  53172. clear(): void;
  53173. /**
  53174. * Updates the texture
  53175. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53176. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53177. */
  53178. update(invertY?: boolean, premulAlpha?: boolean): void;
  53179. /**
  53180. * Draws text onto the texture
  53181. * @param text defines the text to be drawn
  53182. * @param x defines the placement of the text from the left
  53183. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53184. * @param font defines the font to be used with font-style, font-size, font-name
  53185. * @param color defines the color used for the text
  53186. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53187. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53188. * @param update defines whether texture is immediately update (default is true)
  53189. */
  53190. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53191. /**
  53192. * Clones the texture
  53193. * @returns the clone of the texture.
  53194. */
  53195. clone(): DynamicTexture;
  53196. /**
  53197. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53198. * @returns a serialized dynamic texture object
  53199. */
  53200. serialize(): any;
  53201. private _IsCanvasElement;
  53202. /** @hidden */
  53203. _rebuild(): void;
  53204. }
  53205. }
  53206. declare module BABYLON {
  53207. /**
  53208. * Class containing static functions to help procedurally build meshes
  53209. */
  53210. export class GroundBuilder {
  53211. /**
  53212. * Creates a ground mesh
  53213. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53214. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53216. * @param name defines the name of the mesh
  53217. * @param options defines the options used to create the mesh
  53218. * @param scene defines the hosting scene
  53219. * @returns the ground mesh
  53220. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53221. */
  53222. static CreateGround(name: string, options: {
  53223. width?: number;
  53224. height?: number;
  53225. subdivisions?: number;
  53226. subdivisionsX?: number;
  53227. subdivisionsY?: number;
  53228. updatable?: boolean;
  53229. }, scene: any): Mesh;
  53230. /**
  53231. * Creates a tiled ground mesh
  53232. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53233. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53234. * * 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
  53235. * * 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
  53236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53237. * @param name defines the name of the mesh
  53238. * @param options defines the options used to create the mesh
  53239. * @param scene defines the hosting scene
  53240. * @returns the tiled ground mesh
  53241. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53242. */
  53243. static CreateTiledGround(name: string, options: {
  53244. xmin: number;
  53245. zmin: number;
  53246. xmax: number;
  53247. zmax: number;
  53248. subdivisions?: {
  53249. w: number;
  53250. h: number;
  53251. };
  53252. precision?: {
  53253. w: number;
  53254. h: number;
  53255. };
  53256. updatable?: boolean;
  53257. }, scene?: Nullable<Scene>): Mesh;
  53258. /**
  53259. * Creates a ground mesh from a height map
  53260. * * The parameter `url` sets the URL of the height map image resource.
  53261. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53262. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53263. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53264. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53265. * * 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.
  53266. * * 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).
  53267. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53269. * @param name defines the name of the mesh
  53270. * @param url defines the url to the height map
  53271. * @param options defines the options used to create the mesh
  53272. * @param scene defines the hosting scene
  53273. * @returns the ground mesh
  53274. * @see https://doc.babylonjs.com/babylon101/height_map
  53275. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53276. */
  53277. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53278. width?: number;
  53279. height?: number;
  53280. subdivisions?: number;
  53281. minHeight?: number;
  53282. maxHeight?: number;
  53283. colorFilter?: Color3;
  53284. alphaFilter?: number;
  53285. updatable?: boolean;
  53286. onReady?: (mesh: GroundMesh) => void;
  53287. }, scene?: Nullable<Scene>): GroundMesh;
  53288. }
  53289. }
  53290. declare module BABYLON {
  53291. /**
  53292. * Class containing static functions to help procedurally build meshes
  53293. */
  53294. export class TorusBuilder {
  53295. /**
  53296. * Creates a torus mesh
  53297. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53298. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53299. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53301. * * 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
  53302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53303. * @param name defines the name of the mesh
  53304. * @param options defines the options used to create the mesh
  53305. * @param scene defines the hosting scene
  53306. * @returns the torus mesh
  53307. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53308. */
  53309. static CreateTorus(name: string, options: {
  53310. diameter?: number;
  53311. thickness?: number;
  53312. tessellation?: number;
  53313. updatable?: boolean;
  53314. sideOrientation?: number;
  53315. frontUVs?: Vector4;
  53316. backUVs?: Vector4;
  53317. }, scene: any): Mesh;
  53318. }
  53319. }
  53320. declare module BABYLON {
  53321. /**
  53322. * Class containing static functions to help procedurally build meshes
  53323. */
  53324. export class CylinderBuilder {
  53325. /**
  53326. * Creates a cylinder or a cone mesh
  53327. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53328. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53329. * * 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.
  53330. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53331. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53332. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53333. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53334. * * 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).
  53335. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53336. * * 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).
  53337. * * 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
  53338. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53339. * * 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
  53340. * * 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.
  53341. * * If `enclose` is false, a ring surface is one element.
  53342. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53343. * * 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
  53344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53345. * * 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
  53346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53347. * @param name defines the name of the mesh
  53348. * @param options defines the options used to create the mesh
  53349. * @param scene defines the hosting scene
  53350. * @returns the cylinder mesh
  53351. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53352. */
  53353. static CreateCylinder(name: string, options: {
  53354. height?: number;
  53355. diameterTop?: number;
  53356. diameterBottom?: number;
  53357. diameter?: number;
  53358. tessellation?: number;
  53359. subdivisions?: number;
  53360. arc?: number;
  53361. faceColors?: Color4[];
  53362. faceUV?: Vector4[];
  53363. updatable?: boolean;
  53364. hasRings?: boolean;
  53365. enclose?: boolean;
  53366. cap?: number;
  53367. sideOrientation?: number;
  53368. frontUVs?: Vector4;
  53369. backUVs?: Vector4;
  53370. }, scene: any): Mesh;
  53371. }
  53372. }
  53373. declare module BABYLON {
  53374. /**
  53375. * States of the webXR experience
  53376. */
  53377. export enum WebXRState {
  53378. /**
  53379. * Transitioning to being in XR mode
  53380. */
  53381. ENTERING_XR = 0,
  53382. /**
  53383. * Transitioning to non XR mode
  53384. */
  53385. EXITING_XR = 1,
  53386. /**
  53387. * In XR mode and presenting
  53388. */
  53389. IN_XR = 2,
  53390. /**
  53391. * Not entered XR mode
  53392. */
  53393. NOT_IN_XR = 3
  53394. }
  53395. /**
  53396. * The state of the XR camera's tracking
  53397. */
  53398. export enum WebXRTrackingState {
  53399. /**
  53400. * No transformation received, device is not being tracked
  53401. */
  53402. NOT_TRACKING = 0,
  53403. /**
  53404. * Tracking lost - using emulated position
  53405. */
  53406. TRACKING_LOST = 1,
  53407. /**
  53408. * Transformation tracking works normally
  53409. */
  53410. TRACKING = 2
  53411. }
  53412. /**
  53413. * Abstraction of the XR render target
  53414. */
  53415. export interface WebXRRenderTarget extends IDisposable {
  53416. /**
  53417. * xrpresent context of the canvas which can be used to display/mirror xr content
  53418. */
  53419. canvasContext: WebGLRenderingContext;
  53420. /**
  53421. * xr layer for the canvas
  53422. */
  53423. xrLayer: Nullable<XRWebGLLayer>;
  53424. /**
  53425. * Initializes the xr layer for the session
  53426. * @param xrSession xr session
  53427. * @returns a promise that will resolve once the XR Layer has been created
  53428. */
  53429. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53430. }
  53431. }
  53432. declare module BABYLON {
  53433. /**
  53434. * COnfiguration object for WebXR output canvas
  53435. */
  53436. export class WebXRManagedOutputCanvasOptions {
  53437. /**
  53438. * An optional canvas in case you wish to create it yourself and provide it here.
  53439. * If not provided, a new canvas will be created
  53440. */
  53441. canvasElement?: HTMLCanvasElement;
  53442. /**
  53443. * Options for this XR Layer output
  53444. */
  53445. canvasOptions?: XRWebGLLayerInit;
  53446. /**
  53447. * CSS styling for a newly created canvas (if not provided)
  53448. */
  53449. newCanvasCssStyle?: string;
  53450. /**
  53451. * Get the default values of the configuration object
  53452. * @param engine defines the engine to use (can be null)
  53453. * @returns default values of this configuration object
  53454. */
  53455. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53456. }
  53457. /**
  53458. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53459. */
  53460. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53461. private _options;
  53462. private _canvas;
  53463. private _engine;
  53464. private _originalCanvasSize;
  53465. /**
  53466. * Rendering context of the canvas which can be used to display/mirror xr content
  53467. */
  53468. canvasContext: WebGLRenderingContext;
  53469. /**
  53470. * xr layer for the canvas
  53471. */
  53472. xrLayer: Nullable<XRWebGLLayer>;
  53473. /**
  53474. * Obseervers registered here will be triggered when the xr layer was initialized
  53475. */
  53476. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53477. /**
  53478. * Initializes the canvas to be added/removed upon entering/exiting xr
  53479. * @param _xrSessionManager The XR Session manager
  53480. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53481. */
  53482. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53483. /**
  53484. * Disposes of the object
  53485. */
  53486. dispose(): void;
  53487. /**
  53488. * Initializes the xr layer for the session
  53489. * @param xrSession xr session
  53490. * @returns a promise that will resolve once the XR Layer has been created
  53491. */
  53492. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53493. private _addCanvas;
  53494. private _removeCanvas;
  53495. private _setCanvasSize;
  53496. private _setManagedOutputCanvas;
  53497. }
  53498. }
  53499. declare module BABYLON {
  53500. /**
  53501. * Manages an XRSession to work with Babylon's engine
  53502. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53503. */
  53504. export class WebXRSessionManager implements IDisposable {
  53505. /** The scene which the session should be created for */
  53506. scene: Scene;
  53507. private _referenceSpace;
  53508. private _rttProvider;
  53509. private _sessionEnded;
  53510. private _xrNavigator;
  53511. private baseLayer;
  53512. /**
  53513. * The base reference space from which the session started. good if you want to reset your
  53514. * reference space
  53515. */
  53516. baseReferenceSpace: XRReferenceSpace;
  53517. /**
  53518. * Current XR frame
  53519. */
  53520. currentFrame: Nullable<XRFrame>;
  53521. /** WebXR timestamp updated every frame */
  53522. currentTimestamp: number;
  53523. /**
  53524. * Used just in case of a failure to initialize an immersive session.
  53525. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53526. */
  53527. defaultHeightCompensation: number;
  53528. /**
  53529. * Fires every time a new xrFrame arrives which can be used to update the camera
  53530. */
  53531. onXRFrameObservable: Observable<XRFrame>;
  53532. /**
  53533. * Fires when the reference space changed
  53534. */
  53535. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53536. /**
  53537. * Fires when the xr session is ended either by the device or manually done
  53538. */
  53539. onXRSessionEnded: Observable<any>;
  53540. /**
  53541. * Fires when the xr session is ended either by the device or manually done
  53542. */
  53543. onXRSessionInit: Observable<XRSession>;
  53544. /**
  53545. * Underlying xr session
  53546. */
  53547. session: XRSession;
  53548. /**
  53549. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53550. * or get the offset the player is currently at.
  53551. */
  53552. viewerReferenceSpace: XRReferenceSpace;
  53553. /**
  53554. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53555. * @param scene The scene which the session should be created for
  53556. */
  53557. constructor(
  53558. /** The scene which the session should be created for */
  53559. scene: Scene);
  53560. /**
  53561. * The current reference space used in this session. This reference space can constantly change!
  53562. * It is mainly used to offset the camera's position.
  53563. */
  53564. get referenceSpace(): XRReferenceSpace;
  53565. /**
  53566. * Set a new reference space and triggers the observable
  53567. */
  53568. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53569. /**
  53570. * Disposes of the session manager
  53571. */
  53572. dispose(): void;
  53573. /**
  53574. * Stops the xrSession and restores the render loop
  53575. * @returns Promise which resolves after it exits XR
  53576. */
  53577. exitXRAsync(): Promise<void>;
  53578. /**
  53579. * Gets the correct render target texture to be rendered this frame for this eye
  53580. * @param eye the eye for which to get the render target
  53581. * @returns the render target for the specified eye
  53582. */
  53583. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53584. /**
  53585. * Creates a WebXRRenderTarget object for the XR session
  53586. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53587. * @param options optional options to provide when creating a new render target
  53588. * @returns a WebXR render target to which the session can render
  53589. */
  53590. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53591. /**
  53592. * Initializes the manager
  53593. * After initialization enterXR can be called to start an XR session
  53594. * @returns Promise which resolves after it is initialized
  53595. */
  53596. initializeAsync(): Promise<void>;
  53597. /**
  53598. * Initializes an xr session
  53599. * @param xrSessionMode mode to initialize
  53600. * @param xrSessionInit defines optional and required values to pass to the session builder
  53601. * @returns a promise which will resolve once the session has been initialized
  53602. */
  53603. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53604. /**
  53605. * Checks if a session would be supported for the creation options specified
  53606. * @param sessionMode session mode to check if supported eg. immersive-vr
  53607. * @returns A Promise that resolves to true if supported and false if not
  53608. */
  53609. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53610. /**
  53611. * Resets the reference space to the one started the session
  53612. */
  53613. resetReferenceSpace(): void;
  53614. /**
  53615. * Starts rendering to the xr layer
  53616. */
  53617. runXRRenderLoop(): void;
  53618. /**
  53619. * Sets the reference space on the xr session
  53620. * @param referenceSpaceType space to set
  53621. * @returns a promise that will resolve once the reference space has been set
  53622. */
  53623. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53624. /**
  53625. * Updates the render state of the session
  53626. * @param state state to set
  53627. * @returns a promise that resolves once the render state has been updated
  53628. */
  53629. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53630. /**
  53631. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53632. * @param sessionMode defines the session to test
  53633. * @returns a promise with boolean as final value
  53634. */
  53635. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53636. /**
  53637. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53638. */
  53639. get isNative(): boolean;
  53640. private _createRenderTargetTexture;
  53641. }
  53642. }
  53643. declare module BABYLON {
  53644. /**
  53645. * WebXR Camera which holds the views for the xrSession
  53646. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53647. */
  53648. export class WebXRCamera extends FreeCamera {
  53649. private _xrSessionManager;
  53650. private _firstFrame;
  53651. private _referenceQuaternion;
  53652. private _referencedPosition;
  53653. private _xrInvPositionCache;
  53654. private _xrInvQuaternionCache;
  53655. private _trackingState;
  53656. /**
  53657. * Observable raised before camera teleportation
  53658. */
  53659. onBeforeCameraTeleport: Observable<Vector3>;
  53660. /**
  53661. * Observable raised after camera teleportation
  53662. */
  53663. onAfterCameraTeleport: Observable<Vector3>;
  53664. /**
  53665. * Notifies when the camera's tracking state has changed.
  53666. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53667. */
  53668. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53669. /**
  53670. * Should position compensation execute on first frame.
  53671. * This is used when copying the position from a native (non XR) camera
  53672. */
  53673. compensateOnFirstFrame: boolean;
  53674. /**
  53675. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53676. * @param name the name of the camera
  53677. * @param scene the scene to add the camera to
  53678. * @param _xrSessionManager a constructed xr session manager
  53679. */
  53680. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53681. /**
  53682. * Get the current XR tracking state of the camera
  53683. */
  53684. get trackingState(): WebXRTrackingState;
  53685. private _setTrackingState;
  53686. /**
  53687. * Return the user's height, unrelated to the current ground.
  53688. * This will be the y position of this camera, when ground level is 0.
  53689. */
  53690. get realWorldHeight(): number;
  53691. /** @hidden */
  53692. _updateForDualEyeDebugging(): void;
  53693. /**
  53694. * Sets this camera's transformation based on a non-vr camera
  53695. * @param otherCamera the non-vr camera to copy the transformation from
  53696. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53697. */
  53698. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53699. /**
  53700. * Gets the current instance class name ("WebXRCamera").
  53701. * @returns the class name
  53702. */
  53703. getClassName(): string;
  53704. private _rotate180;
  53705. private _updateFromXRSession;
  53706. private _updateNumberOfRigCameras;
  53707. private _updateReferenceSpace;
  53708. private _updateReferenceSpaceOffset;
  53709. }
  53710. }
  53711. declare module BABYLON {
  53712. /**
  53713. * Defining the interface required for a (webxr) feature
  53714. */
  53715. export interface IWebXRFeature extends IDisposable {
  53716. /**
  53717. * Is this feature attached
  53718. */
  53719. attached: boolean;
  53720. /**
  53721. * Should auto-attach be disabled?
  53722. */
  53723. disableAutoAttach: boolean;
  53724. /**
  53725. * Attach the feature to the session
  53726. * Will usually be called by the features manager
  53727. *
  53728. * @param force should attachment be forced (even when already attached)
  53729. * @returns true if successful.
  53730. */
  53731. attach(force?: boolean): boolean;
  53732. /**
  53733. * Detach the feature from the session
  53734. * Will usually be called by the features manager
  53735. *
  53736. * @returns true if successful.
  53737. */
  53738. detach(): boolean;
  53739. /**
  53740. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53741. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53742. *
  53743. * @returns whether or not the feature is compatible in this environment
  53744. */
  53745. isCompatible(): boolean;
  53746. /**
  53747. * Was this feature disposed;
  53748. */
  53749. isDisposed: boolean;
  53750. /**
  53751. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53752. */
  53753. xrNativeFeatureName?: string;
  53754. /**
  53755. * A list of (Babylon WebXR) features this feature depends on
  53756. */
  53757. dependsOn?: string[];
  53758. /**
  53759. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  53760. */
  53761. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  53762. }
  53763. /**
  53764. * A list of the currently available features without referencing them
  53765. */
  53766. export class WebXRFeatureName {
  53767. /**
  53768. * The name of the anchor system feature
  53769. */
  53770. static readonly ANCHOR_SYSTEM: string;
  53771. /**
  53772. * The name of the background remover feature
  53773. */
  53774. static readonly BACKGROUND_REMOVER: string;
  53775. /**
  53776. * The name of the hit test feature
  53777. */
  53778. static readonly HIT_TEST: string;
  53779. /**
  53780. * The name of the mesh detection feature
  53781. */
  53782. static readonly MESH_DETECTION: string;
  53783. /**
  53784. * physics impostors for xr controllers feature
  53785. */
  53786. static readonly PHYSICS_CONTROLLERS: string;
  53787. /**
  53788. * The name of the plane detection feature
  53789. */
  53790. static readonly PLANE_DETECTION: string;
  53791. /**
  53792. * The name of the pointer selection feature
  53793. */
  53794. static readonly POINTER_SELECTION: string;
  53795. /**
  53796. * The name of the teleportation feature
  53797. */
  53798. static readonly TELEPORTATION: string;
  53799. /**
  53800. * The name of the feature points feature.
  53801. */
  53802. static readonly FEATURE_POINTS: string;
  53803. /**
  53804. * The name of the hand tracking feature.
  53805. */
  53806. static readonly HAND_TRACKING: string;
  53807. /**
  53808. * The name of the image tracking feature
  53809. */
  53810. static readonly IMAGE_TRACKING: string;
  53811. }
  53812. /**
  53813. * Defining the constructor of a feature. Used to register the modules.
  53814. */
  53815. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53816. /**
  53817. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53818. * It is mainly used in AR sessions.
  53819. *
  53820. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53821. */
  53822. export class WebXRFeaturesManager implements IDisposable {
  53823. private _xrSessionManager;
  53824. private static readonly _AvailableFeatures;
  53825. private _features;
  53826. /**
  53827. * constructs a new features manages.
  53828. *
  53829. * @param _xrSessionManager an instance of WebXRSessionManager
  53830. */
  53831. constructor(_xrSessionManager: WebXRSessionManager);
  53832. /**
  53833. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53834. * Mainly used internally.
  53835. *
  53836. * @param featureName the name of the feature to register
  53837. * @param constructorFunction the function used to construct the module
  53838. * @param version the (babylon) version of the module
  53839. * @param stable is that a stable version of this module
  53840. */
  53841. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53842. /**
  53843. * Returns a constructor of a specific feature.
  53844. *
  53845. * @param featureName the name of the feature to construct
  53846. * @param version the version of the feature to load
  53847. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53848. * @param options optional options provided to the module.
  53849. * @returns a function that, when called, will return a new instance of this feature
  53850. */
  53851. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53852. /**
  53853. * Can be used to return the list of features currently registered
  53854. *
  53855. * @returns an Array of available features
  53856. */
  53857. static GetAvailableFeatures(): string[];
  53858. /**
  53859. * Gets the versions available for a specific feature
  53860. * @param featureName the name of the feature
  53861. * @returns an array with the available versions
  53862. */
  53863. static GetAvailableVersions(featureName: string): string[];
  53864. /**
  53865. * Return the latest unstable version of this feature
  53866. * @param featureName the name of the feature to search
  53867. * @returns the version number. if not found will return -1
  53868. */
  53869. static GetLatestVersionOfFeature(featureName: string): number;
  53870. /**
  53871. * Return the latest stable version of this feature
  53872. * @param featureName the name of the feature to search
  53873. * @returns the version number. if not found will return -1
  53874. */
  53875. static GetStableVersionOfFeature(featureName: string): number;
  53876. /**
  53877. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53878. * Can be used during a session to start a feature
  53879. * @param featureName the name of feature to attach
  53880. */
  53881. attachFeature(featureName: string): void;
  53882. /**
  53883. * Can be used inside a session or when the session ends to detach a specific feature
  53884. * @param featureName the name of the feature to detach
  53885. */
  53886. detachFeature(featureName: string): void;
  53887. /**
  53888. * Used to disable an already-enabled feature
  53889. * The feature will be disposed and will be recreated once enabled.
  53890. * @param featureName the feature to disable
  53891. * @returns true if disable was successful
  53892. */
  53893. disableFeature(featureName: string | {
  53894. Name: string;
  53895. }): boolean;
  53896. /**
  53897. * dispose this features manager
  53898. */
  53899. dispose(): void;
  53900. /**
  53901. * 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.
  53902. * 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.
  53903. *
  53904. * @param featureName the name of the feature to load or the class of the feature
  53905. * @param version optional version to load. if not provided the latest version will be enabled
  53906. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53907. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53908. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53909. * @returns a new constructed feature or throws an error if feature not found.
  53910. */
  53911. enableFeature(featureName: string | {
  53912. Name: string;
  53913. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53914. /**
  53915. * get the implementation of an enabled feature.
  53916. * @param featureName the name of the feature to load
  53917. * @returns the feature class, if found
  53918. */
  53919. getEnabledFeature(featureName: string): IWebXRFeature;
  53920. /**
  53921. * Get the list of enabled features
  53922. * @returns an array of enabled features
  53923. */
  53924. getEnabledFeatures(): string[];
  53925. /**
  53926. * This function will extend the session creation configuration object with enabled features.
  53927. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53928. * according to the defined "required" variable, provided during enableFeature call
  53929. * @param xrSessionInit the xr Session init object to extend
  53930. *
  53931. * @returns an extended XRSessionInit object
  53932. */
  53933. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  53934. }
  53935. }
  53936. declare module BABYLON {
  53937. /**
  53938. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53939. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53940. */
  53941. export class WebXRExperienceHelper implements IDisposable {
  53942. private scene;
  53943. private _nonVRCamera;
  53944. private _originalSceneAutoClear;
  53945. private _supported;
  53946. /**
  53947. * Camera used to render xr content
  53948. */
  53949. camera: WebXRCamera;
  53950. /** A features manager for this xr session */
  53951. featuresManager: WebXRFeaturesManager;
  53952. /**
  53953. * Observers registered here will be triggered after the camera's initial transformation is set
  53954. * This can be used to set a different ground level or an extra rotation.
  53955. *
  53956. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53957. * to the position set after this observable is done executing.
  53958. */
  53959. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53960. /**
  53961. * Fires when the state of the experience helper has changed
  53962. */
  53963. onStateChangedObservable: Observable<WebXRState>;
  53964. /** Session manager used to keep track of xr session */
  53965. sessionManager: WebXRSessionManager;
  53966. /**
  53967. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53968. */
  53969. state: WebXRState;
  53970. /**
  53971. * Creates a WebXRExperienceHelper
  53972. * @param scene The scene the helper should be created in
  53973. */
  53974. private constructor();
  53975. /**
  53976. * Creates the experience helper
  53977. * @param scene the scene to attach the experience helper to
  53978. * @returns a promise for the experience helper
  53979. */
  53980. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53981. /**
  53982. * Disposes of the experience helper
  53983. */
  53984. dispose(): void;
  53985. /**
  53986. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53987. * @param sessionMode options for the XR session
  53988. * @param referenceSpaceType frame of reference of the XR session
  53989. * @param renderTarget the output canvas that will be used to enter XR mode
  53990. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53991. * @returns promise that resolves after xr mode has entered
  53992. */
  53993. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53994. /**
  53995. * Exits XR mode and returns the scene to its original state
  53996. * @returns promise that resolves after xr mode has exited
  53997. */
  53998. exitXRAsync(): Promise<void>;
  53999. private _nonXRToXRCamera;
  54000. private _setState;
  54001. }
  54002. }
  54003. declare module BABYLON {
  54004. /**
  54005. * X-Y values for axes in WebXR
  54006. */
  54007. export interface IWebXRMotionControllerAxesValue {
  54008. /**
  54009. * The value of the x axis
  54010. */
  54011. x: number;
  54012. /**
  54013. * The value of the y-axis
  54014. */
  54015. y: number;
  54016. }
  54017. /**
  54018. * changed / previous values for the values of this component
  54019. */
  54020. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54021. /**
  54022. * current (this frame) value
  54023. */
  54024. current: T;
  54025. /**
  54026. * previous (last change) value
  54027. */
  54028. previous: T;
  54029. }
  54030. /**
  54031. * Represents changes in the component between current frame and last values recorded
  54032. */
  54033. export interface IWebXRMotionControllerComponentChanges {
  54034. /**
  54035. * will be populated with previous and current values if axes changed
  54036. */
  54037. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54038. /**
  54039. * will be populated with previous and current values if pressed changed
  54040. */
  54041. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54042. /**
  54043. * will be populated with previous and current values if touched changed
  54044. */
  54045. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54046. /**
  54047. * will be populated with previous and current values if value changed
  54048. */
  54049. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54050. }
  54051. /**
  54052. * This class represents a single component (for example button or thumbstick) of a motion controller
  54053. */
  54054. export class WebXRControllerComponent implements IDisposable {
  54055. /**
  54056. * the id of this component
  54057. */
  54058. id: string;
  54059. /**
  54060. * the type of the component
  54061. */
  54062. type: MotionControllerComponentType;
  54063. private _buttonIndex;
  54064. private _axesIndices;
  54065. private _axes;
  54066. private _changes;
  54067. private _currentValue;
  54068. private _hasChanges;
  54069. private _pressed;
  54070. private _touched;
  54071. /**
  54072. * button component type
  54073. */
  54074. static BUTTON_TYPE: MotionControllerComponentType;
  54075. /**
  54076. * squeeze component type
  54077. */
  54078. static SQUEEZE_TYPE: MotionControllerComponentType;
  54079. /**
  54080. * Thumbstick component type
  54081. */
  54082. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54083. /**
  54084. * Touchpad component type
  54085. */
  54086. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54087. /**
  54088. * trigger component type
  54089. */
  54090. static TRIGGER_TYPE: MotionControllerComponentType;
  54091. /**
  54092. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54093. * the axes data changes
  54094. */
  54095. onAxisValueChangedObservable: Observable<{
  54096. x: number;
  54097. y: number;
  54098. }>;
  54099. /**
  54100. * Observers registered here will be triggered when the state of a button changes
  54101. * State change is either pressed / touched / value
  54102. */
  54103. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54104. /**
  54105. * Creates a new component for a motion controller.
  54106. * It is created by the motion controller itself
  54107. *
  54108. * @param id the id of this component
  54109. * @param type the type of the component
  54110. * @param _buttonIndex index in the buttons array of the gamepad
  54111. * @param _axesIndices indices of the values in the axes array of the gamepad
  54112. */
  54113. constructor(
  54114. /**
  54115. * the id of this component
  54116. */
  54117. id: string,
  54118. /**
  54119. * the type of the component
  54120. */
  54121. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54122. /**
  54123. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54124. */
  54125. get axes(): IWebXRMotionControllerAxesValue;
  54126. /**
  54127. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54128. */
  54129. get changes(): IWebXRMotionControllerComponentChanges;
  54130. /**
  54131. * Return whether or not the component changed the last frame
  54132. */
  54133. get hasChanges(): boolean;
  54134. /**
  54135. * is the button currently pressed
  54136. */
  54137. get pressed(): boolean;
  54138. /**
  54139. * is the button currently touched
  54140. */
  54141. get touched(): boolean;
  54142. /**
  54143. * Get the current value of this component
  54144. */
  54145. get value(): number;
  54146. /**
  54147. * Dispose this component
  54148. */
  54149. dispose(): void;
  54150. /**
  54151. * Are there axes correlating to this component
  54152. * @return true is axes data is available
  54153. */
  54154. isAxes(): boolean;
  54155. /**
  54156. * Is this component a button (hence - pressable)
  54157. * @returns true if can be pressed
  54158. */
  54159. isButton(): boolean;
  54160. /**
  54161. * update this component using the gamepad object it is in. Called on every frame
  54162. * @param nativeController the native gamepad controller object
  54163. */
  54164. update(nativeController: IMinimalMotionControllerObject): void;
  54165. }
  54166. }
  54167. declare module BABYLON {
  54168. /**
  54169. * Type used for the success callback of ImportMesh
  54170. */
  54171. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54172. /**
  54173. * Interface used for the result of ImportMeshAsync
  54174. */
  54175. export interface ISceneLoaderAsyncResult {
  54176. /**
  54177. * The array of loaded meshes
  54178. */
  54179. readonly meshes: AbstractMesh[];
  54180. /**
  54181. * The array of loaded particle systems
  54182. */
  54183. readonly particleSystems: IParticleSystem[];
  54184. /**
  54185. * The array of loaded skeletons
  54186. */
  54187. readonly skeletons: Skeleton[];
  54188. /**
  54189. * The array of loaded animation groups
  54190. */
  54191. readonly animationGroups: AnimationGroup[];
  54192. /**
  54193. * The array of loaded transform nodes
  54194. */
  54195. readonly transformNodes: TransformNode[];
  54196. /**
  54197. * The array of loaded geometries
  54198. */
  54199. readonly geometries: Geometry[];
  54200. /**
  54201. * The array of loaded lights
  54202. */
  54203. readonly lights: Light[];
  54204. }
  54205. /**
  54206. * Interface used to represent data loading progression
  54207. */
  54208. export interface ISceneLoaderProgressEvent {
  54209. /**
  54210. * Defines if data length to load can be evaluated
  54211. */
  54212. readonly lengthComputable: boolean;
  54213. /**
  54214. * Defines the loaded data length
  54215. */
  54216. readonly loaded: number;
  54217. /**
  54218. * Defines the data length to load
  54219. */
  54220. readonly total: number;
  54221. }
  54222. /**
  54223. * Interface used by SceneLoader plugins to define supported file extensions
  54224. */
  54225. export interface ISceneLoaderPluginExtensions {
  54226. /**
  54227. * Defines the list of supported extensions
  54228. */
  54229. [extension: string]: {
  54230. isBinary: boolean;
  54231. };
  54232. }
  54233. /**
  54234. * Interface used by SceneLoader plugin factory
  54235. */
  54236. export interface ISceneLoaderPluginFactory {
  54237. /**
  54238. * Defines the name of the factory
  54239. */
  54240. name: string;
  54241. /**
  54242. * Function called to create a new plugin
  54243. * @return the new plugin
  54244. */
  54245. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54246. /**
  54247. * The callback that returns true if the data can be directly loaded.
  54248. * @param data string containing the file data
  54249. * @returns if the data can be loaded directly
  54250. */
  54251. canDirectLoad?(data: string): boolean;
  54252. }
  54253. /**
  54254. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54255. */
  54256. export interface ISceneLoaderPluginBase {
  54257. /**
  54258. * The friendly name of this plugin.
  54259. */
  54260. name: string;
  54261. /**
  54262. * The file extensions supported by this plugin.
  54263. */
  54264. extensions: string | ISceneLoaderPluginExtensions;
  54265. /**
  54266. * The callback called when loading from a url.
  54267. * @param scene scene loading this url
  54268. * @param url url to load
  54269. * @param onSuccess callback called when the file successfully loads
  54270. * @param onProgress callback called while file is loading (if the server supports this mode)
  54271. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54272. * @param onError callback called when the file fails to load
  54273. * @returns a file request object
  54274. */
  54275. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54276. /**
  54277. * The callback called when loading from a file object.
  54278. * @param scene scene loading this file
  54279. * @param file defines the file to load
  54280. * @param onSuccess defines the callback to call when data is loaded
  54281. * @param onProgress defines the callback to call during loading process
  54282. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54283. * @param onError defines the callback to call when an error occurs
  54284. * @returns a file request object
  54285. */
  54286. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54287. /**
  54288. * The callback that returns true if the data can be directly loaded.
  54289. * @param data string containing the file data
  54290. * @returns if the data can be loaded directly
  54291. */
  54292. canDirectLoad?(data: string): boolean;
  54293. /**
  54294. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54295. * @param scene scene loading this data
  54296. * @param data string containing the data
  54297. * @returns data to pass to the plugin
  54298. */
  54299. directLoad?(scene: Scene, data: string): any;
  54300. /**
  54301. * The callback that allows custom handling of the root url based on the response url.
  54302. * @param rootUrl the original root url
  54303. * @param responseURL the response url if available
  54304. * @returns the new root url
  54305. */
  54306. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54307. }
  54308. /**
  54309. * Interface used to define a SceneLoader plugin
  54310. */
  54311. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54312. /**
  54313. * Import meshes into a scene.
  54314. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54315. * @param scene The scene to import into
  54316. * @param data The data to import
  54317. * @param rootUrl The root url for scene and resources
  54318. * @param meshes The meshes array to import into
  54319. * @param particleSystems The particle systems array to import into
  54320. * @param skeletons The skeletons array to import into
  54321. * @param onError The callback when import fails
  54322. * @returns True if successful or false otherwise
  54323. */
  54324. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54325. /**
  54326. * Load into a scene.
  54327. * @param scene The scene to load into
  54328. * @param data The data to import
  54329. * @param rootUrl The root url for scene and resources
  54330. * @param onError The callback when import fails
  54331. * @returns True if successful or false otherwise
  54332. */
  54333. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54334. /**
  54335. * Load into an asset container.
  54336. * @param scene The scene to load into
  54337. * @param data The data to import
  54338. * @param rootUrl The root url for scene and resources
  54339. * @param onError The callback when import fails
  54340. * @returns The loaded asset container
  54341. */
  54342. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54343. }
  54344. /**
  54345. * Interface used to define an async SceneLoader plugin
  54346. */
  54347. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54348. /**
  54349. * Import meshes into a scene.
  54350. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54351. * @param scene The scene to import into
  54352. * @param data The data to import
  54353. * @param rootUrl The root url for scene and resources
  54354. * @param onProgress The callback when the load progresses
  54355. * @param fileName Defines the name of the file to load
  54356. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54357. */
  54358. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54359. /**
  54360. * Load into a scene.
  54361. * @param scene The scene to load into
  54362. * @param data The data to import
  54363. * @param rootUrl The root url for scene and resources
  54364. * @param onProgress The callback when the load progresses
  54365. * @param fileName Defines the name of the file to load
  54366. * @returns Nothing
  54367. */
  54368. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54369. /**
  54370. * Load into an asset container.
  54371. * @param scene The scene to load into
  54372. * @param data The data to import
  54373. * @param rootUrl The root url for scene and resources
  54374. * @param onProgress The callback when the load progresses
  54375. * @param fileName Defines the name of the file to load
  54376. * @returns The loaded asset container
  54377. */
  54378. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54379. }
  54380. /**
  54381. * Mode that determines how to handle old animation groups before loading new ones.
  54382. */
  54383. export enum SceneLoaderAnimationGroupLoadingMode {
  54384. /**
  54385. * Reset all old animations to initial state then dispose them.
  54386. */
  54387. Clean = 0,
  54388. /**
  54389. * Stop all old animations.
  54390. */
  54391. Stop = 1,
  54392. /**
  54393. * Restart old animations from first frame.
  54394. */
  54395. Sync = 2,
  54396. /**
  54397. * Old animations remains untouched.
  54398. */
  54399. NoSync = 3
  54400. }
  54401. /**
  54402. * Defines a plugin registered by the SceneLoader
  54403. */
  54404. interface IRegisteredPlugin {
  54405. /**
  54406. * Defines the plugin to use
  54407. */
  54408. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54409. /**
  54410. * Defines if the plugin supports binary data
  54411. */
  54412. isBinary: boolean;
  54413. }
  54414. /**
  54415. * Class used to load scene from various file formats using registered plugins
  54416. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54417. */
  54418. export class SceneLoader {
  54419. /**
  54420. * No logging while loading
  54421. */
  54422. static readonly NO_LOGGING: number;
  54423. /**
  54424. * Minimal logging while loading
  54425. */
  54426. static readonly MINIMAL_LOGGING: number;
  54427. /**
  54428. * Summary logging while loading
  54429. */
  54430. static readonly SUMMARY_LOGGING: number;
  54431. /**
  54432. * Detailled logging while loading
  54433. */
  54434. static readonly DETAILED_LOGGING: number;
  54435. /**
  54436. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54437. */
  54438. static get ForceFullSceneLoadingForIncremental(): boolean;
  54439. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54440. /**
  54441. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54442. */
  54443. static get ShowLoadingScreen(): boolean;
  54444. static set ShowLoadingScreen(value: boolean);
  54445. /**
  54446. * Defines the current logging level (while loading the scene)
  54447. * @ignorenaming
  54448. */
  54449. static get loggingLevel(): number;
  54450. static set loggingLevel(value: number);
  54451. /**
  54452. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54453. */
  54454. static get CleanBoneMatrixWeights(): boolean;
  54455. static set CleanBoneMatrixWeights(value: boolean);
  54456. /**
  54457. * Event raised when a plugin is used to load a scene
  54458. */
  54459. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54460. private static _registeredPlugins;
  54461. private static _showingLoadingScreen;
  54462. /**
  54463. * Gets the default plugin (used to load Babylon files)
  54464. * @returns the .babylon plugin
  54465. */
  54466. static GetDefaultPlugin(): IRegisteredPlugin;
  54467. private static _GetPluginForExtension;
  54468. private static _GetPluginForDirectLoad;
  54469. private static _GetPluginForFilename;
  54470. private static _GetDirectLoad;
  54471. private static _LoadData;
  54472. private static _GetFileInfo;
  54473. /**
  54474. * Gets a plugin that can load the given extension
  54475. * @param extension defines the extension to load
  54476. * @returns a plugin or null if none works
  54477. */
  54478. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54479. /**
  54480. * Gets a boolean indicating that the given extension can be loaded
  54481. * @param extension defines the extension to load
  54482. * @returns true if the extension is supported
  54483. */
  54484. static IsPluginForExtensionAvailable(extension: string): boolean;
  54485. /**
  54486. * Adds a new plugin to the list of registered plugins
  54487. * @param plugin defines the plugin to add
  54488. */
  54489. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54490. /**
  54491. * Import meshes into a scene
  54492. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54493. * @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)
  54494. * @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)
  54495. * @param scene the instance of BABYLON.Scene to append to
  54496. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54497. * @param onProgress a callback with a progress event for each file being loaded
  54498. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54499. * @param pluginExtension the extension used to determine the plugin
  54500. * @returns The loaded plugin
  54501. */
  54502. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54503. /**
  54504. * Import meshes into a scene
  54505. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54506. * @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)
  54507. * @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)
  54508. * @param scene the instance of BABYLON.Scene to append to
  54509. * @param onProgress a callback with a progress event for each file being loaded
  54510. * @param pluginExtension the extension used to determine the plugin
  54511. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54512. */
  54513. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54514. /**
  54515. * Load a scene
  54516. * @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)
  54517. * @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)
  54518. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54519. * @param onSuccess a callback with the scene when import succeeds
  54520. * @param onProgress a callback with a progress event for each file being loaded
  54521. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54522. * @param pluginExtension the extension used to determine the plugin
  54523. * @returns The loaded plugin
  54524. */
  54525. 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>;
  54526. /**
  54527. * Load a scene
  54528. * @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)
  54529. * @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)
  54530. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54531. * @param onProgress a callback with a progress event for each file being loaded
  54532. * @param pluginExtension the extension used to determine the plugin
  54533. * @returns The loaded scene
  54534. */
  54535. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54536. /**
  54537. * Append a scene
  54538. * @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)
  54539. * @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)
  54540. * @param scene is the instance of BABYLON.Scene to append to
  54541. * @param onSuccess a callback with the scene when import succeeds
  54542. * @param onProgress a callback with a progress event for each file being loaded
  54543. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54544. * @param pluginExtension the extension used to determine the plugin
  54545. * @returns The loaded plugin
  54546. */
  54547. 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>;
  54548. /**
  54549. * Append a scene
  54550. * @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)
  54551. * @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)
  54552. * @param scene is the instance of BABYLON.Scene to append to
  54553. * @param onProgress a callback with a progress event for each file being loaded
  54554. * @param pluginExtension the extension used to determine the plugin
  54555. * @returns The given scene
  54556. */
  54557. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54558. /**
  54559. * Load a scene into an asset container
  54560. * @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)
  54561. * @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)
  54562. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54563. * @param onSuccess a callback with the scene when import succeeds
  54564. * @param onProgress a callback with a progress event for each file being loaded
  54565. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54566. * @param pluginExtension the extension used to determine the plugin
  54567. * @returns The loaded plugin
  54568. */
  54569. 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>;
  54570. /**
  54571. * Load a scene into an asset container
  54572. * @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)
  54573. * @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)
  54574. * @param scene is the instance of Scene to append to
  54575. * @param onProgress a callback with a progress event for each file being loaded
  54576. * @param pluginExtension the extension used to determine the plugin
  54577. * @returns The loaded asset container
  54578. */
  54579. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54580. /**
  54581. * Import animations from a file into a scene
  54582. * @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)
  54583. * @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)
  54584. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54585. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54586. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54587. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54588. * @param onSuccess a callback with the scene when import succeeds
  54589. * @param onProgress a callback with a progress event for each file being loaded
  54590. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54591. * @param pluginExtension the extension used to determine the plugin
  54592. */
  54593. 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;
  54594. /**
  54595. * Import animations from a file into a scene
  54596. * @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)
  54597. * @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)
  54598. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54599. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54600. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54601. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54602. * @param onSuccess a callback with the scene when import succeeds
  54603. * @param onProgress a callback with a progress event for each file being loaded
  54604. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54605. * @param pluginExtension the extension used to determine the plugin
  54606. * @returns the updated scene with imported animations
  54607. */
  54608. 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>;
  54609. }
  54610. }
  54611. declare module BABYLON {
  54612. /**
  54613. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54614. */
  54615. export type MotionControllerHandedness = "none" | "left" | "right";
  54616. /**
  54617. * The type of components available in motion controllers.
  54618. * This is not the name of the component.
  54619. */
  54620. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54621. /**
  54622. * The state of a controller component
  54623. */
  54624. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54625. /**
  54626. * The schema of motion controller layout.
  54627. * No object will be initialized using this interface
  54628. * This is used just to define the profile.
  54629. */
  54630. export interface IMotionControllerLayout {
  54631. /**
  54632. * Path to load the assets. Usually relative to the base path
  54633. */
  54634. assetPath: string;
  54635. /**
  54636. * Available components (unsorted)
  54637. */
  54638. components: {
  54639. /**
  54640. * A map of component Ids
  54641. */
  54642. [componentId: string]: {
  54643. /**
  54644. * The type of input the component outputs
  54645. */
  54646. type: MotionControllerComponentType;
  54647. /**
  54648. * The indices of this component in the gamepad object
  54649. */
  54650. gamepadIndices: {
  54651. /**
  54652. * Index of button
  54653. */
  54654. button?: number;
  54655. /**
  54656. * If available, index of x-axis
  54657. */
  54658. xAxis?: number;
  54659. /**
  54660. * If available, index of y-axis
  54661. */
  54662. yAxis?: number;
  54663. };
  54664. /**
  54665. * The mesh's root node name
  54666. */
  54667. rootNodeName: string;
  54668. /**
  54669. * Animation definitions for this model
  54670. */
  54671. visualResponses: {
  54672. [stateKey: string]: {
  54673. /**
  54674. * What property will be animated
  54675. */
  54676. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54677. /**
  54678. * What states influence this visual response
  54679. */
  54680. states: MotionControllerComponentStateType[];
  54681. /**
  54682. * Type of animation - movement or visibility
  54683. */
  54684. valueNodeProperty: "transform" | "visibility";
  54685. /**
  54686. * Base node name to move. Its position will be calculated according to the min and max nodes
  54687. */
  54688. valueNodeName?: string;
  54689. /**
  54690. * Minimum movement node
  54691. */
  54692. minNodeName?: string;
  54693. /**
  54694. * Max movement node
  54695. */
  54696. maxNodeName?: string;
  54697. };
  54698. };
  54699. /**
  54700. * If touch enabled, what is the name of node to display user feedback
  54701. */
  54702. touchPointNodeName?: string;
  54703. };
  54704. };
  54705. /**
  54706. * Is it xr standard mapping or not
  54707. */
  54708. gamepadMapping: "" | "xr-standard";
  54709. /**
  54710. * Base root node of this entire model
  54711. */
  54712. rootNodeName: string;
  54713. /**
  54714. * Defines the main button component id
  54715. */
  54716. selectComponentId: string;
  54717. }
  54718. /**
  54719. * A definition for the layout map in the input profile
  54720. */
  54721. export interface IMotionControllerLayoutMap {
  54722. /**
  54723. * Layouts with handedness type as a key
  54724. */
  54725. [handedness: string]: IMotionControllerLayout;
  54726. }
  54727. /**
  54728. * The XR Input profile schema
  54729. * Profiles can be found here:
  54730. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54731. */
  54732. export interface IMotionControllerProfile {
  54733. /**
  54734. * fallback profiles for this profileId
  54735. */
  54736. fallbackProfileIds: string[];
  54737. /**
  54738. * The layout map, with handedness as key
  54739. */
  54740. layouts: IMotionControllerLayoutMap;
  54741. /**
  54742. * The id of this profile
  54743. * correlates to the profile(s) in the xrInput.profiles array
  54744. */
  54745. profileId: string;
  54746. }
  54747. /**
  54748. * A helper-interface for the 3 meshes needed for controller button animation
  54749. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54750. */
  54751. export interface IMotionControllerButtonMeshMap {
  54752. /**
  54753. * the mesh that defines the pressed value mesh position.
  54754. * This is used to find the max-position of this button
  54755. */
  54756. pressedMesh: AbstractMesh;
  54757. /**
  54758. * the mesh that defines the unpressed value mesh position.
  54759. * This is used to find the min (or initial) position of this button
  54760. */
  54761. unpressedMesh: AbstractMesh;
  54762. /**
  54763. * The mesh that will be changed when value changes
  54764. */
  54765. valueMesh: AbstractMesh;
  54766. }
  54767. /**
  54768. * A helper-interface for the 3 meshes needed for controller axis animation.
  54769. * This will be expanded when touchpad animations are fully supported
  54770. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54771. */
  54772. export interface IMotionControllerMeshMap {
  54773. /**
  54774. * the mesh that defines the maximum value mesh position.
  54775. */
  54776. maxMesh?: AbstractMesh;
  54777. /**
  54778. * the mesh that defines the minimum value mesh position.
  54779. */
  54780. minMesh?: AbstractMesh;
  54781. /**
  54782. * The mesh that will be changed when axis value changes
  54783. */
  54784. valueMesh?: AbstractMesh;
  54785. }
  54786. /**
  54787. * The elements needed for change-detection of the gamepad objects in motion controllers
  54788. */
  54789. export interface IMinimalMotionControllerObject {
  54790. /**
  54791. * Available axes of this controller
  54792. */
  54793. axes: number[];
  54794. /**
  54795. * An array of available buttons
  54796. */
  54797. buttons: Array<{
  54798. /**
  54799. * Value of the button/trigger
  54800. */
  54801. value: number;
  54802. /**
  54803. * If the button/trigger is currently touched
  54804. */
  54805. touched: boolean;
  54806. /**
  54807. * If the button/trigger is currently pressed
  54808. */
  54809. pressed: boolean;
  54810. }>;
  54811. /**
  54812. * EXPERIMENTAL haptic support.
  54813. */
  54814. hapticActuators?: Array<{
  54815. pulse: (value: number, duration: number) => Promise<boolean>;
  54816. }>;
  54817. }
  54818. /**
  54819. * An Abstract Motion controller
  54820. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54821. * Each component has an observable to check for changes in value and state
  54822. */
  54823. export abstract class WebXRAbstractMotionController implements IDisposable {
  54824. protected scene: Scene;
  54825. protected layout: IMotionControllerLayout;
  54826. /**
  54827. * The gamepad object correlating to this controller
  54828. */
  54829. gamepadObject: IMinimalMotionControllerObject;
  54830. /**
  54831. * handedness (left/right/none) of this controller
  54832. */
  54833. handedness: MotionControllerHandedness;
  54834. private _initComponent;
  54835. private _modelReady;
  54836. /**
  54837. * A map of components (WebXRControllerComponent) in this motion controller
  54838. * Components have a ComponentType and can also have both button and axis definitions
  54839. */
  54840. readonly components: {
  54841. [id: string]: WebXRControllerComponent;
  54842. };
  54843. /**
  54844. * Disable the model's animation. Can be set at any time.
  54845. */
  54846. disableAnimation: boolean;
  54847. /**
  54848. * Observers registered here will be triggered when the model of this controller is done loading
  54849. */
  54850. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54851. /**
  54852. * The profile id of this motion controller
  54853. */
  54854. abstract profileId: string;
  54855. /**
  54856. * The root mesh of the model. It is null if the model was not yet initialized
  54857. */
  54858. rootMesh: Nullable<AbstractMesh>;
  54859. /**
  54860. * constructs a new abstract motion controller
  54861. * @param scene the scene to which the model of the controller will be added
  54862. * @param layout The profile layout to load
  54863. * @param gamepadObject The gamepad object correlating to this controller
  54864. * @param handedness handedness (left/right/none) of this controller
  54865. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54866. */
  54867. constructor(scene: Scene, layout: IMotionControllerLayout,
  54868. /**
  54869. * The gamepad object correlating to this controller
  54870. */
  54871. gamepadObject: IMinimalMotionControllerObject,
  54872. /**
  54873. * handedness (left/right/none) of this controller
  54874. */
  54875. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54876. /**
  54877. * Dispose this controller, the model mesh and all its components
  54878. */
  54879. dispose(): void;
  54880. /**
  54881. * Returns all components of specific type
  54882. * @param type the type to search for
  54883. * @return an array of components with this type
  54884. */
  54885. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54886. /**
  54887. * get a component based an its component id as defined in layout.components
  54888. * @param id the id of the component
  54889. * @returns the component correlates to the id or undefined if not found
  54890. */
  54891. getComponent(id: string): WebXRControllerComponent;
  54892. /**
  54893. * Get the list of components available in this motion controller
  54894. * @returns an array of strings correlating to available components
  54895. */
  54896. getComponentIds(): string[];
  54897. /**
  54898. * Get the first component of specific type
  54899. * @param type type of component to find
  54900. * @return a controller component or null if not found
  54901. */
  54902. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54903. /**
  54904. * Get the main (Select) component of this controller as defined in the layout
  54905. * @returns the main component of this controller
  54906. */
  54907. getMainComponent(): WebXRControllerComponent;
  54908. /**
  54909. * Loads the model correlating to this controller
  54910. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54911. * @returns A promise fulfilled with the result of the model loading
  54912. */
  54913. loadModel(): Promise<boolean>;
  54914. /**
  54915. * Update this model using the current XRFrame
  54916. * @param xrFrame the current xr frame to use and update the model
  54917. */
  54918. updateFromXRFrame(xrFrame: XRFrame): void;
  54919. /**
  54920. * Backwards compatibility due to a deeply-integrated typo
  54921. */
  54922. get handness(): XREye;
  54923. /**
  54924. * Pulse (vibrate) this controller
  54925. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54926. * Consecutive calls to this function will cancel the last pulse call
  54927. *
  54928. * @param value the strength of the pulse in 0.0...1.0 range
  54929. * @param duration Duration of the pulse in milliseconds
  54930. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54931. * @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
  54932. */
  54933. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54934. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54935. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54936. /**
  54937. * Moves the axis on the controller mesh based on its current state
  54938. * @param axis the index of the axis
  54939. * @param axisValue the value of the axis which determines the meshes new position
  54940. * @hidden
  54941. */
  54942. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54943. /**
  54944. * Update the model itself with the current frame data
  54945. * @param xrFrame the frame to use for updating the model mesh
  54946. */
  54947. protected updateModel(xrFrame: XRFrame): void;
  54948. /**
  54949. * Get the filename and path for this controller's model
  54950. * @returns a map of filename and path
  54951. */
  54952. protected abstract _getFilenameAndPath(): {
  54953. filename: string;
  54954. path: string;
  54955. };
  54956. /**
  54957. * This function is called before the mesh is loaded. It checks for loading constraints.
  54958. * For example, this function can check if the GLB loader is available
  54959. * If this function returns false, the generic controller will be loaded instead
  54960. * @returns Is the client ready to load the mesh
  54961. */
  54962. protected abstract _getModelLoadingConstraints(): boolean;
  54963. /**
  54964. * This function will be called after the model was successfully loaded and can be used
  54965. * for mesh transformations before it is available for the user
  54966. * @param meshes the loaded meshes
  54967. */
  54968. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54969. /**
  54970. * Set the root mesh for this controller. Important for the WebXR controller class
  54971. * @param meshes the loaded meshes
  54972. */
  54973. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54974. /**
  54975. * A function executed each frame that updates the mesh (if needed)
  54976. * @param xrFrame the current xrFrame
  54977. */
  54978. protected abstract _updateModel(xrFrame: XRFrame): void;
  54979. private _getGenericFilenameAndPath;
  54980. private _getGenericParentMesh;
  54981. }
  54982. }
  54983. declare module BABYLON {
  54984. /**
  54985. * A generic trigger-only motion controller for WebXR
  54986. */
  54987. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54988. /**
  54989. * Static version of the profile id of this controller
  54990. */
  54991. static ProfileId: string;
  54992. profileId: string;
  54993. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54994. protected _getFilenameAndPath(): {
  54995. filename: string;
  54996. path: string;
  54997. };
  54998. protected _getModelLoadingConstraints(): boolean;
  54999. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55000. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55001. protected _updateModel(): void;
  55002. }
  55003. }
  55004. declare module BABYLON {
  55005. /**
  55006. * Class containing static functions to help procedurally build meshes
  55007. */
  55008. export class SphereBuilder {
  55009. /**
  55010. * Creates a sphere mesh
  55011. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55012. * * 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`)
  55013. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55014. * * 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
  55015. * * 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)
  55016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55017. * * 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
  55018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55019. * @param name defines the name of the mesh
  55020. * @param options defines the options used to create the mesh
  55021. * @param scene defines the hosting scene
  55022. * @returns the sphere mesh
  55023. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55024. */
  55025. static CreateSphere(name: string, options: {
  55026. segments?: number;
  55027. diameter?: number;
  55028. diameterX?: number;
  55029. diameterY?: number;
  55030. diameterZ?: number;
  55031. arc?: number;
  55032. slice?: number;
  55033. sideOrientation?: number;
  55034. frontUVs?: Vector4;
  55035. backUVs?: Vector4;
  55036. updatable?: boolean;
  55037. }, scene?: Nullable<Scene>): Mesh;
  55038. }
  55039. }
  55040. declare module BABYLON {
  55041. /**
  55042. * A profiled motion controller has its profile loaded from an online repository.
  55043. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55044. */
  55045. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55046. private _repositoryUrl;
  55047. private _buttonMeshMapping;
  55048. private _touchDots;
  55049. /**
  55050. * The profile ID of this controller. Will be populated when the controller initializes.
  55051. */
  55052. profileId: string;
  55053. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55054. dispose(): void;
  55055. protected _getFilenameAndPath(): {
  55056. filename: string;
  55057. path: string;
  55058. };
  55059. protected _getModelLoadingConstraints(): boolean;
  55060. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55061. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55062. protected _updateModel(_xrFrame: XRFrame): void;
  55063. }
  55064. }
  55065. declare module BABYLON {
  55066. /**
  55067. * A construction function type to create a new controller based on an xrInput object
  55068. */
  55069. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55070. /**
  55071. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55072. *
  55073. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55074. * it should be replaced with auto-loaded controllers.
  55075. *
  55076. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55077. */
  55078. export class WebXRMotionControllerManager {
  55079. private static _AvailableControllers;
  55080. private static _Fallbacks;
  55081. private static _ProfileLoadingPromises;
  55082. private static _ProfilesList;
  55083. /**
  55084. * The base URL of the online controller repository. Can be changed at any time.
  55085. */
  55086. static BaseRepositoryUrl: string;
  55087. /**
  55088. * Which repository gets priority - local or online
  55089. */
  55090. static PrioritizeOnlineRepository: boolean;
  55091. /**
  55092. * Use the online repository, or use only locally-defined controllers
  55093. */
  55094. static UseOnlineRepository: boolean;
  55095. /**
  55096. * Clear the cache used for profile loading and reload when requested again
  55097. */
  55098. static ClearProfilesCache(): void;
  55099. /**
  55100. * Register the default fallbacks.
  55101. * This function is called automatically when this file is imported.
  55102. */
  55103. static DefaultFallbacks(): void;
  55104. /**
  55105. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55106. * @param profileId the profile to which a fallback needs to be found
  55107. * @return an array with corresponding fallback profiles
  55108. */
  55109. static FindFallbackWithProfileId(profileId: string): string[];
  55110. /**
  55111. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55112. * The order of search:
  55113. *
  55114. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55115. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55116. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55117. * 4) return the generic trigger controller if none were found
  55118. *
  55119. * @param xrInput the xrInput to which a new controller is initialized
  55120. * @param scene the scene to which the model will be added
  55121. * @param forceProfile force a certain profile for this controller
  55122. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55123. */
  55124. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55125. /**
  55126. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55127. *
  55128. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55129. *
  55130. * @param type the profile type to register
  55131. * @param constructFunction the function to be called when loading this profile
  55132. */
  55133. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55134. /**
  55135. * Register a fallback to a specific profile.
  55136. * @param profileId the profileId that will receive the fallbacks
  55137. * @param fallbacks A list of fallback profiles
  55138. */
  55139. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55140. /**
  55141. * Will update the list of profiles available in the repository
  55142. * @return a promise that resolves to a map of profiles available online
  55143. */
  55144. static UpdateProfilesList(): Promise<{
  55145. [profile: string]: string;
  55146. }>;
  55147. private static _LoadProfileFromRepository;
  55148. private static _LoadProfilesFromAvailableControllers;
  55149. }
  55150. }
  55151. declare module BABYLON {
  55152. /**
  55153. * Configuration options for the WebXR controller creation
  55154. */
  55155. export interface IWebXRControllerOptions {
  55156. /**
  55157. * Should the controller mesh be animated when a user interacts with it
  55158. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55159. */
  55160. disableMotionControllerAnimation?: boolean;
  55161. /**
  55162. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55163. */
  55164. doNotLoadControllerMesh?: boolean;
  55165. /**
  55166. * Force a specific controller type for this controller.
  55167. * This can be used when creating your own profile or when testing different controllers
  55168. */
  55169. forceControllerProfile?: string;
  55170. /**
  55171. * Defines a rendering group ID for meshes that will be loaded.
  55172. * This is for the default controllers only.
  55173. */
  55174. renderingGroupId?: number;
  55175. }
  55176. /**
  55177. * Represents an XR controller
  55178. */
  55179. export class WebXRInputSource {
  55180. private _scene;
  55181. /** The underlying input source for the controller */
  55182. inputSource: XRInputSource;
  55183. private _options;
  55184. private _tmpVector;
  55185. private _uniqueId;
  55186. private _disposed;
  55187. /**
  55188. * 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
  55189. */
  55190. grip?: AbstractMesh;
  55191. /**
  55192. * If available, this is the gamepad object related to this controller.
  55193. * Using this object it is possible to get click events and trackpad changes of the
  55194. * webxr controller that is currently being used.
  55195. */
  55196. motionController?: WebXRAbstractMotionController;
  55197. /**
  55198. * Event that fires when the controller is removed/disposed.
  55199. * The object provided as event data is this controller, after associated assets were disposed.
  55200. * uniqueId is still available.
  55201. */
  55202. onDisposeObservable: Observable<WebXRInputSource>;
  55203. /**
  55204. * Will be triggered when the mesh associated with the motion controller is done loading.
  55205. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55206. * A shortened version of controller -> motion controller -> on mesh loaded.
  55207. */
  55208. onMeshLoadedObservable: Observable<AbstractMesh>;
  55209. /**
  55210. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55211. */
  55212. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55213. /**
  55214. * Pointer which can be used to select objects or attach a visible laser to
  55215. */
  55216. pointer: AbstractMesh;
  55217. /**
  55218. * Creates the input source object
  55219. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55220. * @param _scene the scene which the controller should be associated to
  55221. * @param inputSource the underlying input source for the controller
  55222. * @param _options options for this controller creation
  55223. */
  55224. constructor(_scene: Scene,
  55225. /** The underlying input source for the controller */
  55226. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55227. /**
  55228. * Get this controllers unique id
  55229. */
  55230. get uniqueId(): string;
  55231. /**
  55232. * Disposes of the object
  55233. */
  55234. dispose(): void;
  55235. /**
  55236. * Gets a world space ray coming from the pointer or grip
  55237. * @param result the resulting ray
  55238. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55239. */
  55240. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55241. /**
  55242. * Updates the controller pose based on the given XRFrame
  55243. * @param xrFrame xr frame to update the pose with
  55244. * @param referenceSpace reference space to use
  55245. */
  55246. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55247. }
  55248. }
  55249. declare module BABYLON {
  55250. /**
  55251. * The schema for initialization options of the XR Input class
  55252. */
  55253. export interface IWebXRInputOptions {
  55254. /**
  55255. * If set to true no model will be automatically loaded
  55256. */
  55257. doNotLoadControllerMeshes?: boolean;
  55258. /**
  55259. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55260. * If not found, the xr input profile data will be used.
  55261. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55262. */
  55263. forceInputProfile?: string;
  55264. /**
  55265. * Do not send a request to the controller repository to load the profile.
  55266. *
  55267. * Instead, use the controllers available in babylon itself.
  55268. */
  55269. disableOnlineControllerRepository?: boolean;
  55270. /**
  55271. * A custom URL for the controllers repository
  55272. */
  55273. customControllersRepositoryURL?: string;
  55274. /**
  55275. * Should the controller model's components not move according to the user input
  55276. */
  55277. disableControllerAnimation?: boolean;
  55278. /**
  55279. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55280. */
  55281. controllerOptions?: IWebXRControllerOptions;
  55282. }
  55283. /**
  55284. * XR input used to track XR inputs such as controllers/rays
  55285. */
  55286. export class WebXRInput implements IDisposable {
  55287. /**
  55288. * the xr session manager for this session
  55289. */
  55290. xrSessionManager: WebXRSessionManager;
  55291. /**
  55292. * the WebXR camera for this session. Mainly used for teleportation
  55293. */
  55294. xrCamera: WebXRCamera;
  55295. private readonly options;
  55296. /**
  55297. * XR controllers being tracked
  55298. */
  55299. controllers: Array<WebXRInputSource>;
  55300. private _frameObserver;
  55301. private _sessionEndedObserver;
  55302. private _sessionInitObserver;
  55303. /**
  55304. * Event when a controller has been connected/added
  55305. */
  55306. onControllerAddedObservable: Observable<WebXRInputSource>;
  55307. /**
  55308. * Event when a controller has been removed/disconnected
  55309. */
  55310. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55311. /**
  55312. * Initializes the WebXRInput
  55313. * @param xrSessionManager the xr session manager for this session
  55314. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55315. * @param options = initialization options for this xr input
  55316. */
  55317. constructor(
  55318. /**
  55319. * the xr session manager for this session
  55320. */
  55321. xrSessionManager: WebXRSessionManager,
  55322. /**
  55323. * the WebXR camera for this session. Mainly used for teleportation
  55324. */
  55325. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55326. private _onInputSourcesChange;
  55327. private _addAndRemoveControllers;
  55328. /**
  55329. * Disposes of the object
  55330. */
  55331. dispose(): void;
  55332. }
  55333. }
  55334. declare module BABYLON {
  55335. /**
  55336. * This is the base class for all WebXR features.
  55337. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55338. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55339. */
  55340. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55341. protected _xrSessionManager: WebXRSessionManager;
  55342. private _attached;
  55343. private _removeOnDetach;
  55344. /**
  55345. * Is this feature disposed?
  55346. */
  55347. isDisposed: boolean;
  55348. /**
  55349. * Should auto-attach be disabled?
  55350. */
  55351. disableAutoAttach: boolean;
  55352. /**
  55353. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55354. */
  55355. xrNativeFeatureName: string;
  55356. /**
  55357. * Construct a new (abstract) WebXR feature
  55358. * @param _xrSessionManager the xr session manager for this feature
  55359. */
  55360. constructor(_xrSessionManager: WebXRSessionManager);
  55361. /**
  55362. * Is this feature attached
  55363. */
  55364. get attached(): boolean;
  55365. /**
  55366. * attach this feature
  55367. *
  55368. * @param force should attachment be forced (even when already attached)
  55369. * @returns true if successful, false is failed or already attached
  55370. */
  55371. attach(force?: boolean): boolean;
  55372. /**
  55373. * detach this feature.
  55374. *
  55375. * @returns true if successful, false if failed or already detached
  55376. */
  55377. detach(): boolean;
  55378. /**
  55379. * Dispose this feature and all of the resources attached
  55380. */
  55381. dispose(): void;
  55382. /**
  55383. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55384. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55385. *
  55386. * @returns whether or not the feature is compatible in this environment
  55387. */
  55388. isCompatible(): boolean;
  55389. /**
  55390. * This is used to register callbacks that will automatically be removed when detach is called.
  55391. * @param observable the observable to which the observer will be attached
  55392. * @param callback the callback to register
  55393. */
  55394. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55395. /**
  55396. * Code in this function will be executed on each xrFrame received from the browser.
  55397. * This function will not execute after the feature is detached.
  55398. * @param _xrFrame the current frame
  55399. */
  55400. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55401. }
  55402. }
  55403. declare module BABYLON {
  55404. /**
  55405. * Renders a layer on top of an existing scene
  55406. */
  55407. export class UtilityLayerRenderer implements IDisposable {
  55408. /** the original scene that will be rendered on top of */
  55409. originalScene: Scene;
  55410. private _pointerCaptures;
  55411. private _lastPointerEvents;
  55412. private static _DefaultUtilityLayer;
  55413. private static _DefaultKeepDepthUtilityLayer;
  55414. private _sharedGizmoLight;
  55415. private _renderCamera;
  55416. /**
  55417. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55418. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55419. * @returns the camera that is used when rendering the utility layer
  55420. */
  55421. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55422. /**
  55423. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55424. * @param cam the camera that should be used when rendering the utility layer
  55425. */
  55426. setRenderCamera(cam: Nullable<Camera>): void;
  55427. /**
  55428. * @hidden
  55429. * Light which used by gizmos to get light shading
  55430. */
  55431. _getSharedGizmoLight(): HemisphericLight;
  55432. /**
  55433. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55434. */
  55435. pickUtilitySceneFirst: boolean;
  55436. /**
  55437. * 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)
  55438. */
  55439. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55440. /**
  55441. * 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)
  55442. */
  55443. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55444. /**
  55445. * The scene that is rendered on top of the original scene
  55446. */
  55447. utilityLayerScene: Scene;
  55448. /**
  55449. * If the utility layer should automatically be rendered on top of existing scene
  55450. */
  55451. shouldRender: boolean;
  55452. /**
  55453. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55454. */
  55455. onlyCheckPointerDownEvents: boolean;
  55456. /**
  55457. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55458. */
  55459. processAllEvents: boolean;
  55460. /**
  55461. * Observable raised when the pointer move from the utility layer scene to the main scene
  55462. */
  55463. onPointerOutObservable: Observable<number>;
  55464. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55465. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55466. private _afterRenderObserver;
  55467. private _sceneDisposeObserver;
  55468. private _originalPointerObserver;
  55469. /**
  55470. * Instantiates a UtilityLayerRenderer
  55471. * @param originalScene the original scene that will be rendered on top of
  55472. * @param handleEvents boolean indicating if the utility layer should handle events
  55473. */
  55474. constructor(
  55475. /** the original scene that will be rendered on top of */
  55476. originalScene: Scene, handleEvents?: boolean);
  55477. private _notifyObservers;
  55478. /**
  55479. * Renders the utility layers scene on top of the original scene
  55480. */
  55481. render(): void;
  55482. /**
  55483. * Disposes of the renderer
  55484. */
  55485. dispose(): void;
  55486. private _updateCamera;
  55487. }
  55488. }
  55489. declare module BABYLON {
  55490. /**
  55491. * Options interface for the pointer selection module
  55492. */
  55493. export interface IWebXRControllerPointerSelectionOptions {
  55494. /**
  55495. * if provided, this scene will be used to render meshes.
  55496. */
  55497. customUtilityLayerScene?: Scene;
  55498. /**
  55499. * 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)
  55500. * If not disabled, the last picked point will be used to execute a pointer up event
  55501. * If disabled, pointer up event will be triggered right after the pointer down event.
  55502. * Used in screen and gaze target ray mode only
  55503. */
  55504. disablePointerUpOnTouchOut: boolean;
  55505. /**
  55506. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55507. */
  55508. forceGazeMode: boolean;
  55509. /**
  55510. * 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
  55511. * to start a new countdown to the pointer down event.
  55512. * Defaults to 1.
  55513. */
  55514. gazeModePointerMovedFactor?: number;
  55515. /**
  55516. * Different button type to use instead of the main component
  55517. */
  55518. overrideButtonId?: string;
  55519. /**
  55520. * use this rendering group id for the meshes (optional)
  55521. */
  55522. renderingGroupId?: number;
  55523. /**
  55524. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55525. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55526. * 3000 means 3 seconds between pointing at something and selecting it
  55527. */
  55528. timeToSelect?: number;
  55529. /**
  55530. * Should meshes created here be added to a utility layer or the main scene
  55531. */
  55532. useUtilityLayer?: boolean;
  55533. /**
  55534. * Optional WebXR camera to be used for gaze selection
  55535. */
  55536. gazeCamera?: WebXRCamera;
  55537. /**
  55538. * the xr input to use with this pointer selection
  55539. */
  55540. xrInput: WebXRInput;
  55541. /**
  55542. * Should the scene pointerX and pointerY update be disabled
  55543. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55544. * Disable in VR, if not needed.
  55545. * The first rig camera (left eye) will be used to calculate the projection
  55546. */
  55547. disableScenePointerVectorUpdate: boolean;
  55548. /**
  55549. * Enable pointer selection on all controllers instead of switching between them
  55550. */
  55551. enablePointerSelectionOnAllControllers?: boolean;
  55552. /**
  55553. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55554. * If switch is enabled, it will still allow the user to switch between the different controllers
  55555. */
  55556. preferredHandedness?: XRHandedness;
  55557. /**
  55558. * Disable switching the pointer selection from one controller to the other.
  55559. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  55560. */
  55561. disableSwitchOnClick?: boolean;
  55562. /**
  55563. * The maximum distance of the pointer selection feature. Defaults to 100.
  55564. */
  55565. maxPointerDistance?: number;
  55566. }
  55567. /**
  55568. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55569. */
  55570. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55571. private readonly _options;
  55572. private static _idCounter;
  55573. private _attachController;
  55574. private _controllers;
  55575. private _scene;
  55576. private _tmpVectorForPickCompare;
  55577. private _attachedController;
  55578. /**
  55579. * The module's name
  55580. */
  55581. static readonly Name: string;
  55582. /**
  55583. * The (Babylon) version of this module.
  55584. * This is an integer representing the implementation version.
  55585. * This number does not correspond to the WebXR specs version
  55586. */
  55587. static readonly Version: number;
  55588. /**
  55589. * Disable lighting on the laser pointer (so it will always be visible)
  55590. */
  55591. disablePointerLighting: boolean;
  55592. /**
  55593. * Disable lighting on the selection mesh (so it will always be visible)
  55594. */
  55595. disableSelectionMeshLighting: boolean;
  55596. /**
  55597. * Should the laser pointer be displayed
  55598. */
  55599. displayLaserPointer: boolean;
  55600. /**
  55601. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55602. */
  55603. displaySelectionMesh: boolean;
  55604. /**
  55605. * This color will be set to the laser pointer when selection is triggered
  55606. */
  55607. laserPointerPickedColor: Color3;
  55608. /**
  55609. * Default color of the laser pointer
  55610. */
  55611. laserPointerDefaultColor: Color3;
  55612. /**
  55613. * default color of the selection ring
  55614. */
  55615. selectionMeshDefaultColor: Color3;
  55616. /**
  55617. * This color will be applied to the selection ring when selection is triggered
  55618. */
  55619. selectionMeshPickedColor: Color3;
  55620. /**
  55621. * Optional filter to be used for ray selection. This predicate shares behavior with
  55622. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55623. */
  55624. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55625. /**
  55626. * constructs a new background remover module
  55627. * @param _xrSessionManager the session manager for this module
  55628. * @param _options read-only options to be used in this module
  55629. */
  55630. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55631. /**
  55632. * attach this feature
  55633. * Will usually be called by the features manager
  55634. *
  55635. * @returns true if successful.
  55636. */
  55637. attach(): boolean;
  55638. /**
  55639. * detach this feature.
  55640. * Will usually be called by the features manager
  55641. *
  55642. * @returns true if successful.
  55643. */
  55644. detach(): boolean;
  55645. /**
  55646. * Will get the mesh under a specific pointer.
  55647. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55648. * @param controllerId the controllerId to check
  55649. * @returns The mesh under pointer or null if no mesh is under the pointer
  55650. */
  55651. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55652. /**
  55653. * Get the xr controller that correlates to the pointer id in the pointer event
  55654. *
  55655. * @param id the pointer id to search for
  55656. * @returns the controller that correlates to this id or null if not found
  55657. */
  55658. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55659. private _identityMatrix;
  55660. private _screenCoordinatesRef;
  55661. private _viewportRef;
  55662. protected _onXRFrame(_xrFrame: XRFrame): void;
  55663. private _attachGazeMode;
  55664. private _attachScreenRayMode;
  55665. private _attachTrackedPointerRayMode;
  55666. private _convertNormalToDirectionOfRay;
  55667. private _detachController;
  55668. private _generateNewMeshPair;
  55669. private _pickingMoved;
  55670. private _updatePointerDistance;
  55671. /** @hidden */
  55672. get lasterPointerDefaultColor(): Color3;
  55673. }
  55674. }
  55675. declare module BABYLON {
  55676. /**
  55677. * Button which can be used to enter a different mode of XR
  55678. */
  55679. export class WebXREnterExitUIButton {
  55680. /** button element */
  55681. element: HTMLElement;
  55682. /** XR initialization options for the button */
  55683. sessionMode: XRSessionMode;
  55684. /** Reference space type */
  55685. referenceSpaceType: XRReferenceSpaceType;
  55686. /**
  55687. * Creates a WebXREnterExitUIButton
  55688. * @param element button element
  55689. * @param sessionMode XR initialization session mode
  55690. * @param referenceSpaceType the type of reference space to be used
  55691. */
  55692. constructor(
  55693. /** button element */
  55694. element: HTMLElement,
  55695. /** XR initialization options for the button */
  55696. sessionMode: XRSessionMode,
  55697. /** Reference space type */
  55698. referenceSpaceType: XRReferenceSpaceType);
  55699. /**
  55700. * Extendable function which can be used to update the button's visuals when the state changes
  55701. * @param activeButton the current active button in the UI
  55702. */
  55703. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55704. }
  55705. /**
  55706. * Options to create the webXR UI
  55707. */
  55708. export class WebXREnterExitUIOptions {
  55709. /**
  55710. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55711. */
  55712. customButtons?: Array<WebXREnterExitUIButton>;
  55713. /**
  55714. * A reference space type to use when creating the default button.
  55715. * Default is local-floor
  55716. */
  55717. referenceSpaceType?: XRReferenceSpaceType;
  55718. /**
  55719. * Context to enter xr with
  55720. */
  55721. renderTarget?: Nullable<WebXRRenderTarget>;
  55722. /**
  55723. * A session mode to use when creating the default button.
  55724. * Default is immersive-vr
  55725. */
  55726. sessionMode?: XRSessionMode;
  55727. /**
  55728. * A list of optional features to init the session with
  55729. */
  55730. optionalFeatures?: string[];
  55731. /**
  55732. * A list of optional features to init the session with
  55733. */
  55734. requiredFeatures?: string[];
  55735. /**
  55736. * If defined, this function will be executed if the UI encounters an error when entering XR
  55737. */
  55738. onError?: (error: any) => void;
  55739. }
  55740. /**
  55741. * UI to allow the user to enter/exit XR mode
  55742. */
  55743. export class WebXREnterExitUI implements IDisposable {
  55744. private scene;
  55745. /** version of the options passed to this UI */
  55746. options: WebXREnterExitUIOptions;
  55747. private _activeButton;
  55748. private _buttons;
  55749. /**
  55750. * The HTML Div Element to which buttons are added.
  55751. */
  55752. readonly overlay: HTMLDivElement;
  55753. /**
  55754. * Fired every time the active button is changed.
  55755. *
  55756. * When xr is entered via a button that launches xr that button will be the callback parameter
  55757. *
  55758. * When exiting xr the callback parameter will be null)
  55759. */
  55760. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55761. /**
  55762. *
  55763. * @param scene babylon scene object to use
  55764. * @param options (read-only) version of the options passed to this UI
  55765. */
  55766. private constructor();
  55767. /**
  55768. * Creates UI to allow the user to enter/exit XR mode
  55769. * @param scene the scene to add the ui to
  55770. * @param helper the xr experience helper to enter/exit xr with
  55771. * @param options options to configure the UI
  55772. * @returns the created ui
  55773. */
  55774. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55775. /**
  55776. * Disposes of the XR UI component
  55777. */
  55778. dispose(): void;
  55779. private _updateButtons;
  55780. }
  55781. }
  55782. declare module BABYLON {
  55783. /**
  55784. * Class containing static functions to help procedurally build meshes
  55785. */
  55786. export class LinesBuilder {
  55787. /**
  55788. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55789. * * 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
  55790. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55791. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55792. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55793. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55794. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55795. * * 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
  55796. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55799. * @param name defines the name of the new line system
  55800. * @param options defines the options used to create the line system
  55801. * @param scene defines the hosting scene
  55802. * @returns a new line system mesh
  55803. */
  55804. static CreateLineSystem(name: string, options: {
  55805. lines: Vector3[][];
  55806. updatable?: boolean;
  55807. instance?: Nullable<LinesMesh>;
  55808. colors?: Nullable<Color4[][]>;
  55809. useVertexAlpha?: boolean;
  55810. }, scene: Nullable<Scene>): LinesMesh;
  55811. /**
  55812. * Creates a line mesh
  55813. * 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
  55814. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55815. * * The parameter `points` is an array successive Vector3
  55816. * * 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
  55817. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55818. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55819. * * When updating an instance, remember that only point positions can change, not the number of points
  55820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55822. * @param name defines the name of the new line system
  55823. * @param options defines the options used to create the line system
  55824. * @param scene defines the hosting scene
  55825. * @returns a new line mesh
  55826. */
  55827. static CreateLines(name: string, options: {
  55828. points: Vector3[];
  55829. updatable?: boolean;
  55830. instance?: Nullable<LinesMesh>;
  55831. colors?: Color4[];
  55832. useVertexAlpha?: boolean;
  55833. }, scene?: Nullable<Scene>): LinesMesh;
  55834. /**
  55835. * Creates a dashed line mesh
  55836. * * 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
  55837. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55838. * * The parameter `points` is an array successive Vector3
  55839. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55840. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55841. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55842. * * 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
  55843. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55844. * * When updating an instance, remember that only point positions can change, not the number of points
  55845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55846. * @param name defines the name of the mesh
  55847. * @param options defines the options used to create the mesh
  55848. * @param scene defines the hosting scene
  55849. * @returns the dashed line mesh
  55850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55851. */
  55852. static CreateDashedLines(name: string, options: {
  55853. points: Vector3[];
  55854. dashSize?: number;
  55855. gapSize?: number;
  55856. dashNb?: number;
  55857. updatable?: boolean;
  55858. instance?: LinesMesh;
  55859. useVertexAlpha?: boolean;
  55860. }, scene?: Nullable<Scene>): LinesMesh;
  55861. }
  55862. }
  55863. declare module BABYLON {
  55864. /**
  55865. * Construction options for a timer
  55866. */
  55867. export interface ITimerOptions<T> {
  55868. /**
  55869. * Time-to-end
  55870. */
  55871. timeout: number;
  55872. /**
  55873. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55874. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55875. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55876. */
  55877. contextObservable: Observable<T>;
  55878. /**
  55879. * Optional parameters when adding an observer to the observable
  55880. */
  55881. observableParameters?: {
  55882. mask?: number;
  55883. insertFirst?: boolean;
  55884. scope?: any;
  55885. };
  55886. /**
  55887. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55888. */
  55889. breakCondition?: (data?: ITimerData<T>) => boolean;
  55890. /**
  55891. * Will be triggered when the time condition has met
  55892. */
  55893. onEnded?: (data: ITimerData<any>) => void;
  55894. /**
  55895. * Will be triggered when the break condition has met (prematurely ended)
  55896. */
  55897. onAborted?: (data: ITimerData<any>) => void;
  55898. /**
  55899. * Optional function to execute on each tick (or count)
  55900. */
  55901. onTick?: (data: ITimerData<any>) => void;
  55902. }
  55903. /**
  55904. * An interface defining the data sent by the timer
  55905. */
  55906. export interface ITimerData<T> {
  55907. /**
  55908. * When did it start
  55909. */
  55910. startTime: number;
  55911. /**
  55912. * Time now
  55913. */
  55914. currentTime: number;
  55915. /**
  55916. * Time passed since started
  55917. */
  55918. deltaTime: number;
  55919. /**
  55920. * How much is completed, in [0.0...1.0].
  55921. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55922. */
  55923. completeRate: number;
  55924. /**
  55925. * What the registered observable sent in the last count
  55926. */
  55927. payload: T;
  55928. }
  55929. /**
  55930. * The current state of the timer
  55931. */
  55932. export enum TimerState {
  55933. /**
  55934. * Timer initialized, not yet started
  55935. */
  55936. INIT = 0,
  55937. /**
  55938. * Timer started and counting
  55939. */
  55940. STARTED = 1,
  55941. /**
  55942. * Timer ended (whether aborted or time reached)
  55943. */
  55944. ENDED = 2
  55945. }
  55946. /**
  55947. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55948. *
  55949. * @param options options with which to initialize this timer
  55950. */
  55951. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55952. /**
  55953. * An advanced implementation of a timer class
  55954. */
  55955. export class AdvancedTimer<T = any> implements IDisposable {
  55956. /**
  55957. * Will notify each time the timer calculates the remaining time
  55958. */
  55959. onEachCountObservable: Observable<ITimerData<T>>;
  55960. /**
  55961. * Will trigger when the timer was aborted due to the break condition
  55962. */
  55963. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55964. /**
  55965. * Will trigger when the timer ended successfully
  55966. */
  55967. onTimerEndedObservable: Observable<ITimerData<T>>;
  55968. /**
  55969. * Will trigger when the timer state has changed
  55970. */
  55971. onStateChangedObservable: Observable<TimerState>;
  55972. private _observer;
  55973. private _contextObservable;
  55974. private _observableParameters;
  55975. private _startTime;
  55976. private _timer;
  55977. private _state;
  55978. private _breakCondition;
  55979. private _timeToEnd;
  55980. private _breakOnNextTick;
  55981. /**
  55982. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55983. * @param options construction options for this advanced timer
  55984. */
  55985. constructor(options: ITimerOptions<T>);
  55986. /**
  55987. * set a breaking condition for this timer. Default is to never break during count
  55988. * @param predicate the new break condition. Returns true to break, false otherwise
  55989. */
  55990. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55991. /**
  55992. * Reset ALL associated observables in this advanced timer
  55993. */
  55994. clearObservables(): void;
  55995. /**
  55996. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55997. *
  55998. * @param timeToEnd how much time to measure until timer ended
  55999. */
  56000. start(timeToEnd?: number): void;
  56001. /**
  56002. * Will force a stop on the next tick.
  56003. */
  56004. stop(): void;
  56005. /**
  56006. * Dispose this timer, clearing all resources
  56007. */
  56008. dispose(): void;
  56009. private _setState;
  56010. private _tick;
  56011. private _stop;
  56012. }
  56013. }
  56014. declare module BABYLON {
  56015. /**
  56016. * The options container for the teleportation module
  56017. */
  56018. export interface IWebXRTeleportationOptions {
  56019. /**
  56020. * if provided, this scene will be used to render meshes.
  56021. */
  56022. customUtilityLayerScene?: Scene;
  56023. /**
  56024. * Values to configure the default target mesh
  56025. */
  56026. defaultTargetMeshOptions?: {
  56027. /**
  56028. * Fill color of the teleportation area
  56029. */
  56030. teleportationFillColor?: string;
  56031. /**
  56032. * Border color for the teleportation area
  56033. */
  56034. teleportationBorderColor?: string;
  56035. /**
  56036. * Disable the mesh's animation sequence
  56037. */
  56038. disableAnimation?: boolean;
  56039. /**
  56040. * Disable lighting on the material or the ring and arrow
  56041. */
  56042. disableLighting?: boolean;
  56043. /**
  56044. * Override the default material of the torus and arrow
  56045. */
  56046. torusArrowMaterial?: Material;
  56047. };
  56048. /**
  56049. * A list of meshes to use as floor meshes.
  56050. * Meshes can be added and removed after initializing the feature using the
  56051. * addFloorMesh and removeFloorMesh functions
  56052. * If empty, rotation will still work
  56053. */
  56054. floorMeshes?: AbstractMesh[];
  56055. /**
  56056. * use this rendering group id for the meshes (optional)
  56057. */
  56058. renderingGroupId?: number;
  56059. /**
  56060. * Should teleportation move only to snap points
  56061. */
  56062. snapPointsOnly?: boolean;
  56063. /**
  56064. * An array of points to which the teleportation will snap to.
  56065. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56066. */
  56067. snapPositions?: Vector3[];
  56068. /**
  56069. * How close should the teleportation ray be in order to snap to position.
  56070. * Default to 0.8 units (meters)
  56071. */
  56072. snapToPositionRadius?: number;
  56073. /**
  56074. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56075. * If you want to support rotation, make sure your mesh has a direction indicator.
  56076. *
  56077. * When left untouched, the default mesh will be initialized.
  56078. */
  56079. teleportationTargetMesh?: AbstractMesh;
  56080. /**
  56081. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56082. */
  56083. timeToTeleport?: number;
  56084. /**
  56085. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56086. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56087. */
  56088. useMainComponentOnly?: boolean;
  56089. /**
  56090. * Should meshes created here be added to a utility layer or the main scene
  56091. */
  56092. useUtilityLayer?: boolean;
  56093. /**
  56094. * Babylon XR Input class for controller
  56095. */
  56096. xrInput: WebXRInput;
  56097. /**
  56098. * Meshes that the teleportation ray cannot go through
  56099. */
  56100. pickBlockerMeshes?: AbstractMesh[];
  56101. /**
  56102. * Should teleport work only on a specific hand?
  56103. */
  56104. forceHandedness?: XRHandedness;
  56105. /**
  56106. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56107. */
  56108. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56109. }
  56110. /**
  56111. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56112. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56113. * the input of the attached controllers.
  56114. */
  56115. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56116. private _options;
  56117. private _controllers;
  56118. private _currentTeleportationControllerId;
  56119. private _floorMeshes;
  56120. private _quadraticBezierCurve;
  56121. private _selectionFeature;
  56122. private _snapToPositions;
  56123. private _snappedToPoint;
  56124. private _teleportationRingMaterial?;
  56125. private _tmpRay;
  56126. private _tmpVector;
  56127. private _tmpQuaternion;
  56128. /**
  56129. * The module's name
  56130. */
  56131. static readonly Name: string;
  56132. /**
  56133. * The (Babylon) version of this module.
  56134. * This is an integer representing the implementation version.
  56135. * This number does not correspond to the webxr specs version
  56136. */
  56137. static readonly Version: number;
  56138. /**
  56139. * Is movement backwards enabled
  56140. */
  56141. backwardsMovementEnabled: boolean;
  56142. /**
  56143. * Distance to travel when moving backwards
  56144. */
  56145. backwardsTeleportationDistance: number;
  56146. /**
  56147. * The distance from the user to the inspection point in the direction of the controller
  56148. * A higher number will allow the user to move further
  56149. * defaults to 5 (meters, in xr units)
  56150. */
  56151. parabolicCheckRadius: number;
  56152. /**
  56153. * Should the module support parabolic ray on top of direct ray
  56154. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56155. * Very helpful when moving between floors / different heights
  56156. */
  56157. parabolicRayEnabled: boolean;
  56158. /**
  56159. * The second type of ray - straight line.
  56160. * Should it be enabled or should the parabolic line be the only one.
  56161. */
  56162. straightRayEnabled: boolean;
  56163. /**
  56164. * How much rotation should be applied when rotating right and left
  56165. */
  56166. rotationAngle: number;
  56167. private _rotationEnabled;
  56168. /**
  56169. * Is rotation enabled when moving forward?
  56170. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56171. */
  56172. get rotationEnabled(): boolean;
  56173. /**
  56174. * Sets wether rotation is enabled or not
  56175. * @param enabled is rotation enabled when teleportation is shown
  56176. */
  56177. set rotationEnabled(enabled: boolean);
  56178. /**
  56179. * Exposes the currently set teleportation target mesh.
  56180. */
  56181. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56182. /**
  56183. * constructs a new anchor system
  56184. * @param _xrSessionManager an instance of WebXRSessionManager
  56185. * @param _options configuration object for this feature
  56186. */
  56187. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56188. /**
  56189. * Get the snapPointsOnly flag
  56190. */
  56191. get snapPointsOnly(): boolean;
  56192. /**
  56193. * Sets the snapPointsOnly flag
  56194. * @param snapToPoints should teleportation be exclusively to snap points
  56195. */
  56196. set snapPointsOnly(snapToPoints: boolean);
  56197. /**
  56198. * Add a new mesh to the floor meshes array
  56199. * @param mesh the mesh to use as floor mesh
  56200. */
  56201. addFloorMesh(mesh: AbstractMesh): void;
  56202. /**
  56203. * Add a new snap-to point to fix teleportation to this position
  56204. * @param newSnapPoint The new Snap-To point
  56205. */
  56206. addSnapPoint(newSnapPoint: Vector3): void;
  56207. attach(): boolean;
  56208. detach(): boolean;
  56209. dispose(): void;
  56210. /**
  56211. * Remove a mesh from the floor meshes array
  56212. * @param mesh the mesh to remove
  56213. */
  56214. removeFloorMesh(mesh: AbstractMesh): void;
  56215. /**
  56216. * Remove a mesh from the floor meshes array using its name
  56217. * @param name the mesh name to remove
  56218. */
  56219. removeFloorMeshByName(name: string): void;
  56220. /**
  56221. * 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
  56222. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56223. * @returns was the point found and removed or not
  56224. */
  56225. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56226. /**
  56227. * This function sets a selection feature that will be disabled when
  56228. * the forward ray is shown and will be reattached when hidden.
  56229. * This is used to remove the selection rays when moving.
  56230. * @param selectionFeature the feature to disable when forward movement is enabled
  56231. */
  56232. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56233. protected _onXRFrame(_xrFrame: XRFrame): void;
  56234. private _attachController;
  56235. private _createDefaultTargetMesh;
  56236. private _detachController;
  56237. private _findClosestSnapPointWithRadius;
  56238. private _setTargetMeshPosition;
  56239. private _setTargetMeshVisibility;
  56240. private _showParabolicPath;
  56241. private _teleportForward;
  56242. }
  56243. }
  56244. declare module BABYLON {
  56245. /**
  56246. * Options for the default xr helper
  56247. */
  56248. export class WebXRDefaultExperienceOptions {
  56249. /**
  56250. * Enable or disable default UI to enter XR
  56251. */
  56252. disableDefaultUI?: boolean;
  56253. /**
  56254. * Should teleportation not initialize. defaults to false.
  56255. */
  56256. disableTeleportation?: boolean;
  56257. /**
  56258. * Floor meshes that will be used for teleport
  56259. */
  56260. floorMeshes?: Array<AbstractMesh>;
  56261. /**
  56262. * If set to true, the first frame will not be used to reset position
  56263. * The first frame is mainly used when copying transformation from the old camera
  56264. * Mainly used in AR
  56265. */
  56266. ignoreNativeCameraTransformation?: boolean;
  56267. /**
  56268. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56269. */
  56270. inputOptions?: IWebXRInputOptions;
  56271. /**
  56272. * optional configuration for the output canvas
  56273. */
  56274. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56275. /**
  56276. * optional UI options. This can be used among other to change session mode and reference space type
  56277. */
  56278. uiOptions?: WebXREnterExitUIOptions;
  56279. /**
  56280. * When loading teleportation and pointer select, use stable versions instead of latest.
  56281. */
  56282. useStablePlugins?: boolean;
  56283. /**
  56284. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56285. */
  56286. renderingGroupId?: number;
  56287. /**
  56288. * A list of optional features to init the session with
  56289. * If set to true, all features we support will be added
  56290. */
  56291. optionalFeatures?: boolean | string[];
  56292. }
  56293. /**
  56294. * Default experience which provides a similar setup to the previous webVRExperience
  56295. */
  56296. export class WebXRDefaultExperience {
  56297. /**
  56298. * Base experience
  56299. */
  56300. baseExperience: WebXRExperienceHelper;
  56301. /**
  56302. * Enables ui for entering/exiting xr
  56303. */
  56304. enterExitUI: WebXREnterExitUI;
  56305. /**
  56306. * Input experience extension
  56307. */
  56308. input: WebXRInput;
  56309. /**
  56310. * Enables laser pointer and selection
  56311. */
  56312. pointerSelection: WebXRControllerPointerSelection;
  56313. /**
  56314. * Default target xr should render to
  56315. */
  56316. renderTarget: WebXRRenderTarget;
  56317. /**
  56318. * Enables teleportation
  56319. */
  56320. teleportation: WebXRMotionControllerTeleportation;
  56321. private constructor();
  56322. /**
  56323. * Creates the default xr experience
  56324. * @param scene scene
  56325. * @param options options for basic configuration
  56326. * @returns resulting WebXRDefaultExperience
  56327. */
  56328. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56329. /**
  56330. * DIsposes of the experience helper
  56331. */
  56332. dispose(): void;
  56333. }
  56334. }
  56335. declare module BABYLON {
  56336. /**
  56337. * Options to modify the vr teleportation behavior.
  56338. */
  56339. export interface VRTeleportationOptions {
  56340. /**
  56341. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56342. */
  56343. floorMeshName?: string;
  56344. /**
  56345. * A list of meshes to be used as the teleportation floor. (default: empty)
  56346. */
  56347. floorMeshes?: Mesh[];
  56348. /**
  56349. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56350. */
  56351. teleportationMode?: number;
  56352. /**
  56353. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56354. */
  56355. teleportationTime?: number;
  56356. /**
  56357. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56358. */
  56359. teleportationSpeed?: number;
  56360. /**
  56361. * The easing function used in the animation or null for Linear. (default CircleEase)
  56362. */
  56363. easingFunction?: EasingFunction;
  56364. }
  56365. /**
  56366. * Options to modify the vr experience helper's behavior.
  56367. */
  56368. export interface VRExperienceHelperOptions extends WebVROptions {
  56369. /**
  56370. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56371. */
  56372. createDeviceOrientationCamera?: boolean;
  56373. /**
  56374. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56375. */
  56376. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56377. /**
  56378. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56379. */
  56380. laserToggle?: boolean;
  56381. /**
  56382. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56383. */
  56384. floorMeshes?: Mesh[];
  56385. /**
  56386. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56387. */
  56388. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56389. /**
  56390. * Defines if WebXR should be used instead of WebVR (if available)
  56391. */
  56392. useXR?: boolean;
  56393. }
  56394. /**
  56395. * Event containing information after VR has been entered
  56396. */
  56397. export class OnAfterEnteringVRObservableEvent {
  56398. /**
  56399. * If entering vr was successful
  56400. */
  56401. success: boolean;
  56402. }
  56403. /**
  56404. * Helps to quickly add VR support to an existing scene.
  56405. * See https://doc.babylonjs.com/how_to/webvr_helper
  56406. */
  56407. export class VRExperienceHelper {
  56408. /** Options to modify the vr experience helper's behavior. */
  56409. webVROptions: VRExperienceHelperOptions;
  56410. private _scene;
  56411. private _position;
  56412. private _btnVR;
  56413. private _btnVRDisplayed;
  56414. private _webVRsupported;
  56415. private _webVRready;
  56416. private _webVRrequesting;
  56417. private _webVRpresenting;
  56418. private _hasEnteredVR;
  56419. private _fullscreenVRpresenting;
  56420. private _inputElement;
  56421. private _webVRCamera;
  56422. private _vrDeviceOrientationCamera;
  56423. private _deviceOrientationCamera;
  56424. private _existingCamera;
  56425. private _onKeyDown;
  56426. private _onVrDisplayPresentChange;
  56427. private _onVRDisplayChanged;
  56428. private _onVRRequestPresentStart;
  56429. private _onVRRequestPresentComplete;
  56430. /**
  56431. * 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)
  56432. */
  56433. enableGazeEvenWhenNoPointerLock: boolean;
  56434. /**
  56435. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56436. */
  56437. exitVROnDoubleTap: boolean;
  56438. /**
  56439. * Observable raised right before entering VR.
  56440. */
  56441. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56442. /**
  56443. * Observable raised when entering VR has completed.
  56444. */
  56445. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56446. /**
  56447. * Observable raised when exiting VR.
  56448. */
  56449. onExitingVRObservable: Observable<VRExperienceHelper>;
  56450. /**
  56451. * Observable raised when controller mesh is loaded.
  56452. */
  56453. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56454. /** Return this.onEnteringVRObservable
  56455. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56456. */
  56457. get onEnteringVR(): Observable<VRExperienceHelper>;
  56458. /** Return this.onExitingVRObservable
  56459. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56460. */
  56461. get onExitingVR(): Observable<VRExperienceHelper>;
  56462. /** Return this.onControllerMeshLoadedObservable
  56463. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56464. */
  56465. get onControllerMeshLoaded(): Observable<WebVRController>;
  56466. private _rayLength;
  56467. private _useCustomVRButton;
  56468. private _teleportationRequested;
  56469. private _teleportActive;
  56470. private _floorMeshName;
  56471. private _floorMeshesCollection;
  56472. private _teleportationMode;
  56473. private _teleportationTime;
  56474. private _teleportationSpeed;
  56475. private _teleportationEasing;
  56476. private _rotationAllowed;
  56477. private _teleportBackwardsVector;
  56478. private _teleportationTarget;
  56479. private _isDefaultTeleportationTarget;
  56480. private _postProcessMove;
  56481. private _teleportationFillColor;
  56482. private _teleportationBorderColor;
  56483. private _rotationAngle;
  56484. private _haloCenter;
  56485. private _cameraGazer;
  56486. private _padSensibilityUp;
  56487. private _padSensibilityDown;
  56488. private _leftController;
  56489. private _rightController;
  56490. private _gazeColor;
  56491. private _laserColor;
  56492. private _pickedLaserColor;
  56493. private _pickedGazeColor;
  56494. /**
  56495. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56496. */
  56497. onNewMeshSelected: Observable<AbstractMesh>;
  56498. /**
  56499. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56500. * This observable will provide the mesh and the controller used to select the mesh
  56501. */
  56502. onMeshSelectedWithController: Observable<{
  56503. mesh: AbstractMesh;
  56504. controller: WebVRController;
  56505. }>;
  56506. /**
  56507. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56508. */
  56509. onNewMeshPicked: Observable<PickingInfo>;
  56510. private _circleEase;
  56511. /**
  56512. * Observable raised before camera teleportation
  56513. */
  56514. onBeforeCameraTeleport: Observable<Vector3>;
  56515. /**
  56516. * Observable raised after camera teleportation
  56517. */
  56518. onAfterCameraTeleport: Observable<Vector3>;
  56519. /**
  56520. * Observable raised when current selected mesh gets unselected
  56521. */
  56522. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56523. private _raySelectionPredicate;
  56524. /**
  56525. * To be optionaly changed by user to define custom ray selection
  56526. */
  56527. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56528. /**
  56529. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56530. */
  56531. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56532. /**
  56533. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56534. */
  56535. teleportationEnabled: boolean;
  56536. private _defaultHeight;
  56537. private _teleportationInitialized;
  56538. private _interactionsEnabled;
  56539. private _interactionsRequested;
  56540. private _displayGaze;
  56541. private _displayLaserPointer;
  56542. /**
  56543. * The mesh used to display where the user is going to teleport.
  56544. */
  56545. get teleportationTarget(): Mesh;
  56546. /**
  56547. * Sets the mesh to be used to display where the user is going to teleport.
  56548. */
  56549. set teleportationTarget(value: Mesh);
  56550. /**
  56551. * 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
  56552. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56553. * See https://doc.babylonjs.com/resources/baking_transformations
  56554. */
  56555. get gazeTrackerMesh(): Mesh;
  56556. set gazeTrackerMesh(value: Mesh);
  56557. /**
  56558. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56559. */
  56560. updateGazeTrackerScale: boolean;
  56561. /**
  56562. * If the gaze trackers color should be updated when selecting meshes
  56563. */
  56564. updateGazeTrackerColor: boolean;
  56565. /**
  56566. * If the controller laser color should be updated when selecting meshes
  56567. */
  56568. updateControllerLaserColor: boolean;
  56569. /**
  56570. * The gaze tracking mesh corresponding to the left controller
  56571. */
  56572. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56573. /**
  56574. * The gaze tracking mesh corresponding to the right controller
  56575. */
  56576. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56577. /**
  56578. * If the ray of the gaze should be displayed.
  56579. */
  56580. get displayGaze(): boolean;
  56581. /**
  56582. * Sets if the ray of the gaze should be displayed.
  56583. */
  56584. set displayGaze(value: boolean);
  56585. /**
  56586. * If the ray of the LaserPointer should be displayed.
  56587. */
  56588. get displayLaserPointer(): boolean;
  56589. /**
  56590. * Sets if the ray of the LaserPointer should be displayed.
  56591. */
  56592. set displayLaserPointer(value: boolean);
  56593. /**
  56594. * The deviceOrientationCamera used as the camera when not in VR.
  56595. */
  56596. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56597. /**
  56598. * Based on the current WebVR support, returns the current VR camera used.
  56599. */
  56600. get currentVRCamera(): Nullable<Camera>;
  56601. /**
  56602. * The webVRCamera which is used when in VR.
  56603. */
  56604. get webVRCamera(): WebVRFreeCamera;
  56605. /**
  56606. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56607. */
  56608. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56609. /**
  56610. * The html button that is used to trigger entering into VR.
  56611. */
  56612. get vrButton(): Nullable<HTMLButtonElement>;
  56613. private get _teleportationRequestInitiated();
  56614. /**
  56615. * Defines whether or not Pointer lock should be requested when switching to
  56616. * full screen.
  56617. */
  56618. requestPointerLockOnFullScreen: boolean;
  56619. /**
  56620. * If asking to force XR, this will be populated with the default xr experience
  56621. */
  56622. xr: WebXRDefaultExperience;
  56623. /**
  56624. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56625. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56626. */
  56627. xrTestDone: boolean;
  56628. /**
  56629. * Instantiates a VRExperienceHelper.
  56630. * Helps to quickly add VR support to an existing scene.
  56631. * @param scene The scene the VRExperienceHelper belongs to.
  56632. * @param webVROptions Options to modify the vr experience helper's behavior.
  56633. */
  56634. constructor(scene: Scene,
  56635. /** Options to modify the vr experience helper's behavior. */
  56636. webVROptions?: VRExperienceHelperOptions);
  56637. private completeVRInit;
  56638. private _onDefaultMeshLoaded;
  56639. private _onResize;
  56640. private _onFullscreenChange;
  56641. /**
  56642. * Gets a value indicating if we are currently in VR mode.
  56643. */
  56644. get isInVRMode(): boolean;
  56645. private onVrDisplayPresentChange;
  56646. private onVRDisplayChanged;
  56647. private moveButtonToBottomRight;
  56648. private displayVRButton;
  56649. private updateButtonVisibility;
  56650. private _cachedAngularSensibility;
  56651. /**
  56652. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56653. * Otherwise, will use the fullscreen API.
  56654. */
  56655. enterVR(): void;
  56656. /**
  56657. * Attempt to exit VR, or fullscreen.
  56658. */
  56659. exitVR(): void;
  56660. /**
  56661. * The position of the vr experience helper.
  56662. */
  56663. get position(): Vector3;
  56664. /**
  56665. * Sets the position of the vr experience helper.
  56666. */
  56667. set position(value: Vector3);
  56668. /**
  56669. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56670. */
  56671. enableInteractions(): void;
  56672. private get _noControllerIsActive();
  56673. private beforeRender;
  56674. private _isTeleportationFloor;
  56675. /**
  56676. * Adds a floor mesh to be used for teleportation.
  56677. * @param floorMesh the mesh to be used for teleportation.
  56678. */
  56679. addFloorMesh(floorMesh: Mesh): void;
  56680. /**
  56681. * Removes a floor mesh from being used for teleportation.
  56682. * @param floorMesh the mesh to be removed.
  56683. */
  56684. removeFloorMesh(floorMesh: Mesh): void;
  56685. /**
  56686. * Enables interactions and teleportation using the VR controllers and gaze.
  56687. * @param vrTeleportationOptions options to modify teleportation behavior.
  56688. */
  56689. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56690. private _onNewGamepadConnected;
  56691. private _tryEnableInteractionOnController;
  56692. private _onNewGamepadDisconnected;
  56693. private _enableInteractionOnController;
  56694. private _checkTeleportWithRay;
  56695. private _checkRotate;
  56696. private _checkTeleportBackwards;
  56697. private _enableTeleportationOnController;
  56698. private _createTeleportationCircles;
  56699. private _displayTeleportationTarget;
  56700. private _hideTeleportationTarget;
  56701. private _rotateCamera;
  56702. private _moveTeleportationSelectorTo;
  56703. private _workingVector;
  56704. private _workingQuaternion;
  56705. private _workingMatrix;
  56706. /**
  56707. * Time Constant Teleportation Mode
  56708. */
  56709. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56710. /**
  56711. * Speed Constant Teleportation Mode
  56712. */
  56713. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56714. /**
  56715. * Teleports the users feet to the desired location
  56716. * @param location The location where the user's feet should be placed
  56717. */
  56718. teleportCamera(location: Vector3): void;
  56719. private _convertNormalToDirectionOfRay;
  56720. private _castRayAndSelectObject;
  56721. private _notifySelectedMeshUnselected;
  56722. /**
  56723. * Permanently set new colors for the laser pointer
  56724. * @param color the new laser color
  56725. * @param pickedColor the new laser color when picked mesh detected
  56726. */
  56727. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56728. /**
  56729. * Set lighting enabled / disabled on the laser pointer of both controllers
  56730. * @param enabled should the lighting be enabled on the laser pointer
  56731. */
  56732. setLaserLightingState(enabled?: boolean): void;
  56733. /**
  56734. * Permanently set new colors for the gaze pointer
  56735. * @param color the new gaze color
  56736. * @param pickedColor the new gaze color when picked mesh detected
  56737. */
  56738. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56739. /**
  56740. * Sets the color of the laser ray from the vr controllers.
  56741. * @param color new color for the ray.
  56742. */
  56743. changeLaserColor(color: Color3): void;
  56744. /**
  56745. * Sets the color of the ray from the vr headsets gaze.
  56746. * @param color new color for the ray.
  56747. */
  56748. changeGazeColor(color: Color3): void;
  56749. /**
  56750. * Exits VR and disposes of the vr experience helper
  56751. */
  56752. dispose(): void;
  56753. /**
  56754. * Gets the name of the VRExperienceHelper class
  56755. * @returns "VRExperienceHelper"
  56756. */
  56757. getClassName(): string;
  56758. }
  56759. }
  56760. declare module BABYLON {
  56761. /**
  56762. * Contains an array of blocks representing the octree
  56763. */
  56764. export interface IOctreeContainer<T> {
  56765. /**
  56766. * Blocks within the octree
  56767. */
  56768. blocks: Array<OctreeBlock<T>>;
  56769. }
  56770. /**
  56771. * Class used to store a cell in an octree
  56772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56773. */
  56774. export class OctreeBlock<T> {
  56775. /**
  56776. * Gets the content of the current block
  56777. */
  56778. entries: T[];
  56779. /**
  56780. * Gets the list of block children
  56781. */
  56782. blocks: Array<OctreeBlock<T>>;
  56783. private _depth;
  56784. private _maxDepth;
  56785. private _capacity;
  56786. private _minPoint;
  56787. private _maxPoint;
  56788. private _boundingVectors;
  56789. private _creationFunc;
  56790. /**
  56791. * Creates a new block
  56792. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56793. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56794. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56795. * @param depth defines the current depth of this block in the octree
  56796. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56797. * @param creationFunc defines a callback to call when an element is added to the block
  56798. */
  56799. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56800. /**
  56801. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56802. */
  56803. get capacity(): number;
  56804. /**
  56805. * Gets the minimum vector (in world space) of the block's bounding box
  56806. */
  56807. get minPoint(): Vector3;
  56808. /**
  56809. * Gets the maximum vector (in world space) of the block's bounding box
  56810. */
  56811. get maxPoint(): Vector3;
  56812. /**
  56813. * Add a new element to this block
  56814. * @param entry defines the element to add
  56815. */
  56816. addEntry(entry: T): void;
  56817. /**
  56818. * Remove an element from this block
  56819. * @param entry defines the element to remove
  56820. */
  56821. removeEntry(entry: T): void;
  56822. /**
  56823. * Add an array of elements to this block
  56824. * @param entries defines the array of elements to add
  56825. */
  56826. addEntries(entries: T[]): void;
  56827. /**
  56828. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56829. * @param frustumPlanes defines the frustum planes to test
  56830. * @param selection defines the array to store current content if selection is positive
  56831. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56832. */
  56833. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56834. /**
  56835. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56836. * @param sphereCenter defines the bounding sphere center
  56837. * @param sphereRadius defines the bounding sphere radius
  56838. * @param selection defines the array to store current content if selection is positive
  56839. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56840. */
  56841. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56842. /**
  56843. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56844. * @param ray defines the ray to test with
  56845. * @param selection defines the array to store current content if selection is positive
  56846. */
  56847. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56848. /**
  56849. * Subdivide the content into child blocks (this block will then be empty)
  56850. */
  56851. createInnerBlocks(): void;
  56852. /**
  56853. * @hidden
  56854. */
  56855. 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;
  56856. }
  56857. }
  56858. declare module BABYLON {
  56859. /**
  56860. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56861. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56862. */
  56863. export class Octree<T> {
  56864. /** 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.) */
  56865. maxDepth: number;
  56866. /**
  56867. * Blocks within the octree containing objects
  56868. */
  56869. blocks: Array<OctreeBlock<T>>;
  56870. /**
  56871. * Content stored in the octree
  56872. */
  56873. dynamicContent: T[];
  56874. private _maxBlockCapacity;
  56875. private _selectionContent;
  56876. private _creationFunc;
  56877. /**
  56878. * Creates a octree
  56879. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56880. * @param creationFunc function to be used to instatiate the octree
  56881. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56882. * @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.)
  56883. */
  56884. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56885. /** 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.) */
  56886. maxDepth?: number);
  56887. /**
  56888. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56889. * @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);
  56890. * @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);
  56891. * @param entries meshes to be added to the octree blocks
  56892. */
  56893. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56894. /**
  56895. * Adds a mesh to the octree
  56896. * @param entry Mesh to add to the octree
  56897. */
  56898. addMesh(entry: T): void;
  56899. /**
  56900. * Remove an element from the octree
  56901. * @param entry defines the element to remove
  56902. */
  56903. removeMesh(entry: T): void;
  56904. /**
  56905. * Selects an array of meshes within the frustum
  56906. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56907. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56908. * @returns array of meshes within the frustum
  56909. */
  56910. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56911. /**
  56912. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56913. * @param sphereCenter defines the bounding sphere center
  56914. * @param sphereRadius defines the bounding sphere radius
  56915. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56916. * @returns an array of objects that intersect the sphere
  56917. */
  56918. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56919. /**
  56920. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56921. * @param ray defines the ray to test with
  56922. * @returns array of intersected objects
  56923. */
  56924. intersectsRay(ray: Ray): SmartArray<T>;
  56925. /**
  56926. * Adds a mesh into the octree block if it intersects the block
  56927. */
  56928. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56929. /**
  56930. * Adds a submesh into the octree block if it intersects the block
  56931. */
  56932. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56933. }
  56934. }
  56935. declare module BABYLON {
  56936. interface Scene {
  56937. /**
  56938. * @hidden
  56939. * Backing Filed
  56940. */
  56941. _selectionOctree: Octree<AbstractMesh>;
  56942. /**
  56943. * Gets the octree used to boost mesh selection (picking)
  56944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56945. */
  56946. selectionOctree: Octree<AbstractMesh>;
  56947. /**
  56948. * Creates or updates the octree used to boost selection (picking)
  56949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56950. * @param maxCapacity defines the maximum capacity per leaf
  56951. * @param maxDepth defines the maximum depth of the octree
  56952. * @returns an octree of AbstractMesh
  56953. */
  56954. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56955. }
  56956. interface AbstractMesh {
  56957. /**
  56958. * @hidden
  56959. * Backing Field
  56960. */
  56961. _submeshesOctree: Octree<SubMesh>;
  56962. /**
  56963. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56964. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56965. * @param maxCapacity defines the maximum size of each block (64 by default)
  56966. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56967. * @returns the new octree
  56968. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56969. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56970. */
  56971. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56972. }
  56973. /**
  56974. * Defines the octree scene component responsible to manage any octrees
  56975. * in a given scene.
  56976. */
  56977. export class OctreeSceneComponent {
  56978. /**
  56979. * The component name help to identify the component in the list of scene components.
  56980. */
  56981. readonly name: string;
  56982. /**
  56983. * The scene the component belongs to.
  56984. */
  56985. scene: Scene;
  56986. /**
  56987. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56988. */
  56989. readonly checksIsEnabled: boolean;
  56990. /**
  56991. * Creates a new instance of the component for the given scene
  56992. * @param scene Defines the scene to register the component in
  56993. */
  56994. constructor(scene: Scene);
  56995. /**
  56996. * Registers the component in a given scene
  56997. */
  56998. register(): void;
  56999. /**
  57000. * Return the list of active meshes
  57001. * @returns the list of active meshes
  57002. */
  57003. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57004. /**
  57005. * Return the list of active sub meshes
  57006. * @param mesh The mesh to get the candidates sub meshes from
  57007. * @returns the list of active sub meshes
  57008. */
  57009. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57010. private _tempRay;
  57011. /**
  57012. * Return the list of sub meshes intersecting with a given local ray
  57013. * @param mesh defines the mesh to find the submesh for
  57014. * @param localRay defines the ray in local space
  57015. * @returns the list of intersecting sub meshes
  57016. */
  57017. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57018. /**
  57019. * Return the list of sub meshes colliding with a collider
  57020. * @param mesh defines the mesh to find the submesh for
  57021. * @param collider defines the collider to evaluate the collision against
  57022. * @returns the list of colliding sub meshes
  57023. */
  57024. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57025. /**
  57026. * Rebuilds the elements related to this component in case of
  57027. * context lost for instance.
  57028. */
  57029. rebuild(): void;
  57030. /**
  57031. * Disposes the component and the associated ressources.
  57032. */
  57033. dispose(): void;
  57034. }
  57035. }
  57036. declare module BABYLON {
  57037. /**
  57038. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57039. */
  57040. export interface GizmoAxisCache {
  57041. /** Mesh used to runder the Gizmo */
  57042. gizmoMeshes: Mesh[];
  57043. /** Mesh used to detect user interaction with Gizmo */
  57044. colliderMeshes: Mesh[];
  57045. /** Material used to inicate color of gizmo mesh */
  57046. material: StandardMaterial;
  57047. /** Material used to inicate hover state of the Gizmo */
  57048. hoverMaterial: StandardMaterial;
  57049. /** Material used to inicate disabled state of the Gizmo */
  57050. disableMaterial: StandardMaterial;
  57051. /** Used to indicate Active state of the Gizmo */
  57052. active: boolean;
  57053. }
  57054. /**
  57055. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57056. */
  57057. export class Gizmo implements IDisposable {
  57058. /** The utility layer the gizmo will be added to */
  57059. gizmoLayer: UtilityLayerRenderer;
  57060. /**
  57061. * The root mesh of the gizmo
  57062. */
  57063. _rootMesh: Mesh;
  57064. private _attachedMesh;
  57065. private _attachedNode;
  57066. /**
  57067. * Ratio for the scale of the gizmo (Default: 1)
  57068. */
  57069. protected _scaleRatio: number;
  57070. /**
  57071. * boolean updated by pointermove when a gizmo mesh is hovered
  57072. */
  57073. protected _isHovered: boolean;
  57074. /**
  57075. * Ratio for the scale of the gizmo (Default: 1)
  57076. */
  57077. set scaleRatio(value: number);
  57078. get scaleRatio(): number;
  57079. /**
  57080. * True when the mouse pointer is hovered a gizmo mesh
  57081. */
  57082. get isHovered(): boolean;
  57083. /**
  57084. * If a custom mesh has been set (Default: false)
  57085. */
  57086. protected _customMeshSet: boolean;
  57087. /**
  57088. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57089. * * When set, interactions will be enabled
  57090. */
  57091. get attachedMesh(): Nullable<AbstractMesh>;
  57092. set attachedMesh(value: Nullable<AbstractMesh>);
  57093. /**
  57094. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57095. * * When set, interactions will be enabled
  57096. */
  57097. get attachedNode(): Nullable<Node>;
  57098. set attachedNode(value: Nullable<Node>);
  57099. /**
  57100. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57101. * @param mesh The mesh to replace the default mesh of the gizmo
  57102. */
  57103. setCustomMesh(mesh: Mesh): void;
  57104. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57105. /**
  57106. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57107. */
  57108. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57109. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57110. /**
  57111. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57112. */
  57113. updateGizmoPositionToMatchAttachedMesh: boolean;
  57114. /**
  57115. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57116. */
  57117. updateScale: boolean;
  57118. protected _interactionsEnabled: boolean;
  57119. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57120. private _beforeRenderObserver;
  57121. private _tempQuaternion;
  57122. private _tempVector;
  57123. private _tempVector2;
  57124. private _tempMatrix1;
  57125. private _tempMatrix2;
  57126. private _rightHandtoLeftHandMatrix;
  57127. /**
  57128. * Creates a gizmo
  57129. * @param gizmoLayer The utility layer the gizmo will be added to
  57130. */
  57131. constructor(
  57132. /** The utility layer the gizmo will be added to */
  57133. gizmoLayer?: UtilityLayerRenderer);
  57134. /**
  57135. * Updates the gizmo to match the attached mesh's position/rotation
  57136. */
  57137. protected _update(): void;
  57138. /**
  57139. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57140. * @param value Node, TransformNode or mesh
  57141. */
  57142. protected _matrixChanged(): void;
  57143. /**
  57144. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57145. * @param gizmoLayer The utility layer the gizmo will be added to
  57146. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57147. * @returns {Observer<PointerInfo>} pointerObserver
  57148. */
  57149. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57150. /**
  57151. * Disposes of the gizmo
  57152. */
  57153. dispose(): void;
  57154. }
  57155. }
  57156. declare module BABYLON {
  57157. /**
  57158. * Single plane drag gizmo
  57159. */
  57160. export class PlaneDragGizmo extends Gizmo {
  57161. /**
  57162. * Drag behavior responsible for the gizmos dragging interactions
  57163. */
  57164. dragBehavior: PointerDragBehavior;
  57165. private _pointerObserver;
  57166. /**
  57167. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57168. */
  57169. snapDistance: number;
  57170. /**
  57171. * Event that fires each time the gizmo snaps to a new location.
  57172. * * snapDistance is the the change in distance
  57173. */
  57174. onSnapObservable: Observable<{
  57175. snapDistance: number;
  57176. }>;
  57177. private _gizmoMesh;
  57178. private _coloredMaterial;
  57179. private _hoverMaterial;
  57180. private _disableMaterial;
  57181. private _isEnabled;
  57182. private _parent;
  57183. private _dragging;
  57184. /** @hidden */
  57185. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57186. /**
  57187. * Creates a PlaneDragGizmo
  57188. * @param gizmoLayer The utility layer the gizmo will be added to
  57189. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57190. * @param color The color of the gizmo
  57191. */
  57192. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57193. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57194. /**
  57195. * If the gizmo is enabled
  57196. */
  57197. set isEnabled(value: boolean);
  57198. get isEnabled(): boolean;
  57199. /**
  57200. * Disposes of the gizmo
  57201. */
  57202. dispose(): void;
  57203. }
  57204. }
  57205. declare module BABYLON {
  57206. /**
  57207. * Single plane rotation gizmo
  57208. */
  57209. export class PlaneRotationGizmo extends Gizmo {
  57210. /**
  57211. * Drag behavior responsible for the gizmos dragging interactions
  57212. */
  57213. dragBehavior: PointerDragBehavior;
  57214. private _pointerObserver;
  57215. /**
  57216. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57217. */
  57218. snapDistance: number;
  57219. /**
  57220. * Event that fires each time the gizmo snaps to a new location.
  57221. * * snapDistance is the the change in distance
  57222. */
  57223. onSnapObservable: Observable<{
  57224. snapDistance: number;
  57225. }>;
  57226. private _isEnabled;
  57227. private _parent;
  57228. private _coloredMaterial;
  57229. private _hoverMaterial;
  57230. private _disableMaterial;
  57231. private _gizmoMesh;
  57232. private _rotationCircle;
  57233. private _dragging;
  57234. private static _CircleConstants;
  57235. /**
  57236. * Creates a PlaneRotationGizmo
  57237. * @param gizmoLayer The utility layer the gizmo will be added to
  57238. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57239. * @param color The color of the gizmo
  57240. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57241. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57242. * @param thickness display gizmo axis thickness
  57243. */
  57244. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57245. /** Create Geometry for Gizmo */
  57246. private _createGizmoMesh;
  57247. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57248. private setupRotationCircle;
  57249. private updateRotationPath;
  57250. private updateRotationCircle;
  57251. /**
  57252. * If the gizmo is enabled
  57253. */
  57254. set isEnabled(value: boolean);
  57255. get isEnabled(): boolean;
  57256. /**
  57257. * Disposes of the gizmo
  57258. */
  57259. dispose(): void;
  57260. }
  57261. }
  57262. declare module BABYLON {
  57263. /**
  57264. * Gizmo that enables rotating a mesh along 3 axis
  57265. */
  57266. export class RotationGizmo extends Gizmo {
  57267. /**
  57268. * Internal gizmo used for interactions on the x axis
  57269. */
  57270. xGizmo: PlaneRotationGizmo;
  57271. /**
  57272. * Internal gizmo used for interactions on the y axis
  57273. */
  57274. yGizmo: PlaneRotationGizmo;
  57275. /**
  57276. * Internal gizmo used for interactions on the z axis
  57277. */
  57278. zGizmo: PlaneRotationGizmo;
  57279. /** Fires an event when any of it's sub gizmos are dragged */
  57280. onDragStartObservable: Observable<unknown>;
  57281. /** Fires an event when any of it's sub gizmos are released from dragging */
  57282. onDragEndObservable: Observable<unknown>;
  57283. private _meshAttached;
  57284. private _nodeAttached;
  57285. private _observables;
  57286. /** Node Caching for quick lookup */
  57287. private _gizmoAxisCache;
  57288. get attachedMesh(): Nullable<AbstractMesh>;
  57289. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57290. get attachedNode(): Nullable<Node>;
  57291. set attachedNode(node: Nullable<Node>);
  57292. protected _checkBillboardTransform(): void;
  57293. /**
  57294. * True when the mouse pointer is hovering a gizmo mesh
  57295. */
  57296. get isHovered(): boolean;
  57297. /**
  57298. * Creates a RotationGizmo
  57299. * @param gizmoLayer The utility layer the gizmo will be added to
  57300. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57301. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57302. * @param thickness display gizmo axis thickness
  57303. */
  57304. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57305. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57306. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57307. /**
  57308. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57309. */
  57310. set snapDistance(value: number);
  57311. get snapDistance(): number;
  57312. /**
  57313. * Ratio for the scale of the gizmo (Default: 1)
  57314. */
  57315. set scaleRatio(value: number);
  57316. get scaleRatio(): number;
  57317. /**
  57318. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57319. * @param mesh Axis gizmo mesh
  57320. * @param cache Gizmo axis definition used for reactive gizmo UI
  57321. */
  57322. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57323. /**
  57324. * Disposes of the gizmo
  57325. */
  57326. dispose(): void;
  57327. /**
  57328. * CustomMeshes are not supported by this gizmo
  57329. * @param mesh The mesh to replace the default mesh of the gizmo
  57330. */
  57331. setCustomMesh(mesh: Mesh): void;
  57332. }
  57333. }
  57334. declare module BABYLON {
  57335. /**
  57336. * Class containing static functions to help procedurally build meshes
  57337. */
  57338. export class PolyhedronBuilder {
  57339. /**
  57340. * Creates a polyhedron mesh
  57341. * * 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
  57342. * * The parameter `size` (positive float, default 1) sets the polygon size
  57343. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57344. * * 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`
  57345. * * 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
  57346. * * 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)`)
  57347. * * 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
  57348. * * 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
  57349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57350. * * 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
  57351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57352. * @param name defines the name of the mesh
  57353. * @param options defines the options used to create the mesh
  57354. * @param scene defines the hosting scene
  57355. * @returns the polyhedron mesh
  57356. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57357. */
  57358. static CreatePolyhedron(name: string, options: {
  57359. type?: number;
  57360. size?: number;
  57361. sizeX?: number;
  57362. sizeY?: number;
  57363. sizeZ?: number;
  57364. custom?: any;
  57365. faceUV?: Vector4[];
  57366. faceColors?: Color4[];
  57367. flat?: boolean;
  57368. updatable?: boolean;
  57369. sideOrientation?: number;
  57370. frontUVs?: Vector4;
  57371. backUVs?: Vector4;
  57372. }, scene?: Nullable<Scene>): Mesh;
  57373. }
  57374. }
  57375. declare module BABYLON {
  57376. /**
  57377. * Class containing static functions to help procedurally build meshes
  57378. */
  57379. export class BoxBuilder {
  57380. /**
  57381. * Creates a box mesh
  57382. * * The parameter `size` sets the size (float) of each box side (default 1)
  57383. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57384. * * 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)
  57385. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57387. * * 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
  57388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57389. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57390. * @param name defines the name of the mesh
  57391. * @param options defines the options used to create the mesh
  57392. * @param scene defines the hosting scene
  57393. * @returns the box mesh
  57394. */
  57395. static CreateBox(name: string, options: {
  57396. size?: number;
  57397. width?: number;
  57398. height?: number;
  57399. depth?: number;
  57400. faceUV?: Vector4[];
  57401. faceColors?: Color4[];
  57402. sideOrientation?: number;
  57403. frontUVs?: Vector4;
  57404. backUVs?: Vector4;
  57405. wrap?: boolean;
  57406. topBaseAt?: number;
  57407. bottomBaseAt?: number;
  57408. updatable?: boolean;
  57409. }, scene?: Nullable<Scene>): Mesh;
  57410. }
  57411. }
  57412. declare module BABYLON {
  57413. /**
  57414. * Single axis scale gizmo
  57415. */
  57416. export class AxisScaleGizmo extends Gizmo {
  57417. /**
  57418. * Drag behavior responsible for the gizmos dragging interactions
  57419. */
  57420. dragBehavior: PointerDragBehavior;
  57421. private _pointerObserver;
  57422. /**
  57423. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57424. */
  57425. snapDistance: number;
  57426. /**
  57427. * Event that fires each time the gizmo snaps to a new location.
  57428. * * snapDistance is the the change in distance
  57429. */
  57430. onSnapObservable: Observable<{
  57431. snapDistance: number;
  57432. }>;
  57433. /**
  57434. * If the scaling operation should be done on all axis (default: false)
  57435. */
  57436. uniformScaling: boolean;
  57437. /**
  57438. * Custom sensitivity value for the drag strength
  57439. */
  57440. sensitivity: number;
  57441. private _isEnabled;
  57442. private _parent;
  57443. private _gizmoMesh;
  57444. private _coloredMaterial;
  57445. private _hoverMaterial;
  57446. private _disableMaterial;
  57447. private _dragging;
  57448. private _tmpVector;
  57449. private _tmpMatrix;
  57450. private _tmpMatrix2;
  57451. /**
  57452. * Creates an AxisScaleGizmo
  57453. * @param gizmoLayer The utility layer the gizmo will be added to
  57454. * @param dragAxis The axis which the gizmo will be able to scale on
  57455. * @param color The color of the gizmo
  57456. * @param thickness display gizmo axis thickness
  57457. */
  57458. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57459. /** Create Geometry for Gizmo */
  57460. private _createGizmoMesh;
  57461. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57462. /**
  57463. * If the gizmo is enabled
  57464. */
  57465. set isEnabled(value: boolean);
  57466. get isEnabled(): boolean;
  57467. /**
  57468. * Disposes of the gizmo
  57469. */
  57470. dispose(): void;
  57471. /**
  57472. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57473. * @param mesh The mesh to replace the default mesh of the gizmo
  57474. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57475. */
  57476. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57477. }
  57478. }
  57479. declare module BABYLON {
  57480. /**
  57481. * Gizmo that enables scaling a mesh along 3 axis
  57482. */
  57483. export class ScaleGizmo extends Gizmo {
  57484. /**
  57485. * Internal gizmo used for interactions on the x axis
  57486. */
  57487. xGizmo: AxisScaleGizmo;
  57488. /**
  57489. * Internal gizmo used for interactions on the y axis
  57490. */
  57491. yGizmo: AxisScaleGizmo;
  57492. /**
  57493. * Internal gizmo used for interactions on the z axis
  57494. */
  57495. zGizmo: AxisScaleGizmo;
  57496. /**
  57497. * Internal gizmo used to scale all axis equally
  57498. */
  57499. uniformScaleGizmo: AxisScaleGizmo;
  57500. private _meshAttached;
  57501. private _nodeAttached;
  57502. private _snapDistance;
  57503. private _uniformScalingMesh;
  57504. private _octahedron;
  57505. private _sensitivity;
  57506. private _coloredMaterial;
  57507. private _hoverMaterial;
  57508. private _disableMaterial;
  57509. private _observables;
  57510. /** Node Caching for quick lookup */
  57511. private _gizmoAxisCache;
  57512. /** Fires an event when any of it's sub gizmos are dragged */
  57513. onDragStartObservable: Observable<unknown>;
  57514. /** Fires an event when any of it's sub gizmos are released from dragging */
  57515. onDragEndObservable: Observable<unknown>;
  57516. get attachedMesh(): Nullable<AbstractMesh>;
  57517. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57518. get attachedNode(): Nullable<Node>;
  57519. set attachedNode(node: Nullable<Node>);
  57520. /**
  57521. * True when the mouse pointer is hovering a gizmo mesh
  57522. */
  57523. get isHovered(): boolean;
  57524. /**
  57525. * Creates a ScaleGizmo
  57526. * @param gizmoLayer The utility layer the gizmo will be added to
  57527. * @param thickness display gizmo axis thickness
  57528. */
  57529. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57530. /** Create Geometry for Gizmo */
  57531. private _createUniformScaleMesh;
  57532. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57533. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57534. /**
  57535. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57536. */
  57537. set snapDistance(value: number);
  57538. get snapDistance(): number;
  57539. /**
  57540. * Ratio for the scale of the gizmo (Default: 1)
  57541. */
  57542. set scaleRatio(value: number);
  57543. get scaleRatio(): number;
  57544. /**
  57545. * Sensitivity factor for dragging (Default: 1)
  57546. */
  57547. set sensitivity(value: number);
  57548. get sensitivity(): number;
  57549. /**
  57550. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57551. * @param mesh Axis gizmo mesh
  57552. * @param cache Gizmo axis definition used for reactive gizmo UI
  57553. */
  57554. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57555. /**
  57556. * Disposes of the gizmo
  57557. */
  57558. dispose(): void;
  57559. }
  57560. }
  57561. declare module BABYLON {
  57562. /**
  57563. * Bounding box gizmo
  57564. */
  57565. export class BoundingBoxGizmo extends Gizmo {
  57566. private _lineBoundingBox;
  57567. private _rotateSpheresParent;
  57568. private _scaleBoxesParent;
  57569. private _boundingDimensions;
  57570. private _renderObserver;
  57571. private _pointerObserver;
  57572. private _scaleDragSpeed;
  57573. private _tmpQuaternion;
  57574. private _tmpVector;
  57575. private _tmpRotationMatrix;
  57576. /**
  57577. * 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)
  57578. */
  57579. ignoreChildren: boolean;
  57580. /**
  57581. * 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)
  57582. */
  57583. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57584. /**
  57585. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57586. */
  57587. rotationSphereSize: number;
  57588. /**
  57589. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57590. */
  57591. scaleBoxSize: number;
  57592. /**
  57593. * 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)
  57594. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57595. */
  57596. fixedDragMeshScreenSize: boolean;
  57597. /**
  57598. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57599. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57600. */
  57601. fixedDragMeshBoundsSize: boolean;
  57602. /**
  57603. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57604. */
  57605. fixedDragMeshScreenSizeDistanceFactor: number;
  57606. /**
  57607. * Fired when a rotation sphere or scale box is dragged
  57608. */
  57609. onDragStartObservable: Observable<{}>;
  57610. /**
  57611. * Fired when a scale box is dragged
  57612. */
  57613. onScaleBoxDragObservable: Observable<{}>;
  57614. /**
  57615. * Fired when a scale box drag is ended
  57616. */
  57617. onScaleBoxDragEndObservable: Observable<{}>;
  57618. /**
  57619. * Fired when a rotation sphere is dragged
  57620. */
  57621. onRotationSphereDragObservable: Observable<{}>;
  57622. /**
  57623. * Fired when a rotation sphere drag is ended
  57624. */
  57625. onRotationSphereDragEndObservable: Observable<{}>;
  57626. /**
  57627. * 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)
  57628. */
  57629. scalePivot: Nullable<Vector3>;
  57630. /**
  57631. * Mesh used as a pivot to rotate the attached node
  57632. */
  57633. private _anchorMesh;
  57634. private _existingMeshScale;
  57635. private _dragMesh;
  57636. private pointerDragBehavior;
  57637. private coloredMaterial;
  57638. private hoverColoredMaterial;
  57639. /**
  57640. * Sets the color of the bounding box gizmo
  57641. * @param color the color to set
  57642. */
  57643. setColor(color: Color3): void;
  57644. /**
  57645. * Creates an BoundingBoxGizmo
  57646. * @param gizmoLayer The utility layer the gizmo will be added to
  57647. * @param color The color of the gizmo
  57648. */
  57649. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57650. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57651. private _selectNode;
  57652. /**
  57653. * Updates the bounding box information for the Gizmo
  57654. */
  57655. updateBoundingBox(): void;
  57656. private _updateRotationSpheres;
  57657. private _updateScaleBoxes;
  57658. /**
  57659. * Enables rotation on the specified axis and disables rotation on the others
  57660. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57661. */
  57662. setEnabledRotationAxis(axis: string): void;
  57663. /**
  57664. * Enables/disables scaling
  57665. * @param enable if scaling should be enabled
  57666. * @param homogeneousScaling defines if scaling should only be homogeneous
  57667. */
  57668. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57669. private _updateDummy;
  57670. /**
  57671. * Enables a pointer drag behavior on the bounding box of the gizmo
  57672. */
  57673. enableDragBehavior(): void;
  57674. /**
  57675. * Disposes of the gizmo
  57676. */
  57677. dispose(): void;
  57678. /**
  57679. * 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)
  57680. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57681. * @returns the bounding box mesh with the passed in mesh as a child
  57682. */
  57683. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57684. /**
  57685. * CustomMeshes are not supported by this gizmo
  57686. * @param mesh The mesh to replace the default mesh of the gizmo
  57687. */
  57688. setCustomMesh(mesh: Mesh): void;
  57689. }
  57690. }
  57691. declare module BABYLON {
  57692. /**
  57693. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57694. */
  57695. export class GizmoManager implements IDisposable {
  57696. private scene;
  57697. /**
  57698. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57699. */
  57700. gizmos: {
  57701. positionGizmo: Nullable<PositionGizmo>;
  57702. rotationGizmo: Nullable<RotationGizmo>;
  57703. scaleGizmo: Nullable<ScaleGizmo>;
  57704. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57705. };
  57706. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57707. clearGizmoOnEmptyPointerEvent: boolean;
  57708. /** Fires an event when the manager is attached to a mesh */
  57709. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57710. /** Fires an event when the manager is attached to a node */
  57711. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57712. private _gizmosEnabled;
  57713. private _pointerObservers;
  57714. private _attachedMesh;
  57715. private _attachedNode;
  57716. private _boundingBoxColor;
  57717. private _defaultUtilityLayer;
  57718. private _defaultKeepDepthUtilityLayer;
  57719. private _thickness;
  57720. /** Node Caching for quick lookup */
  57721. private _gizmoAxisCache;
  57722. /**
  57723. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57724. */
  57725. boundingBoxDragBehavior: SixDofDragBehavior;
  57726. /**
  57727. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57728. */
  57729. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57730. /**
  57731. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57732. */
  57733. attachableNodes: Nullable<Array<Node>>;
  57734. /**
  57735. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57736. */
  57737. usePointerToAttachGizmos: boolean;
  57738. /**
  57739. * Utility layer that the bounding box gizmo belongs to
  57740. */
  57741. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57742. /**
  57743. * Utility layer that all gizmos besides bounding box belong to
  57744. */
  57745. get utilityLayer(): UtilityLayerRenderer;
  57746. /**
  57747. * True when the mouse pointer is hovering a gizmo mesh
  57748. */
  57749. get isHovered(): boolean;
  57750. /**
  57751. * Instatiates a gizmo manager
  57752. * @param scene the scene to overlay the gizmos on top of
  57753. * @param thickness display gizmo axis thickness
  57754. * @param utilityLayer the layer where gizmos are rendered
  57755. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57756. */
  57757. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57758. /**
  57759. * Subscribes to pointer down events, for attaching and detaching mesh
  57760. * @param scene The sceme layer the observer will be added to
  57761. */
  57762. private _attachToMeshPointerObserver;
  57763. /**
  57764. * Attaches a set of gizmos to the specified mesh
  57765. * @param mesh The mesh the gizmo's should be attached to
  57766. */
  57767. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57768. /**
  57769. * Attaches a set of gizmos to the specified node
  57770. * @param node The node the gizmo's should be attached to
  57771. */
  57772. attachToNode(node: Nullable<Node>): void;
  57773. /**
  57774. * If the position gizmo is enabled
  57775. */
  57776. set positionGizmoEnabled(value: boolean);
  57777. get positionGizmoEnabled(): boolean;
  57778. /**
  57779. * If the rotation gizmo is enabled
  57780. */
  57781. set rotationGizmoEnabled(value: boolean);
  57782. get rotationGizmoEnabled(): boolean;
  57783. /**
  57784. * If the scale gizmo is enabled
  57785. */
  57786. set scaleGizmoEnabled(value: boolean);
  57787. get scaleGizmoEnabled(): boolean;
  57788. /**
  57789. * If the boundingBox gizmo is enabled
  57790. */
  57791. set boundingBoxGizmoEnabled(value: boolean);
  57792. get boundingBoxGizmoEnabled(): boolean;
  57793. /**
  57794. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57795. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57796. */
  57797. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57798. /**
  57799. * Disposes of the gizmo manager
  57800. */
  57801. dispose(): void;
  57802. }
  57803. }
  57804. declare module BABYLON {
  57805. /**
  57806. * Gizmo that enables dragging a mesh along 3 axis
  57807. */
  57808. export class PositionGizmo extends Gizmo {
  57809. /**
  57810. * Internal gizmo used for interactions on the x axis
  57811. */
  57812. xGizmo: AxisDragGizmo;
  57813. /**
  57814. * Internal gizmo used for interactions on the y axis
  57815. */
  57816. yGizmo: AxisDragGizmo;
  57817. /**
  57818. * Internal gizmo used for interactions on the z axis
  57819. */
  57820. zGizmo: AxisDragGizmo;
  57821. /**
  57822. * Internal gizmo used for interactions on the yz plane
  57823. */
  57824. xPlaneGizmo: PlaneDragGizmo;
  57825. /**
  57826. * Internal gizmo used for interactions on the xz plane
  57827. */
  57828. yPlaneGizmo: PlaneDragGizmo;
  57829. /**
  57830. * Internal gizmo used for interactions on the xy plane
  57831. */
  57832. zPlaneGizmo: PlaneDragGizmo;
  57833. /**
  57834. * private variables
  57835. */
  57836. private _meshAttached;
  57837. private _nodeAttached;
  57838. private _snapDistance;
  57839. private _observables;
  57840. /** Node Caching for quick lookup */
  57841. private _gizmoAxisCache;
  57842. /** Fires an event when any of it's sub gizmos are dragged */
  57843. onDragStartObservable: Observable<unknown>;
  57844. /** Fires an event when any of it's sub gizmos are released from dragging */
  57845. onDragEndObservable: Observable<unknown>;
  57846. /**
  57847. * If set to true, planar drag is enabled
  57848. */
  57849. private _planarGizmoEnabled;
  57850. get attachedMesh(): Nullable<AbstractMesh>;
  57851. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57852. get attachedNode(): Nullable<Node>;
  57853. set attachedNode(node: Nullable<Node>);
  57854. /**
  57855. * True when the mouse pointer is hovering a gizmo mesh
  57856. */
  57857. get isHovered(): boolean;
  57858. /**
  57859. * Creates a PositionGizmo
  57860. * @param gizmoLayer The utility layer the gizmo will be added to
  57861. @param thickness display gizmo axis thickness
  57862. */
  57863. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57864. /**
  57865. * If the planar drag gizmo is enabled
  57866. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57867. */
  57868. set planarGizmoEnabled(value: boolean);
  57869. get planarGizmoEnabled(): boolean;
  57870. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57871. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57872. /**
  57873. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57874. */
  57875. set snapDistance(value: number);
  57876. get snapDistance(): number;
  57877. /**
  57878. * Ratio for the scale of the gizmo (Default: 1)
  57879. */
  57880. set scaleRatio(value: number);
  57881. get scaleRatio(): number;
  57882. /**
  57883. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57884. * @param mesh Axis gizmo mesh
  57885. * @param cache Gizmo axis definition used for reactive gizmo UI
  57886. */
  57887. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57888. /**
  57889. * Disposes of the gizmo
  57890. */
  57891. dispose(): void;
  57892. /**
  57893. * CustomMeshes are not supported by this gizmo
  57894. * @param mesh The mesh to replace the default mesh of the gizmo
  57895. */
  57896. setCustomMesh(mesh: Mesh): void;
  57897. }
  57898. }
  57899. declare module BABYLON {
  57900. /**
  57901. * Single axis drag gizmo
  57902. */
  57903. export class AxisDragGizmo extends Gizmo {
  57904. /**
  57905. * Drag behavior responsible for the gizmos dragging interactions
  57906. */
  57907. dragBehavior: PointerDragBehavior;
  57908. private _pointerObserver;
  57909. /**
  57910. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57911. */
  57912. snapDistance: number;
  57913. /**
  57914. * Event that fires each time the gizmo snaps to a new location.
  57915. * * snapDistance is the the change in distance
  57916. */
  57917. onSnapObservable: Observable<{
  57918. snapDistance: number;
  57919. }>;
  57920. private _isEnabled;
  57921. private _parent;
  57922. private _gizmoMesh;
  57923. private _coloredMaterial;
  57924. private _hoverMaterial;
  57925. private _disableMaterial;
  57926. private _dragging;
  57927. /** @hidden */
  57928. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57929. /** @hidden */
  57930. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57931. /**
  57932. * Creates an AxisDragGizmo
  57933. * @param gizmoLayer The utility layer the gizmo will be added to
  57934. * @param dragAxis The axis which the gizmo will be able to drag on
  57935. * @param color The color of the gizmo
  57936. * @param thickness display gizmo axis thickness
  57937. */
  57938. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57939. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57940. /**
  57941. * If the gizmo is enabled
  57942. */
  57943. set isEnabled(value: boolean);
  57944. get isEnabled(): boolean;
  57945. /**
  57946. * Disposes of the gizmo
  57947. */
  57948. dispose(): void;
  57949. }
  57950. }
  57951. declare module BABYLON.Debug {
  57952. /**
  57953. * The Axes viewer will show 3 axes in a specific point in space
  57954. */
  57955. export class AxesViewer {
  57956. private _xAxis;
  57957. private _yAxis;
  57958. private _zAxis;
  57959. private _scaleLinesFactor;
  57960. private _instanced;
  57961. /**
  57962. * Gets the hosting scene
  57963. */
  57964. scene: Nullable<Scene>;
  57965. /**
  57966. * Gets or sets a number used to scale line length
  57967. */
  57968. scaleLines: number;
  57969. /** Gets the node hierarchy used to render x-axis */
  57970. get xAxis(): TransformNode;
  57971. /** Gets the node hierarchy used to render y-axis */
  57972. get yAxis(): TransformNode;
  57973. /** Gets the node hierarchy used to render z-axis */
  57974. get zAxis(): TransformNode;
  57975. /**
  57976. * Creates a new AxesViewer
  57977. * @param scene defines the hosting scene
  57978. * @param scaleLines defines a number used to scale line length (1 by default)
  57979. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57980. * @param xAxis defines the node hierarchy used to render the x-axis
  57981. * @param yAxis defines the node hierarchy used to render the y-axis
  57982. * @param zAxis defines the node hierarchy used to render the z-axis
  57983. */
  57984. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57985. /**
  57986. * Force the viewer to update
  57987. * @param position defines the position of the viewer
  57988. * @param xaxis defines the x axis of the viewer
  57989. * @param yaxis defines the y axis of the viewer
  57990. * @param zaxis defines the z axis of the viewer
  57991. */
  57992. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57993. /**
  57994. * Creates an instance of this axes viewer.
  57995. * @returns a new axes viewer with instanced meshes
  57996. */
  57997. createInstance(): AxesViewer;
  57998. /** Releases resources */
  57999. dispose(): void;
  58000. private static _SetRenderingGroupId;
  58001. }
  58002. }
  58003. declare module BABYLON.Debug {
  58004. /**
  58005. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58006. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58007. */
  58008. export class BoneAxesViewer extends AxesViewer {
  58009. /**
  58010. * Gets or sets the target mesh where to display the axes viewer
  58011. */
  58012. mesh: Nullable<Mesh>;
  58013. /**
  58014. * Gets or sets the target bone where to display the axes viewer
  58015. */
  58016. bone: Nullable<Bone>;
  58017. /** Gets current position */
  58018. pos: Vector3;
  58019. /** Gets direction of X axis */
  58020. xaxis: Vector3;
  58021. /** Gets direction of Y axis */
  58022. yaxis: Vector3;
  58023. /** Gets direction of Z axis */
  58024. zaxis: Vector3;
  58025. /**
  58026. * Creates a new BoneAxesViewer
  58027. * @param scene defines the hosting scene
  58028. * @param bone defines the target bone
  58029. * @param mesh defines the target mesh
  58030. * @param scaleLines defines a scaling factor for line length (1 by default)
  58031. */
  58032. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58033. /**
  58034. * Force the viewer to update
  58035. */
  58036. update(): void;
  58037. /** Releases resources */
  58038. dispose(): void;
  58039. }
  58040. }
  58041. declare module BABYLON {
  58042. /**
  58043. * Interface used to define scene explorer extensibility option
  58044. */
  58045. export interface IExplorerExtensibilityOption {
  58046. /**
  58047. * Define the option label
  58048. */
  58049. label: string;
  58050. /**
  58051. * Defines the action to execute on click
  58052. */
  58053. action: (entity: any) => void;
  58054. }
  58055. /**
  58056. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58057. */
  58058. export interface IExplorerExtensibilityGroup {
  58059. /**
  58060. * Defines a predicate to test if a given type mut be extended
  58061. */
  58062. predicate: (entity: any) => boolean;
  58063. /**
  58064. * Gets the list of options added to a type
  58065. */
  58066. entries: IExplorerExtensibilityOption[];
  58067. }
  58068. /**
  58069. * Interface used to define the options to use to create the Inspector
  58070. */
  58071. export interface IInspectorOptions {
  58072. /**
  58073. * Display in overlay mode (default: false)
  58074. */
  58075. overlay?: boolean;
  58076. /**
  58077. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58078. */
  58079. globalRoot?: HTMLElement;
  58080. /**
  58081. * Display the Scene explorer
  58082. */
  58083. showExplorer?: boolean;
  58084. /**
  58085. * Display the property inspector
  58086. */
  58087. showInspector?: boolean;
  58088. /**
  58089. * Display in embed mode (both panes on the right)
  58090. */
  58091. embedMode?: boolean;
  58092. /**
  58093. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58094. */
  58095. handleResize?: boolean;
  58096. /**
  58097. * Allow the panes to popup (default: true)
  58098. */
  58099. enablePopup?: boolean;
  58100. /**
  58101. * Allow the panes to be closed by users (default: true)
  58102. */
  58103. enableClose?: boolean;
  58104. /**
  58105. * Optional list of extensibility entries
  58106. */
  58107. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58108. /**
  58109. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58110. */
  58111. inspectorURL?: string;
  58112. /**
  58113. * Optional initial tab (default to DebugLayerTab.Properties)
  58114. */
  58115. initialTab?: DebugLayerTab;
  58116. }
  58117. interface Scene {
  58118. /**
  58119. * @hidden
  58120. * Backing field
  58121. */
  58122. _debugLayer: DebugLayer;
  58123. /**
  58124. * Gets the debug layer (aka Inspector) associated with the scene
  58125. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58126. */
  58127. debugLayer: DebugLayer;
  58128. }
  58129. /**
  58130. * Enum of inspector action tab
  58131. */
  58132. export enum DebugLayerTab {
  58133. /**
  58134. * Properties tag (default)
  58135. */
  58136. Properties = 0,
  58137. /**
  58138. * Debug tab
  58139. */
  58140. Debug = 1,
  58141. /**
  58142. * Statistics tab
  58143. */
  58144. Statistics = 2,
  58145. /**
  58146. * Tools tab
  58147. */
  58148. Tools = 3,
  58149. /**
  58150. * Settings tab
  58151. */
  58152. Settings = 4
  58153. }
  58154. /**
  58155. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58156. * what is happening in your scene
  58157. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58158. */
  58159. export class DebugLayer {
  58160. /**
  58161. * Define the url to get the inspector script from.
  58162. * By default it uses the babylonjs CDN.
  58163. * @ignoreNaming
  58164. */
  58165. static InspectorURL: string;
  58166. private _scene;
  58167. private BJSINSPECTOR;
  58168. private _onPropertyChangedObservable?;
  58169. /**
  58170. * Observable triggered when a property is changed through the inspector.
  58171. */
  58172. get onPropertyChangedObservable(): any;
  58173. /**
  58174. * Instantiates a new debug layer.
  58175. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58176. * what is happening in your scene
  58177. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58178. * @param scene Defines the scene to inspect
  58179. */
  58180. constructor(scene: Scene);
  58181. /** Creates the inspector window. */
  58182. private _createInspector;
  58183. /**
  58184. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58185. * @param entity defines the entity to select
  58186. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58187. */
  58188. select(entity: any, lineContainerTitles?: string | string[]): void;
  58189. /** Get the inspector from bundle or global */
  58190. private _getGlobalInspector;
  58191. /**
  58192. * Get if the inspector is visible or not.
  58193. * @returns true if visible otherwise, false
  58194. */
  58195. isVisible(): boolean;
  58196. /**
  58197. * Hide the inspector and close its window.
  58198. */
  58199. hide(): void;
  58200. /**
  58201. * Update the scene in the inspector
  58202. */
  58203. setAsActiveScene(): void;
  58204. /**
  58205. * Launch the debugLayer.
  58206. * @param config Define the configuration of the inspector
  58207. * @return a promise fulfilled when the debug layer is visible
  58208. */
  58209. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58210. }
  58211. }
  58212. declare module BABYLON.Debug {
  58213. /**
  58214. * Used to show the physics impostor around the specific mesh
  58215. */
  58216. export class PhysicsViewer {
  58217. /** @hidden */
  58218. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58219. /** @hidden */
  58220. protected _meshes: Array<Nullable<AbstractMesh>>;
  58221. /** @hidden */
  58222. protected _scene: Nullable<Scene>;
  58223. /** @hidden */
  58224. protected _numMeshes: number;
  58225. /** @hidden */
  58226. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58227. private _renderFunction;
  58228. private _utilityLayer;
  58229. private _debugBoxMesh;
  58230. private _debugSphereMesh;
  58231. private _debugCylinderMesh;
  58232. private _debugMaterial;
  58233. private _debugMeshMeshes;
  58234. /**
  58235. * Creates a new PhysicsViewer
  58236. * @param scene defines the hosting scene
  58237. */
  58238. constructor(scene: Scene);
  58239. /** @hidden */
  58240. protected _updateDebugMeshes(): void;
  58241. /**
  58242. * Renders a specified physic impostor
  58243. * @param impostor defines the impostor to render
  58244. * @param targetMesh defines the mesh represented by the impostor
  58245. * @returns the new debug mesh used to render the impostor
  58246. */
  58247. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58248. /**
  58249. * Hides a specified physic impostor
  58250. * @param impostor defines the impostor to hide
  58251. */
  58252. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58253. private _getDebugMaterial;
  58254. private _getDebugBoxMesh;
  58255. private _getDebugSphereMesh;
  58256. private _getDebugCylinderMesh;
  58257. private _getDebugMeshMesh;
  58258. private _getDebugMesh;
  58259. /** Releases all resources */
  58260. dispose(): void;
  58261. }
  58262. }
  58263. declare module BABYLON {
  58264. /**
  58265. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58266. * in order to better appreciate the issue one might have.
  58267. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58268. */
  58269. export class RayHelper {
  58270. /**
  58271. * Defines the ray we are currently tryin to visualize.
  58272. */
  58273. ray: Nullable<Ray>;
  58274. private _renderPoints;
  58275. private _renderLine;
  58276. private _renderFunction;
  58277. private _scene;
  58278. private _onAfterRenderObserver;
  58279. private _onAfterStepObserver;
  58280. private _attachedToMesh;
  58281. private _meshSpaceDirection;
  58282. private _meshSpaceOrigin;
  58283. /**
  58284. * Helper function to create a colored helper in a scene in one line.
  58285. * @param ray Defines the ray we are currently tryin to visualize
  58286. * @param scene Defines the scene the ray is used in
  58287. * @param color Defines the color we want to see the ray in
  58288. * @returns The newly created ray helper.
  58289. */
  58290. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58291. /**
  58292. * Instantiate a new ray helper.
  58293. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58294. * in order to better appreciate the issue one might have.
  58295. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58296. * @param ray Defines the ray we are currently tryin to visualize
  58297. */
  58298. constructor(ray: Ray);
  58299. /**
  58300. * Shows the ray we are willing to debug.
  58301. * @param scene Defines the scene the ray needs to be rendered in
  58302. * @param color Defines the color the ray needs to be rendered in
  58303. */
  58304. show(scene: Scene, color?: Color3): void;
  58305. /**
  58306. * Hides the ray we are debugging.
  58307. */
  58308. hide(): void;
  58309. private _render;
  58310. /**
  58311. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58312. * @param mesh Defines the mesh we want the helper attached to
  58313. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58314. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58315. * @param length Defines the length of the ray
  58316. */
  58317. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58318. /**
  58319. * Detach the ray helper from the mesh it has previously been attached to.
  58320. */
  58321. detachFromMesh(): void;
  58322. private _updateToMesh;
  58323. /**
  58324. * Dispose the helper and release its associated resources.
  58325. */
  58326. dispose(): void;
  58327. }
  58328. }
  58329. declare module BABYLON {
  58330. /**
  58331. * Defines the options associated with the creation of a SkeletonViewer.
  58332. */
  58333. export interface ISkeletonViewerOptions {
  58334. /** Should the system pause animations before building the Viewer? */
  58335. pauseAnimations: boolean;
  58336. /** Should the system return the skeleton to rest before building? */
  58337. returnToRest: boolean;
  58338. /** public Display Mode of the Viewer */
  58339. displayMode: number;
  58340. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58341. displayOptions: ISkeletonViewerDisplayOptions;
  58342. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58343. computeBonesUsingShaders: boolean;
  58344. /** Flag ignore non weighted bones */
  58345. useAllBones: boolean;
  58346. }
  58347. /**
  58348. * Defines how to display the various bone meshes for the viewer.
  58349. */
  58350. export interface ISkeletonViewerDisplayOptions {
  58351. /** How far down to start tapering the bone spurs */
  58352. midStep?: number;
  58353. /** How big is the midStep? */
  58354. midStepFactor?: number;
  58355. /** Base for the Sphere Size */
  58356. sphereBaseSize?: number;
  58357. /** The ratio of the sphere to the longest bone in units */
  58358. sphereScaleUnit?: number;
  58359. /** Ratio for the Sphere Size */
  58360. sphereFactor?: number;
  58361. /** Whether a spur should attach its far end to the child bone position */
  58362. spurFollowsChild?: boolean;
  58363. /** Whether to show local axes or not */
  58364. showLocalAxes?: boolean;
  58365. /** Length of each local axis */
  58366. localAxesSize?: number;
  58367. }
  58368. /**
  58369. * Defines the constructor options for the BoneWeight Shader.
  58370. */
  58371. export interface IBoneWeightShaderOptions {
  58372. /** Skeleton to Map */
  58373. skeleton: Skeleton;
  58374. /** Colors for Uninfluenced bones */
  58375. colorBase?: Color3;
  58376. /** Colors for 0.0-0.25 Weight bones */
  58377. colorZero?: Color3;
  58378. /** Color for 0.25-0.5 Weight Influence */
  58379. colorQuarter?: Color3;
  58380. /** Color for 0.5-0.75 Weight Influence */
  58381. colorHalf?: Color3;
  58382. /** Color for 0.75-1 Weight Influence */
  58383. colorFull?: Color3;
  58384. /** Color for Zero Weight Influence */
  58385. targetBoneIndex?: number;
  58386. }
  58387. /**
  58388. * Simple structure of the gradient steps for the Color Map.
  58389. */
  58390. export interface ISkeletonMapShaderColorMapKnot {
  58391. /** Color of the Knot */
  58392. color: Color3;
  58393. /** Location of the Knot */
  58394. location: number;
  58395. }
  58396. /**
  58397. * Defines the constructor options for the SkeletonMap Shader.
  58398. */
  58399. export interface ISkeletonMapShaderOptions {
  58400. /** Skeleton to Map */
  58401. skeleton: Skeleton;
  58402. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58403. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58404. }
  58405. }
  58406. declare module BABYLON {
  58407. /**
  58408. * Class containing static functions to help procedurally build meshes
  58409. */
  58410. export class RibbonBuilder {
  58411. /**
  58412. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58413. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58414. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58415. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58416. * * 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
  58417. * * 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
  58418. * * 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
  58419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58420. * * 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
  58421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58422. * * 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
  58423. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58424. * * 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
  58425. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58427. * @param name defines the name of the mesh
  58428. * @param options defines the options used to create the mesh
  58429. * @param scene defines the hosting scene
  58430. * @returns the ribbon mesh
  58431. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58432. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58433. */
  58434. static CreateRibbon(name: string, options: {
  58435. pathArray: Vector3[][];
  58436. closeArray?: boolean;
  58437. closePath?: boolean;
  58438. offset?: number;
  58439. updatable?: boolean;
  58440. sideOrientation?: number;
  58441. frontUVs?: Vector4;
  58442. backUVs?: Vector4;
  58443. instance?: Mesh;
  58444. invertUV?: boolean;
  58445. uvs?: Vector2[];
  58446. colors?: Color4[];
  58447. }, scene?: Nullable<Scene>): Mesh;
  58448. }
  58449. }
  58450. declare module BABYLON {
  58451. /**
  58452. * Class containing static functions to help procedurally build meshes
  58453. */
  58454. export class ShapeBuilder {
  58455. /**
  58456. * 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.
  58457. * * 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.
  58458. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58459. * * 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.
  58460. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58461. * * 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
  58462. * * 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
  58463. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58465. * * 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
  58466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58468. * @param name defines the name of the mesh
  58469. * @param options defines the options used to create the mesh
  58470. * @param scene defines the hosting scene
  58471. * @returns the extruded shape mesh
  58472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58474. */
  58475. static ExtrudeShape(name: string, options: {
  58476. shape: Vector3[];
  58477. path: Vector3[];
  58478. scale?: number;
  58479. rotation?: number;
  58480. cap?: number;
  58481. updatable?: boolean;
  58482. sideOrientation?: number;
  58483. frontUVs?: Vector4;
  58484. backUVs?: Vector4;
  58485. instance?: Mesh;
  58486. invertUV?: boolean;
  58487. }, scene?: Nullable<Scene>): Mesh;
  58488. /**
  58489. * Creates an custom extruded shape mesh.
  58490. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58491. * * 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.
  58492. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58493. * * 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
  58494. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58495. * * 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
  58496. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58497. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58498. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58499. * * 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
  58500. * * 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
  58501. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58503. * * 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
  58504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58506. * @param name defines the name of the mesh
  58507. * @param options defines the options used to create the mesh
  58508. * @param scene defines the hosting scene
  58509. * @returns the custom extruded shape mesh
  58510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58513. */
  58514. static ExtrudeShapeCustom(name: string, options: {
  58515. shape: Vector3[];
  58516. path: Vector3[];
  58517. scaleFunction?: any;
  58518. rotationFunction?: any;
  58519. ribbonCloseArray?: boolean;
  58520. ribbonClosePath?: boolean;
  58521. cap?: number;
  58522. updatable?: boolean;
  58523. sideOrientation?: number;
  58524. frontUVs?: Vector4;
  58525. backUVs?: Vector4;
  58526. instance?: Mesh;
  58527. invertUV?: boolean;
  58528. }, scene?: Nullable<Scene>): Mesh;
  58529. private static _ExtrudeShapeGeneric;
  58530. }
  58531. }
  58532. declare module BABYLON.Debug {
  58533. /**
  58534. * Class used to render a debug view of a given skeleton
  58535. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58536. */
  58537. export class SkeletonViewer {
  58538. /** defines the skeleton to render */
  58539. skeleton: Skeleton;
  58540. /** defines the mesh attached to the skeleton */
  58541. mesh: AbstractMesh;
  58542. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58543. autoUpdateBonesMatrices: boolean;
  58544. /** defines the rendering group id to use with the viewer */
  58545. renderingGroupId: number;
  58546. /** is the options for the viewer */
  58547. options: Partial<ISkeletonViewerOptions>;
  58548. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58549. static readonly DISPLAY_LINES: number;
  58550. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58551. static readonly DISPLAY_SPHERES: number;
  58552. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58553. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58554. /** public static method to create a BoneWeight Shader
  58555. * @param options The constructor options
  58556. * @param scene The scene that the shader is scoped to
  58557. * @returns The created ShaderMaterial
  58558. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58559. */
  58560. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58561. /** public static method to create a BoneWeight Shader
  58562. * @param options The constructor options
  58563. * @param scene The scene that the shader is scoped to
  58564. * @returns The created ShaderMaterial
  58565. */
  58566. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58567. /** private static method to create a BoneWeight Shader
  58568. * @param size The size of the buffer to create (usually the bone count)
  58569. * @param colorMap The gradient data to generate
  58570. * @param scene The scene that the shader is scoped to
  58571. * @returns an Array of floats from the color gradient values
  58572. */
  58573. private static _CreateBoneMapColorBuffer;
  58574. /** If SkeletonViewer scene scope. */
  58575. private _scene;
  58576. /** Gets or sets the color used to render the skeleton */
  58577. color: Color3;
  58578. /** Array of the points of the skeleton fo the line view. */
  58579. private _debugLines;
  58580. /** The SkeletonViewers Mesh. */
  58581. private _debugMesh;
  58582. /** The local axes Meshes. */
  58583. private _localAxes;
  58584. /** If SkeletonViewer is enabled. */
  58585. private _isEnabled;
  58586. /** If SkeletonViewer is ready. */
  58587. private _ready;
  58588. /** SkeletonViewer render observable. */
  58589. private _obs;
  58590. /** The Utility Layer to render the gizmos in. */
  58591. private _utilityLayer;
  58592. private _boneIndices;
  58593. /** Gets the Scene. */
  58594. get scene(): Scene;
  58595. /** Gets the utilityLayer. */
  58596. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58597. /** Checks Ready Status. */
  58598. get isReady(): Boolean;
  58599. /** Sets Ready Status. */
  58600. set ready(value: boolean);
  58601. /** Gets the debugMesh */
  58602. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58603. /** Sets the debugMesh */
  58604. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58605. /** Gets the displayMode */
  58606. get displayMode(): number;
  58607. /** Sets the displayMode */
  58608. set displayMode(value: number);
  58609. /**
  58610. * Creates a new SkeletonViewer
  58611. * @param skeleton defines the skeleton to render
  58612. * @param mesh defines the mesh attached to the skeleton
  58613. * @param scene defines the hosting scene
  58614. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58615. * @param renderingGroupId defines the rendering group id to use with the viewer
  58616. * @param options All of the extra constructor options for the SkeletonViewer
  58617. */
  58618. constructor(
  58619. /** defines the skeleton to render */
  58620. skeleton: Skeleton,
  58621. /** defines the mesh attached to the skeleton */
  58622. mesh: AbstractMesh,
  58623. /** The Scene scope*/
  58624. scene: Scene,
  58625. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58626. autoUpdateBonesMatrices?: boolean,
  58627. /** defines the rendering group id to use with the viewer */
  58628. renderingGroupId?: number,
  58629. /** is the options for the viewer */
  58630. options?: Partial<ISkeletonViewerOptions>);
  58631. /** The Dynamic bindings for the update functions */
  58632. private _bindObs;
  58633. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58634. update(): void;
  58635. /** Gets or sets a boolean indicating if the viewer is enabled */
  58636. set isEnabled(value: boolean);
  58637. get isEnabled(): boolean;
  58638. private _getBonePosition;
  58639. private _getLinesForBonesWithLength;
  58640. private _getLinesForBonesNoLength;
  58641. /** function to revert the mesh and scene back to the initial state. */
  58642. private _revert;
  58643. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58644. private _getAbsoluteBindPoseToRef;
  58645. /** function to build and bind sphere joint points and spur bone representations. */
  58646. private _buildSpheresAndSpurs;
  58647. private _buildLocalAxes;
  58648. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58649. private _displayLinesUpdate;
  58650. /** Changes the displayMode of the skeleton viewer
  58651. * @param mode The displayMode numerical value
  58652. */
  58653. changeDisplayMode(mode: number): void;
  58654. /** Sets a display option of the skeleton viewer
  58655. *
  58656. * | Option | Type | Default | Description |
  58657. * | ---------------- | ------- | ------- | ----------- |
  58658. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58659. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58660. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58661. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58662. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58663. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58664. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58665. *
  58666. * @param option String of the option name
  58667. * @param value The numerical option value
  58668. */
  58669. changeDisplayOptions(option: string, value: number): void;
  58670. /** Release associated resources */
  58671. dispose(): void;
  58672. }
  58673. }
  58674. declare module BABYLON {
  58675. /**
  58676. * Enum for Device Types
  58677. */
  58678. export enum DeviceType {
  58679. /** Generic */
  58680. Generic = 0,
  58681. /** Keyboard */
  58682. Keyboard = 1,
  58683. /** Mouse */
  58684. Mouse = 2,
  58685. /** Touch Pointers */
  58686. Touch = 3,
  58687. /** PS4 Dual Shock */
  58688. DualShock = 4,
  58689. /** Xbox */
  58690. Xbox = 5,
  58691. /** Switch Controller */
  58692. Switch = 6
  58693. }
  58694. /**
  58695. * Enum for All Pointers (Touch/Mouse)
  58696. */
  58697. export enum PointerInput {
  58698. /** Horizontal Axis */
  58699. Horizontal = 0,
  58700. /** Vertical Axis */
  58701. Vertical = 1,
  58702. /** Left Click or Touch */
  58703. LeftClick = 2,
  58704. /** Middle Click */
  58705. MiddleClick = 3,
  58706. /** Right Click */
  58707. RightClick = 4,
  58708. /** Browser Back */
  58709. BrowserBack = 5,
  58710. /** Browser Forward */
  58711. BrowserForward = 6
  58712. }
  58713. /**
  58714. * Enum for Dual Shock Gamepad
  58715. */
  58716. export enum DualShockInput {
  58717. /** Cross */
  58718. Cross = 0,
  58719. /** Circle */
  58720. Circle = 1,
  58721. /** Square */
  58722. Square = 2,
  58723. /** Triangle */
  58724. Triangle = 3,
  58725. /** L1 */
  58726. L1 = 4,
  58727. /** R1 */
  58728. R1 = 5,
  58729. /** L2 */
  58730. L2 = 6,
  58731. /** R2 */
  58732. R2 = 7,
  58733. /** Share */
  58734. Share = 8,
  58735. /** Options */
  58736. Options = 9,
  58737. /** L3 */
  58738. L3 = 10,
  58739. /** R3 */
  58740. R3 = 11,
  58741. /** DPadUp */
  58742. DPadUp = 12,
  58743. /** DPadDown */
  58744. DPadDown = 13,
  58745. /** DPadLeft */
  58746. DPadLeft = 14,
  58747. /** DRight */
  58748. DPadRight = 15,
  58749. /** Home */
  58750. Home = 16,
  58751. /** TouchPad */
  58752. TouchPad = 17,
  58753. /** LStickXAxis */
  58754. LStickXAxis = 18,
  58755. /** LStickYAxis */
  58756. LStickYAxis = 19,
  58757. /** RStickXAxis */
  58758. RStickXAxis = 20,
  58759. /** RStickYAxis */
  58760. RStickYAxis = 21
  58761. }
  58762. /**
  58763. * Enum for Xbox Gamepad
  58764. */
  58765. export enum XboxInput {
  58766. /** A */
  58767. A = 0,
  58768. /** B */
  58769. B = 1,
  58770. /** X */
  58771. X = 2,
  58772. /** Y */
  58773. Y = 3,
  58774. /** LB */
  58775. LB = 4,
  58776. /** RB */
  58777. RB = 5,
  58778. /** LT */
  58779. LT = 6,
  58780. /** RT */
  58781. RT = 7,
  58782. /** Back */
  58783. Back = 8,
  58784. /** Start */
  58785. Start = 9,
  58786. /** LS */
  58787. LS = 10,
  58788. /** RS */
  58789. RS = 11,
  58790. /** DPadUp */
  58791. DPadUp = 12,
  58792. /** DPadDown */
  58793. DPadDown = 13,
  58794. /** DPadLeft */
  58795. DPadLeft = 14,
  58796. /** DRight */
  58797. DPadRight = 15,
  58798. /** Home */
  58799. Home = 16,
  58800. /** LStickXAxis */
  58801. LStickXAxis = 17,
  58802. /** LStickYAxis */
  58803. LStickYAxis = 18,
  58804. /** RStickXAxis */
  58805. RStickXAxis = 19,
  58806. /** RStickYAxis */
  58807. RStickYAxis = 20
  58808. }
  58809. /**
  58810. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58811. */
  58812. export enum SwitchInput {
  58813. /** B */
  58814. B = 0,
  58815. /** A */
  58816. A = 1,
  58817. /** Y */
  58818. Y = 2,
  58819. /** X */
  58820. X = 3,
  58821. /** L */
  58822. L = 4,
  58823. /** R */
  58824. R = 5,
  58825. /** ZL */
  58826. ZL = 6,
  58827. /** ZR */
  58828. ZR = 7,
  58829. /** Minus */
  58830. Minus = 8,
  58831. /** Plus */
  58832. Plus = 9,
  58833. /** LS */
  58834. LS = 10,
  58835. /** RS */
  58836. RS = 11,
  58837. /** DPadUp */
  58838. DPadUp = 12,
  58839. /** DPadDown */
  58840. DPadDown = 13,
  58841. /** DPadLeft */
  58842. DPadLeft = 14,
  58843. /** DRight */
  58844. DPadRight = 15,
  58845. /** Home */
  58846. Home = 16,
  58847. /** Capture */
  58848. Capture = 17,
  58849. /** LStickXAxis */
  58850. LStickXAxis = 18,
  58851. /** LStickYAxis */
  58852. LStickYAxis = 19,
  58853. /** RStickXAxis */
  58854. RStickXAxis = 20,
  58855. /** RStickYAxis */
  58856. RStickYAxis = 21
  58857. }
  58858. }
  58859. declare module BABYLON {
  58860. /**
  58861. * This class will take all inputs from Keyboard, Pointer, and
  58862. * any Gamepads and provide a polling system that all devices
  58863. * will use. This class assumes that there will only be one
  58864. * pointer device and one keyboard.
  58865. */
  58866. export class DeviceInputSystem implements IDisposable {
  58867. /**
  58868. * Returns onDeviceConnected callback property
  58869. * @returns Callback with function to execute when a device is connected
  58870. */
  58871. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58872. /**
  58873. * Sets callback function when a device is connected and executes against all connected devices
  58874. * @param callback Function to execute when a device is connected
  58875. */
  58876. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58877. /**
  58878. * Callback to be triggered when a device is disconnected
  58879. */
  58880. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58881. /**
  58882. * Callback to be triggered when event driven input is updated
  58883. */
  58884. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58885. private _inputs;
  58886. private _gamepads;
  58887. private _keyboardActive;
  58888. private _pointerActive;
  58889. private _elementToAttachTo;
  58890. private _keyboardDownEvent;
  58891. private _keyboardUpEvent;
  58892. private _pointerMoveEvent;
  58893. private _pointerDownEvent;
  58894. private _pointerUpEvent;
  58895. private _gamepadConnectedEvent;
  58896. private _gamepadDisconnectedEvent;
  58897. private _onDeviceConnected;
  58898. private static _MAX_KEYCODES;
  58899. private static _MAX_POINTER_INPUTS;
  58900. private constructor();
  58901. /**
  58902. * Creates a new DeviceInputSystem instance
  58903. * @param engine Engine to pull input element from
  58904. * @returns The new instance
  58905. */
  58906. static Create(engine: Engine): DeviceInputSystem;
  58907. /**
  58908. * Checks for current device input value, given an id and input index
  58909. * @param deviceName Id of connected device
  58910. * @param inputIndex Index of device input
  58911. * @returns Current value of input
  58912. */
  58913. /**
  58914. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58915. * @param deviceType Enum specifiying device type
  58916. * @param deviceSlot "Slot" or index that device is referenced in
  58917. * @param inputIndex Id of input to be checked
  58918. * @returns Current value of input
  58919. */
  58920. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58921. /**
  58922. * Dispose of all the eventlisteners
  58923. */
  58924. dispose(): void;
  58925. /**
  58926. * Checks for existing connections to devices and register them, if necessary
  58927. * Currently handles gamepads and mouse
  58928. */
  58929. private _checkForConnectedDevices;
  58930. /**
  58931. * Add a gamepad to the DeviceInputSystem
  58932. * @param gamepad A single DOM Gamepad object
  58933. */
  58934. private _addGamePad;
  58935. /**
  58936. * Add pointer device to DeviceInputSystem
  58937. * @param deviceType Type of Pointer to add
  58938. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58939. * @param currentX Current X at point of adding
  58940. * @param currentY Current Y at point of adding
  58941. */
  58942. private _addPointerDevice;
  58943. /**
  58944. * Add device and inputs to device array
  58945. * @param deviceType Enum specifiying device type
  58946. * @param deviceSlot "Slot" or index that device is referenced in
  58947. * @param numberOfInputs Number of input entries to create for given device
  58948. */
  58949. private _registerDevice;
  58950. /**
  58951. * Given a specific device name, remove that device from the device map
  58952. * @param deviceType Enum specifiying device type
  58953. * @param deviceSlot "Slot" or index that device is referenced in
  58954. */
  58955. private _unregisterDevice;
  58956. /**
  58957. * Handle all actions that come from keyboard interaction
  58958. */
  58959. private _handleKeyActions;
  58960. /**
  58961. * Handle all actions that come from pointer interaction
  58962. */
  58963. private _handlePointerActions;
  58964. /**
  58965. * Handle all actions that come from gamepad interaction
  58966. */
  58967. private _handleGamepadActions;
  58968. /**
  58969. * Update all non-event based devices with each frame
  58970. * @param deviceType Enum specifiying device type
  58971. * @param deviceSlot "Slot" or index that device is referenced in
  58972. * @param inputIndex Id of input to be checked
  58973. */
  58974. private _updateDevice;
  58975. /**
  58976. * Gets DeviceType from the device name
  58977. * @param deviceName Name of Device from DeviceInputSystem
  58978. * @returns DeviceType enum value
  58979. */
  58980. private _getGamepadDeviceType;
  58981. }
  58982. }
  58983. declare module BABYLON {
  58984. /**
  58985. * Type to handle enforcement of inputs
  58986. */
  58987. 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;
  58988. }
  58989. declare module BABYLON {
  58990. /**
  58991. * Class that handles all input for a specific device
  58992. */
  58993. export class DeviceSource<T extends DeviceType> {
  58994. /** Type of device */
  58995. readonly deviceType: DeviceType;
  58996. /** "Slot" or index that device is referenced in */
  58997. readonly deviceSlot: number;
  58998. /**
  58999. * Observable to handle device input changes per device
  59000. */
  59001. readonly onInputChangedObservable: Observable<{
  59002. inputIndex: DeviceInput<T>;
  59003. previousState: Nullable<number>;
  59004. currentState: Nullable<number>;
  59005. }>;
  59006. private readonly _deviceInputSystem;
  59007. /**
  59008. * Default Constructor
  59009. * @param deviceInputSystem Reference to DeviceInputSystem
  59010. * @param deviceType Type of device
  59011. * @param deviceSlot "Slot" or index that device is referenced in
  59012. */
  59013. constructor(deviceInputSystem: DeviceInputSystem,
  59014. /** Type of device */
  59015. deviceType: DeviceType,
  59016. /** "Slot" or index that device is referenced in */
  59017. deviceSlot?: number);
  59018. /**
  59019. * Get input for specific input
  59020. * @param inputIndex index of specific input on device
  59021. * @returns Input value from DeviceInputSystem
  59022. */
  59023. getInput(inputIndex: DeviceInput<T>): number;
  59024. }
  59025. /**
  59026. * Class to keep track of devices
  59027. */
  59028. export class DeviceSourceManager implements IDisposable {
  59029. /**
  59030. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59031. */
  59032. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59033. /**
  59034. * Observable to be triggered when after a device is disconnected
  59035. */
  59036. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59037. private readonly _devices;
  59038. private readonly _firstDevice;
  59039. private readonly _deviceInputSystem;
  59040. /**
  59041. * Default Constructor
  59042. * @param engine engine to pull input element from
  59043. */
  59044. constructor(engine: Engine);
  59045. /**
  59046. * Gets a DeviceSource, given a type and slot
  59047. * @param deviceType Enum specifying device type
  59048. * @param deviceSlot "Slot" or index that device is referenced in
  59049. * @returns DeviceSource object
  59050. */
  59051. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59052. /**
  59053. * Gets an array of DeviceSource objects for a given device type
  59054. * @param deviceType Enum specifying device type
  59055. * @returns Array of DeviceSource objects
  59056. */
  59057. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59058. /**
  59059. * Returns a read-only list of all available devices
  59060. * @returns Read-only array with active devices
  59061. */
  59062. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59063. /**
  59064. * Dispose of DeviceInputSystem and other parts
  59065. */
  59066. dispose(): void;
  59067. /**
  59068. * Function to add device name to device list
  59069. * @param deviceType Enum specifying device type
  59070. * @param deviceSlot "Slot" or index that device is referenced in
  59071. */
  59072. private _addDevice;
  59073. /**
  59074. * Function to remove device name to device list
  59075. * @param deviceType Enum specifying device type
  59076. * @param deviceSlot "Slot" or index that device is referenced in
  59077. */
  59078. private _removeDevice;
  59079. /**
  59080. * Updates array storing first connected device of each type
  59081. * @param type Type of Device
  59082. */
  59083. private _updateFirstDevices;
  59084. }
  59085. }
  59086. declare module BABYLON {
  59087. /**
  59088. * Options to create the null engine
  59089. */
  59090. export class NullEngineOptions {
  59091. /**
  59092. * Render width (Default: 512)
  59093. */
  59094. renderWidth: number;
  59095. /**
  59096. * Render height (Default: 256)
  59097. */
  59098. renderHeight: number;
  59099. /**
  59100. * Texture size (Default: 512)
  59101. */
  59102. textureSize: number;
  59103. /**
  59104. * If delta time between frames should be constant
  59105. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59106. */
  59107. deterministicLockstep: boolean;
  59108. /**
  59109. * Maximum about of steps between frames (Default: 4)
  59110. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59111. */
  59112. lockstepMaxSteps: number;
  59113. /**
  59114. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59115. */
  59116. useHighPrecisionMatrix?: boolean;
  59117. }
  59118. /**
  59119. * The null engine class provides support for headless version of babylon.js.
  59120. * This can be used in server side scenario or for testing purposes
  59121. */
  59122. export class NullEngine extends Engine {
  59123. private _options;
  59124. /**
  59125. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59126. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59127. * @returns true if engine is in deterministic lock step mode
  59128. */
  59129. isDeterministicLockStep(): boolean;
  59130. /**
  59131. * Gets the max steps when engine is running in deterministic lock step
  59132. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59133. * @returns the max steps
  59134. */
  59135. getLockstepMaxSteps(): number;
  59136. /**
  59137. * Gets the current hardware scaling level.
  59138. * By default the hardware scaling level is computed from the window device ratio.
  59139. * 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.
  59140. * @returns a number indicating the current hardware scaling level
  59141. */
  59142. getHardwareScalingLevel(): number;
  59143. constructor(options?: NullEngineOptions);
  59144. /**
  59145. * Creates a vertex buffer
  59146. * @param vertices the data for the vertex buffer
  59147. * @returns the new WebGL static buffer
  59148. */
  59149. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59150. /**
  59151. * Creates a new index buffer
  59152. * @param indices defines the content of the index buffer
  59153. * @param updatable defines if the index buffer must be updatable
  59154. * @returns a new webGL buffer
  59155. */
  59156. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59157. /**
  59158. * Clear the current render buffer or the current render target (if any is set up)
  59159. * @param color defines the color to use
  59160. * @param backBuffer defines if the back buffer must be cleared
  59161. * @param depth defines if the depth buffer must be cleared
  59162. * @param stencil defines if the stencil buffer must be cleared
  59163. */
  59164. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59165. /**
  59166. * Gets the current render width
  59167. * @param useScreen defines if screen size must be used (or the current render target if any)
  59168. * @returns a number defining the current render width
  59169. */
  59170. getRenderWidth(useScreen?: boolean): number;
  59171. /**
  59172. * Gets the current render height
  59173. * @param useScreen defines if screen size must be used (or the current render target if any)
  59174. * @returns a number defining the current render height
  59175. */
  59176. getRenderHeight(useScreen?: boolean): number;
  59177. /**
  59178. * Set the WebGL's viewport
  59179. * @param viewport defines the viewport element to be used
  59180. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59181. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59182. */
  59183. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59184. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59185. /**
  59186. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59187. * @param pipelineContext defines the pipeline context to use
  59188. * @param uniformsNames defines the list of uniform names
  59189. * @returns an array of webGL uniform locations
  59190. */
  59191. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59192. /**
  59193. * Gets the lsit of active attributes for a given webGL program
  59194. * @param pipelineContext defines the pipeline context to use
  59195. * @param attributesNames defines the list of attribute names to get
  59196. * @returns an array of indices indicating the offset of each attribute
  59197. */
  59198. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59199. /**
  59200. * Binds an effect to the webGL context
  59201. * @param effect defines the effect to bind
  59202. */
  59203. bindSamplers(effect: Effect): void;
  59204. /**
  59205. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  59206. * @param effect defines the effect to activate
  59207. */
  59208. enableEffect(effect: Effect): void;
  59209. /**
  59210. * Set various states to the webGL context
  59211. * @param culling defines backface culling state
  59212. * @param zOffset defines the value to apply to zOffset (0 by default)
  59213. * @param force defines if states must be applied even if cache is up to date
  59214. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59215. */
  59216. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59217. /**
  59218. * Set the value of an uniform to an array of int32
  59219. * @param uniform defines the webGL uniform location where to store the value
  59220. * @param array defines the array of int32 to store
  59221. * @returns true if value was set
  59222. */
  59223. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59224. /**
  59225. * Set the value of an uniform to an array of int32 (stored as vec2)
  59226. * @param uniform defines the webGL uniform location where to store the value
  59227. * @param array defines the array of int32 to store
  59228. * @returns true if value was set
  59229. */
  59230. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59231. /**
  59232. * Set the value of an uniform to an array of int32 (stored as vec3)
  59233. * @param uniform defines the webGL uniform location where to store the value
  59234. * @param array defines the array of int32 to store
  59235. * @returns true if value was set
  59236. */
  59237. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59238. /**
  59239. * Set the value of an uniform to an array of int32 (stored as vec4)
  59240. * @param uniform defines the webGL uniform location where to store the value
  59241. * @param array defines the array of int32 to store
  59242. * @returns true if value was set
  59243. */
  59244. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59245. /**
  59246. * Set the value of an uniform to an array of float32
  59247. * @param uniform defines the webGL uniform location where to store the value
  59248. * @param array defines the array of float32 to store
  59249. * @returns true if value was set
  59250. */
  59251. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59252. /**
  59253. * Set the value of an uniform to an array of float32 (stored as vec2)
  59254. * @param uniform defines the webGL uniform location where to store the value
  59255. * @param array defines the array of float32 to store
  59256. * @returns true if value was set
  59257. */
  59258. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59259. /**
  59260. * Set the value of an uniform to an array of float32 (stored as vec3)
  59261. * @param uniform defines the webGL uniform location where to store the value
  59262. * @param array defines the array of float32 to store
  59263. * @returns true if value was set
  59264. */
  59265. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59266. /**
  59267. * Set the value of an uniform to an array of float32 (stored as vec4)
  59268. * @param uniform defines the webGL uniform location where to store the value
  59269. * @param array defines the array of float32 to store
  59270. * @returns true if value was set
  59271. */
  59272. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59273. /**
  59274. * Set the value of an uniform to an array of number
  59275. * @param uniform defines the webGL uniform location where to store the value
  59276. * @param array defines the array of number to store
  59277. * @returns true if value was set
  59278. */
  59279. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59280. /**
  59281. * Set the value of an uniform to an array of number (stored as vec2)
  59282. * @param uniform defines the webGL uniform location where to store the value
  59283. * @param array defines the array of number to store
  59284. * @returns true if value was set
  59285. */
  59286. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59287. /**
  59288. * Set the value of an uniform to an array of number (stored as vec3)
  59289. * @param uniform defines the webGL uniform location where to store the value
  59290. * @param array defines the array of number to store
  59291. * @returns true if value was set
  59292. */
  59293. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59294. /**
  59295. * Set the value of an uniform to an array of number (stored as vec4)
  59296. * @param uniform defines the webGL uniform location where to store the value
  59297. * @param array defines the array of number to store
  59298. * @returns true if value was set
  59299. */
  59300. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59301. /**
  59302. * Set the value of an uniform to an array of float32 (stored as matrices)
  59303. * @param uniform defines the webGL uniform location where to store the value
  59304. * @param matrices defines the array of float32 to store
  59305. * @returns true if value was set
  59306. */
  59307. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59308. /**
  59309. * Set the value of an uniform to a matrix (3x3)
  59310. * @param uniform defines the webGL uniform location where to store the value
  59311. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59312. * @returns true if value was set
  59313. */
  59314. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59315. /**
  59316. * Set the value of an uniform to a matrix (2x2)
  59317. * @param uniform defines the webGL uniform location where to store the value
  59318. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59319. * @returns true if value was set
  59320. */
  59321. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59322. /**
  59323. * Set the value of an uniform to a number (float)
  59324. * @param uniform defines the webGL uniform location where to store the value
  59325. * @param value defines the float number to store
  59326. * @returns true if value was set
  59327. */
  59328. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59329. /**
  59330. * Set the value of an uniform to a vec2
  59331. * @param uniform defines the webGL uniform location where to store the value
  59332. * @param x defines the 1st component of the value
  59333. * @param y defines the 2nd component of the value
  59334. * @returns true if value was set
  59335. */
  59336. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59337. /**
  59338. * Set the value of an uniform to a vec3
  59339. * @param uniform defines the webGL uniform location where to store the value
  59340. * @param x defines the 1st component of the value
  59341. * @param y defines the 2nd component of the value
  59342. * @param z defines the 3rd component of the value
  59343. * @returns true if value was set
  59344. */
  59345. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59346. /**
  59347. * Set the value of an uniform to a boolean
  59348. * @param uniform defines the webGL uniform location where to store the value
  59349. * @param bool defines the boolean to store
  59350. * @returns true if value was set
  59351. */
  59352. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59353. /**
  59354. * Set the value of an uniform to a vec4
  59355. * @param uniform defines the webGL uniform location where to store the value
  59356. * @param x defines the 1st component of the value
  59357. * @param y defines the 2nd component of the value
  59358. * @param z defines the 3rd component of the value
  59359. * @param w defines the 4th component of the value
  59360. * @returns true if value was set
  59361. */
  59362. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59363. /**
  59364. * Sets the current alpha mode
  59365. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59366. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59367. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59368. */
  59369. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59370. /**
  59371. * Bind webGl buffers directly to the webGL context
  59372. * @param vertexBuffers defines the vertex buffer to bind
  59373. * @param indexBuffer defines the index buffer to bind
  59374. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59375. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59376. * @param effect defines the effect associated with the vertex buffer
  59377. */
  59378. bindBuffers(vertexBuffers: {
  59379. [key: string]: VertexBuffer;
  59380. }, indexBuffer: DataBuffer, effect: Effect): void;
  59381. /**
  59382. * Force the entire cache to be cleared
  59383. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59384. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59385. */
  59386. wipeCaches(bruteForce?: boolean): void;
  59387. /**
  59388. * Send a draw order
  59389. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59390. * @param indexStart defines the starting index
  59391. * @param indexCount defines the number of index to draw
  59392. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59393. */
  59394. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59395. /**
  59396. * Draw a list of indexed primitives
  59397. * @param fillMode defines the primitive to use
  59398. * @param indexStart defines the starting index
  59399. * @param indexCount defines the number of index to draw
  59400. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59401. */
  59402. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59403. /**
  59404. * Draw a list of unindexed primitives
  59405. * @param fillMode defines the primitive to use
  59406. * @param verticesStart defines the index of first vertex to draw
  59407. * @param verticesCount defines the count of vertices to draw
  59408. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59409. */
  59410. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59411. /** @hidden */
  59412. protected _createTexture(): WebGLTexture;
  59413. /** @hidden */
  59414. _releaseTexture(texture: InternalTexture): void;
  59415. /**
  59416. * Usually called from Texture.ts.
  59417. * Passed information to create a WebGLTexture
  59418. * @param urlArg defines a value which contains one of the following:
  59419. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59420. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59421. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59422. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59423. * @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)
  59424. * @param scene needed for loading to the correct scene
  59425. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59426. * @param onLoad optional callback to be called upon successful completion
  59427. * @param onError optional callback to be called upon failure
  59428. * @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
  59429. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59430. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59431. * @param forcedExtension defines the extension to use to pick the right loader
  59432. * @param mimeType defines an optional mime type
  59433. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59434. */
  59435. 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;
  59436. /**
  59437. * Creates a new render target texture
  59438. * @param size defines the size of the texture
  59439. * @param options defines the options used to create the texture
  59440. * @returns a new render target texture stored in an InternalTexture
  59441. */
  59442. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59443. /**
  59444. * Update the sampling mode of a given texture
  59445. * @param samplingMode defines the required sampling mode
  59446. * @param texture defines the texture to update
  59447. */
  59448. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59449. /**
  59450. * Binds the frame buffer to the specified texture.
  59451. * @param texture The texture to render to or null for the default canvas
  59452. * @param faceIndex The face of the texture to render to in case of cube texture
  59453. * @param requiredWidth The width of the target to render to
  59454. * @param requiredHeight The height of the target to render to
  59455. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59456. * @param lodLevel defines le lod level to bind to the frame buffer
  59457. */
  59458. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59459. /**
  59460. * Unbind the current render target texture from the webGL context
  59461. * @param texture defines the render target texture to unbind
  59462. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59463. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59464. */
  59465. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59466. /**
  59467. * Creates a dynamic vertex buffer
  59468. * @param vertices the data for the dynamic vertex buffer
  59469. * @returns the new WebGL dynamic buffer
  59470. */
  59471. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59472. /**
  59473. * Update the content of a dynamic texture
  59474. * @param texture defines the texture to update
  59475. * @param canvas defines the canvas containing the source
  59476. * @param invertY defines if data must be stored with Y axis inverted
  59477. * @param premulAlpha defines if alpha is stored as premultiplied
  59478. * @param format defines the format of the data
  59479. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59480. */
  59481. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59482. /**
  59483. * Gets a boolean indicating if all created effects are ready
  59484. * @returns true if all effects are ready
  59485. */
  59486. areAllEffectsReady(): boolean;
  59487. /**
  59488. * @hidden
  59489. * Get the current error code of the webGL context
  59490. * @returns the error code
  59491. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59492. */
  59493. getError(): number;
  59494. /** @hidden */
  59495. _getUnpackAlignement(): number;
  59496. /** @hidden */
  59497. _unpackFlipY(value: boolean): void;
  59498. /**
  59499. * Update a dynamic index buffer
  59500. * @param indexBuffer defines the target index buffer
  59501. * @param indices defines the data to update
  59502. * @param offset defines the offset in the target index buffer where update should start
  59503. */
  59504. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59505. /**
  59506. * Updates a dynamic vertex buffer.
  59507. * @param vertexBuffer the vertex buffer to update
  59508. * @param vertices the data used to update the vertex buffer
  59509. * @param byteOffset the byte offset of the data (optional)
  59510. * @param byteLength the byte length of the data (optional)
  59511. */
  59512. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59513. /** @hidden */
  59514. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59515. /** @hidden */
  59516. _bindTexture(channel: number, texture: InternalTexture): void;
  59517. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59518. /**
  59519. * 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
  59520. */
  59521. releaseEffects(): void;
  59522. displayLoadingUI(): void;
  59523. hideLoadingUI(): void;
  59524. /** @hidden */
  59525. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59526. /** @hidden */
  59527. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59528. /** @hidden */
  59529. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59530. /** @hidden */
  59531. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59532. }
  59533. }
  59534. declare module BABYLON {
  59535. /** @hidden */
  59536. export class _OcclusionDataStorage {
  59537. /** @hidden */
  59538. occlusionInternalRetryCounter: number;
  59539. /** @hidden */
  59540. isOcclusionQueryInProgress: boolean;
  59541. /** @hidden */
  59542. isOccluded: boolean;
  59543. /** @hidden */
  59544. occlusionRetryCount: number;
  59545. /** @hidden */
  59546. occlusionType: number;
  59547. /** @hidden */
  59548. occlusionQueryAlgorithmType: number;
  59549. }
  59550. interface Engine {
  59551. /**
  59552. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59553. * @return the new query
  59554. */
  59555. createQuery(): WebGLQuery;
  59556. /**
  59557. * Delete and release a webGL query
  59558. * @param query defines the query to delete
  59559. * @return the current engine
  59560. */
  59561. deleteQuery(query: WebGLQuery): Engine;
  59562. /**
  59563. * Check if a given query has resolved and got its value
  59564. * @param query defines the query to check
  59565. * @returns true if the query got its value
  59566. */
  59567. isQueryResultAvailable(query: WebGLQuery): boolean;
  59568. /**
  59569. * Gets the value of a given query
  59570. * @param query defines the query to check
  59571. * @returns the value of the query
  59572. */
  59573. getQueryResult(query: WebGLQuery): number;
  59574. /**
  59575. * Initiates an occlusion query
  59576. * @param algorithmType defines the algorithm to use
  59577. * @param query defines the query to use
  59578. * @returns the current engine
  59579. * @see https://doc.babylonjs.com/features/occlusionquery
  59580. */
  59581. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59582. /**
  59583. * Ends an occlusion query
  59584. * @see https://doc.babylonjs.com/features/occlusionquery
  59585. * @param algorithmType defines the algorithm to use
  59586. * @returns the current engine
  59587. */
  59588. endOcclusionQuery(algorithmType: number): Engine;
  59589. /**
  59590. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59591. * Please note that only one query can be issued at a time
  59592. * @returns a time token used to track the time span
  59593. */
  59594. startTimeQuery(): Nullable<_TimeToken>;
  59595. /**
  59596. * Ends a time query
  59597. * @param token defines the token used to measure the time span
  59598. * @returns the time spent (in ns)
  59599. */
  59600. endTimeQuery(token: _TimeToken): int;
  59601. /** @hidden */
  59602. _currentNonTimestampToken: Nullable<_TimeToken>;
  59603. /** @hidden */
  59604. _createTimeQuery(): WebGLQuery;
  59605. /** @hidden */
  59606. _deleteTimeQuery(query: WebGLQuery): void;
  59607. /** @hidden */
  59608. _getGlAlgorithmType(algorithmType: number): number;
  59609. /** @hidden */
  59610. _getTimeQueryResult(query: WebGLQuery): any;
  59611. /** @hidden */
  59612. _getTimeQueryAvailability(query: WebGLQuery): any;
  59613. }
  59614. interface AbstractMesh {
  59615. /**
  59616. * Backing filed
  59617. * @hidden
  59618. */
  59619. __occlusionDataStorage: _OcclusionDataStorage;
  59620. /**
  59621. * Access property
  59622. * @hidden
  59623. */
  59624. _occlusionDataStorage: _OcclusionDataStorage;
  59625. /**
  59626. * 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.
  59627. * The default value is -1 which means don't break the query and wait till the result
  59628. * @see https://doc.babylonjs.com/features/occlusionquery
  59629. */
  59630. occlusionRetryCount: number;
  59631. /**
  59632. * 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:
  59633. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59634. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59635. * * 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.
  59636. * @see https://doc.babylonjs.com/features/occlusionquery
  59637. */
  59638. occlusionType: number;
  59639. /**
  59640. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59641. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59642. * * 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.
  59643. * @see https://doc.babylonjs.com/features/occlusionquery
  59644. */
  59645. occlusionQueryAlgorithmType: number;
  59646. /**
  59647. * 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
  59648. * @see https://doc.babylonjs.com/features/occlusionquery
  59649. */
  59650. isOccluded: boolean;
  59651. /**
  59652. * Flag to check the progress status of the query
  59653. * @see https://doc.babylonjs.com/features/occlusionquery
  59654. */
  59655. isOcclusionQueryInProgress: boolean;
  59656. }
  59657. }
  59658. declare module BABYLON {
  59659. /** @hidden */
  59660. export var _forceTransformFeedbackToBundle: boolean;
  59661. interface Engine {
  59662. /**
  59663. * Creates a webGL transform feedback object
  59664. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59665. * @returns the webGL transform feedback object
  59666. */
  59667. createTransformFeedback(): WebGLTransformFeedback;
  59668. /**
  59669. * Delete a webGL transform feedback object
  59670. * @param value defines the webGL transform feedback object to delete
  59671. */
  59672. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59673. /**
  59674. * Bind a webGL transform feedback object to the webgl context
  59675. * @param value defines the webGL transform feedback object to bind
  59676. */
  59677. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59678. /**
  59679. * Begins a transform feedback operation
  59680. * @param usePoints defines if points or triangles must be used
  59681. */
  59682. beginTransformFeedback(usePoints: boolean): void;
  59683. /**
  59684. * Ends a transform feedback operation
  59685. */
  59686. endTransformFeedback(): void;
  59687. /**
  59688. * Specify the varyings to use with transform feedback
  59689. * @param program defines the associated webGL program
  59690. * @param value defines the list of strings representing the varying names
  59691. */
  59692. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59693. /**
  59694. * Bind a webGL buffer for a transform feedback operation
  59695. * @param value defines the webGL buffer to bind
  59696. */
  59697. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59698. }
  59699. }
  59700. declare module BABYLON {
  59701. /**
  59702. * Class used to define an additional view for the engine
  59703. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59704. */
  59705. export class EngineView {
  59706. /** Defines the canvas where to render the view */
  59707. target: HTMLCanvasElement;
  59708. /** Defines an optional camera used to render the view (will use active camera else) */
  59709. camera?: Camera;
  59710. }
  59711. interface Engine {
  59712. /**
  59713. * Gets or sets the HTML element to use for attaching events
  59714. */
  59715. inputElement: Nullable<HTMLElement>;
  59716. /**
  59717. * Gets the current engine view
  59718. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59719. */
  59720. activeView: Nullable<EngineView>;
  59721. /** Gets or sets the list of views */
  59722. views: EngineView[];
  59723. /**
  59724. * Register a new child canvas
  59725. * @param canvas defines the canvas to register
  59726. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59727. * @returns the associated view
  59728. */
  59729. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59730. /**
  59731. * Remove a registered child canvas
  59732. * @param canvas defines the canvas to remove
  59733. * @returns the current engine
  59734. */
  59735. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59736. }
  59737. }
  59738. declare module BABYLON {
  59739. interface Engine {
  59740. /** @hidden */
  59741. _excludedCompressedTextures: string[];
  59742. /** @hidden */
  59743. _textureFormatInUse: string;
  59744. /**
  59745. * Gets the list of texture formats supported
  59746. */
  59747. readonly texturesSupported: Array<string>;
  59748. /**
  59749. * Gets the texture format in use
  59750. */
  59751. readonly textureFormatInUse: Nullable<string>;
  59752. /**
  59753. * Set the compressed texture extensions or file names to skip.
  59754. *
  59755. * @param skippedFiles defines the list of those texture files you want to skip
  59756. * Example: [".dds", ".env", "myfile.png"]
  59757. */
  59758. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59759. /**
  59760. * Set the compressed texture format to use, based on the formats you have, and the formats
  59761. * supported by the hardware / browser.
  59762. *
  59763. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59764. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59765. * to API arguments needed to compressed textures. This puts the burden on the container
  59766. * generator to house the arcane code for determining these for current & future formats.
  59767. *
  59768. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59769. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59770. *
  59771. * Note: The result of this call is not taken into account when a texture is base64.
  59772. *
  59773. * @param formatsAvailable defines the list of those format families you have created
  59774. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59775. *
  59776. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59777. * @returns The extension selected.
  59778. */
  59779. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59780. }
  59781. }
  59782. declare module BABYLON {
  59783. /** @hidden */
  59784. export var rgbdEncodePixelShader: {
  59785. name: string;
  59786. shader: string;
  59787. };
  59788. }
  59789. declare module BABYLON {
  59790. /**
  59791. * Raw texture data and descriptor sufficient for WebGL texture upload
  59792. */
  59793. export interface EnvironmentTextureInfo {
  59794. /**
  59795. * Version of the environment map
  59796. */
  59797. version: number;
  59798. /**
  59799. * Width of image
  59800. */
  59801. width: number;
  59802. /**
  59803. * Irradiance information stored in the file.
  59804. */
  59805. irradiance: any;
  59806. /**
  59807. * Specular information stored in the file.
  59808. */
  59809. specular: any;
  59810. }
  59811. /**
  59812. * Defines One Image in the file. It requires only the position in the file
  59813. * as well as the length.
  59814. */
  59815. interface BufferImageData {
  59816. /**
  59817. * Length of the image data.
  59818. */
  59819. length: number;
  59820. /**
  59821. * Position of the data from the null terminator delimiting the end of the JSON.
  59822. */
  59823. position: number;
  59824. }
  59825. /**
  59826. * Defines the specular data enclosed in the file.
  59827. * This corresponds to the version 1 of the data.
  59828. */
  59829. export interface EnvironmentTextureSpecularInfoV1 {
  59830. /**
  59831. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59832. */
  59833. specularDataPosition?: number;
  59834. /**
  59835. * This contains all the images data needed to reconstruct the cubemap.
  59836. */
  59837. mipmaps: Array<BufferImageData>;
  59838. /**
  59839. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59840. */
  59841. lodGenerationScale: number;
  59842. }
  59843. /**
  59844. * Sets of helpers addressing the serialization and deserialization of environment texture
  59845. * stored in a BabylonJS env file.
  59846. * Those files are usually stored as .env files.
  59847. */
  59848. export class EnvironmentTextureTools {
  59849. /**
  59850. * Magic number identifying the env file.
  59851. */
  59852. private static _MagicBytes;
  59853. /**
  59854. * Gets the environment info from an env file.
  59855. * @param data The array buffer containing the .env bytes.
  59856. * @returns the environment file info (the json header) if successfully parsed.
  59857. */
  59858. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59859. /**
  59860. * Creates an environment texture from a loaded cube texture.
  59861. * @param texture defines the cube texture to convert in env file
  59862. * @return a promise containing the environment data if succesfull.
  59863. */
  59864. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59865. /**
  59866. * Creates a JSON representation of the spherical data.
  59867. * @param texture defines the texture containing the polynomials
  59868. * @return the JSON representation of the spherical info
  59869. */
  59870. private static _CreateEnvTextureIrradiance;
  59871. /**
  59872. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59873. * @param data the image data
  59874. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59875. * @return the views described by info providing access to the underlying buffer
  59876. */
  59877. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59878. /**
  59879. * Uploads the texture info contained in the env file to the GPU.
  59880. * @param texture defines the internal texture to upload to
  59881. * @param data defines the data to load
  59882. * @param info defines the texture info retrieved through the GetEnvInfo method
  59883. * @returns a promise
  59884. */
  59885. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59886. private static _OnImageReadyAsync;
  59887. /**
  59888. * Uploads the levels of image data to the GPU.
  59889. * @param texture defines the internal texture to upload to
  59890. * @param imageData defines the array buffer views of image data [mipmap][face]
  59891. * @returns a promise
  59892. */
  59893. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59894. /**
  59895. * Uploads spherical polynomials information to the texture.
  59896. * @param texture defines the texture we are trying to upload the information to
  59897. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59898. */
  59899. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59900. /** @hidden */
  59901. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59902. }
  59903. }
  59904. declare module BABYLON {
  59905. /**
  59906. * Container for accessors for natively-stored mesh data buffers.
  59907. */
  59908. class NativeDataBuffer extends DataBuffer {
  59909. /**
  59910. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59911. */
  59912. nativeIndexBuffer?: any;
  59913. /**
  59914. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59915. */
  59916. nativeVertexBuffer?: any;
  59917. }
  59918. /** @hidden */
  59919. class NativeTexture extends InternalTexture {
  59920. getInternalTexture(): InternalTexture;
  59921. getViewCount(): number;
  59922. }
  59923. /** @hidden */
  59924. export class NativeEngine extends Engine {
  59925. private readonly _native;
  59926. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59927. private readonly INVALID_HANDLE;
  59928. private _boundBuffersVertexArray;
  59929. private _currentDepthTest;
  59930. getHardwareScalingLevel(): number;
  59931. constructor();
  59932. dispose(): void;
  59933. /**
  59934. * Can be used to override the current requestAnimationFrame requester.
  59935. * @hidden
  59936. */
  59937. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59938. /**
  59939. * Override default engine behavior.
  59940. * @param color
  59941. * @param backBuffer
  59942. * @param depth
  59943. * @param stencil
  59944. */
  59945. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59946. /**
  59947. * Gets host document
  59948. * @returns the host document object
  59949. */
  59950. getHostDocument(): Nullable<Document>;
  59951. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59952. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59953. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59954. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59955. [key: string]: VertexBuffer;
  59956. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59957. bindBuffers(vertexBuffers: {
  59958. [key: string]: VertexBuffer;
  59959. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59960. recordVertexArrayObject(vertexBuffers: {
  59961. [key: string]: VertexBuffer;
  59962. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59963. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59964. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59965. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59966. /**
  59967. * Draw a list of indexed primitives
  59968. * @param fillMode defines the primitive to use
  59969. * @param indexStart defines the starting index
  59970. * @param indexCount defines the number of index to draw
  59971. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59972. */
  59973. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59974. /**
  59975. * Draw a list of unindexed primitives
  59976. * @param fillMode defines the primitive to use
  59977. * @param verticesStart defines the index of first vertex to draw
  59978. * @param verticesCount defines the count of vertices to draw
  59979. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59980. */
  59981. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59982. createPipelineContext(): IPipelineContext;
  59983. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59984. /** @hidden */
  59985. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59986. /** @hidden */
  59987. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59988. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59989. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59990. protected _setProgram(program: WebGLProgram): void;
  59991. _releaseEffect(effect: Effect): void;
  59992. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59993. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59994. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59995. bindSamplers(effect: Effect): void;
  59996. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  59997. getRenderWidth(useScreen?: boolean): number;
  59998. getRenderHeight(useScreen?: boolean): number;
  59999. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60000. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60001. /**
  60002. * Set the z offset to apply to current rendering
  60003. * @param value defines the offset to apply
  60004. */
  60005. setZOffset(value: number): void;
  60006. /**
  60007. * Gets the current value of the zOffset
  60008. * @returns the current zOffset state
  60009. */
  60010. getZOffset(): number;
  60011. /**
  60012. * Enable or disable depth buffering
  60013. * @param enable defines the state to set
  60014. */
  60015. setDepthBuffer(enable: boolean): void;
  60016. /**
  60017. * Gets a boolean indicating if depth writing is enabled
  60018. * @returns the current depth writing state
  60019. */
  60020. getDepthWrite(): boolean;
  60021. setDepthFunctionToGreater(): void;
  60022. setDepthFunctionToGreaterOrEqual(): void;
  60023. setDepthFunctionToLess(): void;
  60024. setDepthFunctionToLessOrEqual(): void;
  60025. /**
  60026. * Enable or disable depth writing
  60027. * @param enable defines the state to set
  60028. */
  60029. setDepthWrite(enable: boolean): void;
  60030. /**
  60031. * Enable or disable color writing
  60032. * @param enable defines the state to set
  60033. */
  60034. setColorWrite(enable: boolean): void;
  60035. /**
  60036. * Gets a boolean indicating if color writing is enabled
  60037. * @returns the current color writing state
  60038. */
  60039. getColorWrite(): boolean;
  60040. /**
  60041. * Sets alpha constants used by some alpha blending modes
  60042. * @param r defines the red component
  60043. * @param g defines the green component
  60044. * @param b defines the blue component
  60045. * @param a defines the alpha component
  60046. */
  60047. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60048. /**
  60049. * Sets the current alpha mode
  60050. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60051. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60052. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60053. */
  60054. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60055. /**
  60056. * Gets the current alpha mode
  60057. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60058. * @returns the current alpha mode
  60059. */
  60060. getAlphaMode(): number;
  60061. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60062. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60063. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60064. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60065. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60066. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60067. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60068. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60069. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60070. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60071. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60072. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60073. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60074. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60075. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60076. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60077. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60078. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60079. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60080. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60081. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60082. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60083. wipeCaches(bruteForce?: boolean): void;
  60084. protected _createTexture(): WebGLTexture;
  60085. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60086. /**
  60087. * Update the content of a dynamic texture
  60088. * @param texture defines the texture to update
  60089. * @param canvas defines the canvas containing the source
  60090. * @param invertY defines if data must be stored with Y axis inverted
  60091. * @param premulAlpha defines if alpha is stored as premultiplied
  60092. * @param format defines the format of the data
  60093. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60094. */
  60095. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60096. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60097. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60098. /**
  60099. * Usually called from Texture.ts.
  60100. * Passed information to create a WebGLTexture
  60101. * @param url defines a value which contains one of the following:
  60102. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60103. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60104. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60105. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60106. * @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)
  60107. * @param scene needed for loading to the correct scene
  60108. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60109. * @param onLoad optional callback to be called upon successful completion
  60110. * @param onError optional callback to be called upon failure
  60111. * @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
  60112. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60113. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60114. * @param forcedExtension defines the extension to use to pick the right loader
  60115. * @param mimeType defines an optional mime type
  60116. * @param loaderOptions options to be passed to the loader
  60117. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60118. */
  60119. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  60120. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60121. _releaseFramebufferObjects(texture: InternalTexture): void;
  60122. /**
  60123. * Creates a cube texture
  60124. * @param rootUrl defines the url where the files to load is located
  60125. * @param scene defines the current scene
  60126. * @param files defines the list of files to load (1 per face)
  60127. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60128. * @param onLoad defines an optional callback raised when the texture is loaded
  60129. * @param onError defines an optional callback raised if there is an issue to load the texture
  60130. * @param format defines the format of the data
  60131. * @param forcedExtension defines the extension to use to pick the right loader
  60132. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60133. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60134. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60135. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60136. * @returns the cube texture as an InternalTexture
  60137. */
  60138. 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;
  60139. createRenderTargetTexture(size: number | {
  60140. width: number;
  60141. height: number;
  60142. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60143. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60144. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60145. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60146. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60147. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60148. /**
  60149. * Updates a dynamic vertex buffer.
  60150. * @param vertexBuffer the vertex buffer to update
  60151. * @param data the data used to update the vertex buffer
  60152. * @param byteOffset the byte offset of the data (optional)
  60153. * @param byteLength the byte length of the data (optional)
  60154. */
  60155. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60156. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60157. private _updateAnisotropicLevel;
  60158. private _getAddressMode;
  60159. /** @hidden */
  60160. _bindTexture(channel: number, texture: InternalTexture): void;
  60161. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60162. releaseEffects(): void;
  60163. /** @hidden */
  60164. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60165. /** @hidden */
  60166. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60167. /** @hidden */
  60168. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60169. /** @hidden */
  60170. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60171. private _getNativeSamplingMode;
  60172. private _getNativeTextureFormat;
  60173. private _getNativeAlphaMode;
  60174. private _getNativeAttribType;
  60175. }
  60176. }
  60177. declare module BABYLON {
  60178. /**
  60179. * Helper class to create the best engine depending on the current hardware
  60180. */
  60181. export class EngineFactory {
  60182. /**
  60183. * Creates an engine based on the capabilities of the underlying hardware
  60184. * @param canvas Defines the canvas to use to display the result
  60185. * @param options Defines the options passed to the engine to create the context dependencies
  60186. * @returns a promise that resolves with the created engine
  60187. */
  60188. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60189. }
  60190. }
  60191. declare module BABYLON {
  60192. /**
  60193. * Gather the list of clipboard event types as constants.
  60194. */
  60195. export class ClipboardEventTypes {
  60196. /**
  60197. * The clipboard event is fired when a copy command is active (pressed).
  60198. */
  60199. static readonly COPY: number;
  60200. /**
  60201. * The clipboard event is fired when a cut command is active (pressed).
  60202. */
  60203. static readonly CUT: number;
  60204. /**
  60205. * The clipboard event is fired when a paste command is active (pressed).
  60206. */
  60207. static readonly PASTE: number;
  60208. }
  60209. /**
  60210. * This class is used to store clipboard related info for the onClipboardObservable event.
  60211. */
  60212. export class ClipboardInfo {
  60213. /**
  60214. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60215. */
  60216. type: number;
  60217. /**
  60218. * Defines the related dom event
  60219. */
  60220. event: ClipboardEvent;
  60221. /**
  60222. *Creates an instance of ClipboardInfo.
  60223. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60224. * @param event Defines the related dom event
  60225. */
  60226. constructor(
  60227. /**
  60228. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60229. */
  60230. type: number,
  60231. /**
  60232. * Defines the related dom event
  60233. */
  60234. event: ClipboardEvent);
  60235. /**
  60236. * Get the clipboard event's type from the keycode.
  60237. * @param keyCode Defines the keyCode for the current keyboard event.
  60238. * @return {number}
  60239. */
  60240. static GetTypeFromCharacter(keyCode: number): number;
  60241. }
  60242. }
  60243. declare module BABYLON {
  60244. /**
  60245. * Google Daydream controller
  60246. */
  60247. export class DaydreamController extends WebVRController {
  60248. /**
  60249. * Base Url for the controller model.
  60250. */
  60251. static MODEL_BASE_URL: string;
  60252. /**
  60253. * File name for the controller model.
  60254. */
  60255. static MODEL_FILENAME: string;
  60256. /**
  60257. * Gamepad Id prefix used to identify Daydream Controller.
  60258. */
  60259. static readonly GAMEPAD_ID_PREFIX: string;
  60260. /**
  60261. * Creates a new DaydreamController from a gamepad
  60262. * @param vrGamepad the gamepad that the controller should be created from
  60263. */
  60264. constructor(vrGamepad: any);
  60265. /**
  60266. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60267. * @param scene scene in which to add meshes
  60268. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60269. */
  60270. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60271. /**
  60272. * Called once for each button that changed state since the last frame
  60273. * @param buttonIdx Which button index changed
  60274. * @param state New state of the button
  60275. * @param changes Which properties on the state changed since last frame
  60276. */
  60277. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60278. }
  60279. }
  60280. declare module BABYLON {
  60281. /**
  60282. * Gear VR Controller
  60283. */
  60284. export class GearVRController extends WebVRController {
  60285. /**
  60286. * Base Url for the controller model.
  60287. */
  60288. static MODEL_BASE_URL: string;
  60289. /**
  60290. * File name for the controller model.
  60291. */
  60292. static MODEL_FILENAME: string;
  60293. /**
  60294. * Gamepad Id prefix used to identify this controller.
  60295. */
  60296. static readonly GAMEPAD_ID_PREFIX: string;
  60297. private readonly _buttonIndexToObservableNameMap;
  60298. /**
  60299. * Creates a new GearVRController from a gamepad
  60300. * @param vrGamepad the gamepad that the controller should be created from
  60301. */
  60302. constructor(vrGamepad: any);
  60303. /**
  60304. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60305. * @param scene scene in which to add meshes
  60306. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60307. */
  60308. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60309. /**
  60310. * Called once for each button that changed state since the last frame
  60311. * @param buttonIdx Which button index changed
  60312. * @param state New state of the button
  60313. * @param changes Which properties on the state changed since last frame
  60314. */
  60315. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60316. }
  60317. }
  60318. declare module BABYLON {
  60319. /**
  60320. * Generic Controller
  60321. */
  60322. export class GenericController extends WebVRController {
  60323. /**
  60324. * Base Url for the controller model.
  60325. */
  60326. static readonly MODEL_BASE_URL: string;
  60327. /**
  60328. * File name for the controller model.
  60329. */
  60330. static readonly MODEL_FILENAME: string;
  60331. /**
  60332. * Creates a new GenericController from a gamepad
  60333. * @param vrGamepad the gamepad that the controller should be created from
  60334. */
  60335. constructor(vrGamepad: any);
  60336. /**
  60337. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60338. * @param scene scene in which to add meshes
  60339. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60340. */
  60341. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60342. /**
  60343. * Called once for each button that changed state since the last frame
  60344. * @param buttonIdx Which button index changed
  60345. * @param state New state of the button
  60346. * @param changes Which properties on the state changed since last frame
  60347. */
  60348. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60349. }
  60350. }
  60351. declare module BABYLON {
  60352. /**
  60353. * Oculus Touch Controller
  60354. */
  60355. export class OculusTouchController extends WebVRController {
  60356. /**
  60357. * Base Url for the controller model.
  60358. */
  60359. static MODEL_BASE_URL: string;
  60360. /**
  60361. * File name for the left controller model.
  60362. */
  60363. static MODEL_LEFT_FILENAME: string;
  60364. /**
  60365. * File name for the right controller model.
  60366. */
  60367. static MODEL_RIGHT_FILENAME: string;
  60368. /**
  60369. * Base Url for the Quest controller model.
  60370. */
  60371. static QUEST_MODEL_BASE_URL: string;
  60372. /**
  60373. * @hidden
  60374. * If the controllers are running on a device that needs the updated Quest controller models
  60375. */
  60376. static _IsQuest: boolean;
  60377. /**
  60378. * Fired when the secondary trigger on this controller is modified
  60379. */
  60380. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60381. /**
  60382. * Fired when the thumb rest on this controller is modified
  60383. */
  60384. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60385. /**
  60386. * Creates a new OculusTouchController from a gamepad
  60387. * @param vrGamepad the gamepad that the controller should be created from
  60388. */
  60389. constructor(vrGamepad: any);
  60390. /**
  60391. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60392. * @param scene scene in which to add meshes
  60393. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60394. */
  60395. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60396. /**
  60397. * Fired when the A button on this controller is modified
  60398. */
  60399. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60400. /**
  60401. * Fired when the B button on this controller is modified
  60402. */
  60403. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60404. /**
  60405. * Fired when the X button on this controller is modified
  60406. */
  60407. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60408. /**
  60409. * Fired when the Y button on this controller is modified
  60410. */
  60411. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60412. /**
  60413. * Called once for each button that changed state since the last frame
  60414. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60415. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60416. * 2) secondary trigger (same)
  60417. * 3) A (right) X (left), touch, pressed = value
  60418. * 4) B / Y
  60419. * 5) thumb rest
  60420. * @param buttonIdx Which button index changed
  60421. * @param state New state of the button
  60422. * @param changes Which properties on the state changed since last frame
  60423. */
  60424. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60425. }
  60426. }
  60427. declare module BABYLON {
  60428. /**
  60429. * Vive Controller
  60430. */
  60431. export class ViveController extends WebVRController {
  60432. /**
  60433. * Base Url for the controller model.
  60434. */
  60435. static MODEL_BASE_URL: string;
  60436. /**
  60437. * File name for the controller model.
  60438. */
  60439. static MODEL_FILENAME: string;
  60440. /**
  60441. * Creates a new ViveController from a gamepad
  60442. * @param vrGamepad the gamepad that the controller should be created from
  60443. */
  60444. constructor(vrGamepad: any);
  60445. /**
  60446. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60447. * @param scene scene in which to add meshes
  60448. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60449. */
  60450. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60451. /**
  60452. * Fired when the left button on this controller is modified
  60453. */
  60454. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60455. /**
  60456. * Fired when the right button on this controller is modified
  60457. */
  60458. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60459. /**
  60460. * Fired when the menu button on this controller is modified
  60461. */
  60462. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60463. /**
  60464. * Called once for each button that changed state since the last frame
  60465. * Vive mapping:
  60466. * 0: touchpad
  60467. * 1: trigger
  60468. * 2: left AND right buttons
  60469. * 3: menu button
  60470. * @param buttonIdx Which button index changed
  60471. * @param state New state of the button
  60472. * @param changes Which properties on the state changed since last frame
  60473. */
  60474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60475. }
  60476. }
  60477. declare module BABYLON {
  60478. /**
  60479. * Defines the WindowsMotionController object that the state of the windows motion controller
  60480. */
  60481. export class WindowsMotionController extends WebVRController {
  60482. /**
  60483. * The base url used to load the left and right controller models
  60484. */
  60485. static MODEL_BASE_URL: string;
  60486. /**
  60487. * The name of the left controller model file
  60488. */
  60489. static MODEL_LEFT_FILENAME: string;
  60490. /**
  60491. * The name of the right controller model file
  60492. */
  60493. static MODEL_RIGHT_FILENAME: string;
  60494. /**
  60495. * The controller name prefix for this controller type
  60496. */
  60497. static readonly GAMEPAD_ID_PREFIX: string;
  60498. /**
  60499. * The controller id pattern for this controller type
  60500. */
  60501. private static readonly GAMEPAD_ID_PATTERN;
  60502. private _loadedMeshInfo;
  60503. protected readonly _mapping: {
  60504. buttons: string[];
  60505. buttonMeshNames: {
  60506. trigger: string;
  60507. menu: string;
  60508. grip: string;
  60509. thumbstick: string;
  60510. trackpad: string;
  60511. };
  60512. buttonObservableNames: {
  60513. trigger: string;
  60514. menu: string;
  60515. grip: string;
  60516. thumbstick: string;
  60517. trackpad: string;
  60518. };
  60519. axisMeshNames: string[];
  60520. pointingPoseMeshName: string;
  60521. };
  60522. /**
  60523. * Fired when the trackpad on this controller is clicked
  60524. */
  60525. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60526. /**
  60527. * Fired when the trackpad on this controller is modified
  60528. */
  60529. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60530. /**
  60531. * The current x and y values of this controller's trackpad
  60532. */
  60533. trackpad: StickValues;
  60534. /**
  60535. * Creates a new WindowsMotionController from a gamepad
  60536. * @param vrGamepad the gamepad that the controller should be created from
  60537. */
  60538. constructor(vrGamepad: any);
  60539. /**
  60540. * Fired when the trigger on this controller is modified
  60541. */
  60542. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60543. /**
  60544. * Fired when the menu button on this controller is modified
  60545. */
  60546. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60547. /**
  60548. * Fired when the grip button on this controller is modified
  60549. */
  60550. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60551. /**
  60552. * Fired when the thumbstick button on this controller is modified
  60553. */
  60554. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60555. /**
  60556. * Fired when the touchpad button on this controller is modified
  60557. */
  60558. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60559. /**
  60560. * Fired when the touchpad values on this controller are modified
  60561. */
  60562. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60563. protected _updateTrackpad(): void;
  60564. /**
  60565. * Called once per frame by the engine.
  60566. */
  60567. update(): void;
  60568. /**
  60569. * Called once for each button that changed state since the last frame
  60570. * @param buttonIdx Which button index changed
  60571. * @param state New state of the button
  60572. * @param changes Which properties on the state changed since last frame
  60573. */
  60574. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60575. /**
  60576. * Moves the buttons on the controller mesh based on their current state
  60577. * @param buttonName the name of the button to move
  60578. * @param buttonValue the value of the button which determines the buttons new position
  60579. */
  60580. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60581. /**
  60582. * Moves the axis on the controller mesh based on its current state
  60583. * @param axis the index of the axis
  60584. * @param axisValue the value of the axis which determines the meshes new position
  60585. * @hidden
  60586. */
  60587. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60588. /**
  60589. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60590. * @param scene scene in which to add meshes
  60591. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60592. */
  60593. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60594. /**
  60595. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60596. * can be transformed by button presses and axes values, based on this._mapping.
  60597. *
  60598. * @param scene scene in which the meshes exist
  60599. * @param meshes list of meshes that make up the controller model to process
  60600. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60601. */
  60602. private processModel;
  60603. private createMeshInfo;
  60604. /**
  60605. * Gets the ray of the controller in the direction the controller is pointing
  60606. * @param length the length the resulting ray should be
  60607. * @returns a ray in the direction the controller is pointing
  60608. */
  60609. getForwardRay(length?: number): Ray;
  60610. /**
  60611. * Disposes of the controller
  60612. */
  60613. dispose(): void;
  60614. }
  60615. /**
  60616. * This class represents a new windows motion controller in XR.
  60617. */
  60618. export class XRWindowsMotionController extends WindowsMotionController {
  60619. /**
  60620. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60621. */
  60622. protected readonly _mapping: {
  60623. buttons: string[];
  60624. buttonMeshNames: {
  60625. trigger: string;
  60626. menu: string;
  60627. grip: string;
  60628. thumbstick: string;
  60629. trackpad: string;
  60630. };
  60631. buttonObservableNames: {
  60632. trigger: string;
  60633. menu: string;
  60634. grip: string;
  60635. thumbstick: string;
  60636. trackpad: string;
  60637. };
  60638. axisMeshNames: string[];
  60639. pointingPoseMeshName: string;
  60640. };
  60641. /**
  60642. * Construct a new XR-Based windows motion controller
  60643. *
  60644. * @param gamepadInfo the gamepad object from the browser
  60645. */
  60646. constructor(gamepadInfo: any);
  60647. /**
  60648. * holds the thumbstick values (X,Y)
  60649. */
  60650. thumbstickValues: StickValues;
  60651. /**
  60652. * Fired when the thumbstick on this controller is clicked
  60653. */
  60654. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60655. /**
  60656. * Fired when the thumbstick on this controller is modified
  60657. */
  60658. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60659. /**
  60660. * Fired when the touchpad button on this controller is modified
  60661. */
  60662. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60663. /**
  60664. * Fired when the touchpad values on this controller are modified
  60665. */
  60666. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60667. /**
  60668. * Fired when the thumbstick button on this controller is modified
  60669. * here to prevent breaking changes
  60670. */
  60671. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60672. /**
  60673. * updating the thumbstick(!) and not the trackpad.
  60674. * This is named this way due to the difference between WebVR and XR and to avoid
  60675. * changing the parent class.
  60676. */
  60677. protected _updateTrackpad(): void;
  60678. /**
  60679. * Disposes the class with joy
  60680. */
  60681. dispose(): void;
  60682. }
  60683. }
  60684. declare module BABYLON {
  60685. /**
  60686. * A directional light is defined by a direction (what a surprise!).
  60687. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60688. * 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.
  60689. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60690. */
  60691. export class DirectionalLight extends ShadowLight {
  60692. private _shadowFrustumSize;
  60693. /**
  60694. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60695. */
  60696. get shadowFrustumSize(): number;
  60697. /**
  60698. * Specifies a fix frustum size for the shadow generation.
  60699. */
  60700. set shadowFrustumSize(value: number);
  60701. private _shadowOrthoScale;
  60702. /**
  60703. * Gets the shadow projection scale against the optimal computed one.
  60704. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60705. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60706. */
  60707. get shadowOrthoScale(): number;
  60708. /**
  60709. * Sets the shadow projection scale against the optimal computed one.
  60710. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60711. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60712. */
  60713. set shadowOrthoScale(value: number);
  60714. /**
  60715. * Automatically compute the projection matrix to best fit (including all the casters)
  60716. * on each frame.
  60717. */
  60718. autoUpdateExtends: boolean;
  60719. /**
  60720. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60721. * on each frame. autoUpdateExtends must be set to true for this to work
  60722. */
  60723. autoCalcShadowZBounds: boolean;
  60724. private _orthoLeft;
  60725. private _orthoRight;
  60726. private _orthoTop;
  60727. private _orthoBottom;
  60728. /**
  60729. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60730. * The directional light is emitted from everywhere in the given direction.
  60731. * It can cast shadows.
  60732. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60733. * @param name The friendly name of the light
  60734. * @param direction The direction of the light
  60735. * @param scene The scene the light belongs to
  60736. */
  60737. constructor(name: string, direction: Vector3, scene: Scene);
  60738. /**
  60739. * Returns the string "DirectionalLight".
  60740. * @return The class name
  60741. */
  60742. getClassName(): string;
  60743. /**
  60744. * Returns the integer 1.
  60745. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60746. */
  60747. getTypeID(): number;
  60748. /**
  60749. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60750. * Returns the DirectionalLight Shadow projection matrix.
  60751. */
  60752. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60753. /**
  60754. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60755. * Returns the DirectionalLight Shadow projection matrix.
  60756. */
  60757. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60758. /**
  60759. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60760. * Returns the DirectionalLight Shadow projection matrix.
  60761. */
  60762. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60763. protected _buildUniformLayout(): void;
  60764. /**
  60765. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60766. * @param effect The effect to update
  60767. * @param lightIndex The index of the light in the effect to update
  60768. * @returns The directional light
  60769. */
  60770. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60771. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60772. /**
  60773. * Gets the minZ used for shadow according to both the scene and the light.
  60774. *
  60775. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60776. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60777. * @param activeCamera The camera we are returning the min for
  60778. * @returns the depth min z
  60779. */
  60780. getDepthMinZ(activeCamera: Camera): number;
  60781. /**
  60782. * Gets the maxZ used for shadow according to both the scene and the light.
  60783. *
  60784. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60785. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60786. * @param activeCamera The camera we are returning the max for
  60787. * @returns the depth max z
  60788. */
  60789. getDepthMaxZ(activeCamera: Camera): number;
  60790. /**
  60791. * Prepares the list of defines specific to the light type.
  60792. * @param defines the list of defines
  60793. * @param lightIndex defines the index of the light for the effect
  60794. */
  60795. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60796. }
  60797. }
  60798. declare module BABYLON {
  60799. /**
  60800. * Class containing static functions to help procedurally build meshes
  60801. */
  60802. export class HemisphereBuilder {
  60803. /**
  60804. * Creates a hemisphere mesh
  60805. * @param name defines the name of the mesh
  60806. * @param options defines the options used to create the mesh
  60807. * @param scene defines the hosting scene
  60808. * @returns the hemisphere mesh
  60809. */
  60810. static CreateHemisphere(name: string, options: {
  60811. segments?: number;
  60812. diameter?: number;
  60813. sideOrientation?: number;
  60814. }, scene: any): Mesh;
  60815. }
  60816. }
  60817. declare module BABYLON {
  60818. /**
  60819. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60820. * These values define a cone of light starting from the position, emitting toward the direction.
  60821. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60822. * and the exponent defines the speed of the decay of the light with distance (reach).
  60823. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60824. */
  60825. export class SpotLight extends ShadowLight {
  60826. private _angle;
  60827. private _innerAngle;
  60828. private _cosHalfAngle;
  60829. private _lightAngleScale;
  60830. private _lightAngleOffset;
  60831. /**
  60832. * Gets the cone angle of the spot light in Radians.
  60833. */
  60834. get angle(): number;
  60835. /**
  60836. * Sets the cone angle of the spot light in Radians.
  60837. */
  60838. set angle(value: number);
  60839. /**
  60840. * Only used in gltf falloff mode, this defines the angle where
  60841. * the directional falloff will start before cutting at angle which could be seen
  60842. * as outer angle.
  60843. */
  60844. get innerAngle(): number;
  60845. /**
  60846. * Only used in gltf falloff mode, this defines the angle where
  60847. * the directional falloff will start before cutting at angle which could be seen
  60848. * as outer angle.
  60849. */
  60850. set innerAngle(value: number);
  60851. private _shadowAngleScale;
  60852. /**
  60853. * Allows scaling the angle of the light for shadow generation only.
  60854. */
  60855. get shadowAngleScale(): number;
  60856. /**
  60857. * Allows scaling the angle of the light for shadow generation only.
  60858. */
  60859. set shadowAngleScale(value: number);
  60860. /**
  60861. * The light decay speed with the distance from the emission spot.
  60862. */
  60863. exponent: number;
  60864. private _projectionTextureMatrix;
  60865. /**
  60866. * Allows reading the projecton texture
  60867. */
  60868. get projectionTextureMatrix(): Matrix;
  60869. protected _projectionTextureLightNear: number;
  60870. /**
  60871. * Gets the near clip of the Spotlight for texture projection.
  60872. */
  60873. get projectionTextureLightNear(): number;
  60874. /**
  60875. * Sets the near clip of the Spotlight for texture projection.
  60876. */
  60877. set projectionTextureLightNear(value: number);
  60878. protected _projectionTextureLightFar: number;
  60879. /**
  60880. * Gets the far clip of the Spotlight for texture projection.
  60881. */
  60882. get projectionTextureLightFar(): number;
  60883. /**
  60884. * Sets the far clip of the Spotlight for texture projection.
  60885. */
  60886. set projectionTextureLightFar(value: number);
  60887. protected _projectionTextureUpDirection: Vector3;
  60888. /**
  60889. * Gets the Up vector of the Spotlight for texture projection.
  60890. */
  60891. get projectionTextureUpDirection(): Vector3;
  60892. /**
  60893. * Sets the Up vector of the Spotlight for texture projection.
  60894. */
  60895. set projectionTextureUpDirection(value: Vector3);
  60896. private _projectionTexture;
  60897. /**
  60898. * Gets the projection texture of the light.
  60899. */
  60900. get projectionTexture(): Nullable<BaseTexture>;
  60901. /**
  60902. * Sets the projection texture of the light.
  60903. */
  60904. set projectionTexture(value: Nullable<BaseTexture>);
  60905. private static _IsProceduralTexture;
  60906. private static _IsTexture;
  60907. private _projectionTextureViewLightDirty;
  60908. private _projectionTextureProjectionLightDirty;
  60909. private _projectionTextureDirty;
  60910. private _projectionTextureViewTargetVector;
  60911. private _projectionTextureViewLightMatrix;
  60912. private _projectionTextureProjectionLightMatrix;
  60913. private _projectionTextureScalingMatrix;
  60914. /**
  60915. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60916. * It can cast shadows.
  60917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60918. * @param name The light friendly name
  60919. * @param position The position of the spot light in the scene
  60920. * @param direction The direction of the light in the scene
  60921. * @param angle The cone angle of the light in Radians
  60922. * @param exponent The light decay speed with the distance from the emission spot
  60923. * @param scene The scene the lights belongs to
  60924. */
  60925. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60926. /**
  60927. * Returns the string "SpotLight".
  60928. * @returns the class name
  60929. */
  60930. getClassName(): string;
  60931. /**
  60932. * Returns the integer 2.
  60933. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60934. */
  60935. getTypeID(): number;
  60936. /**
  60937. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60938. */
  60939. protected _setDirection(value: Vector3): void;
  60940. /**
  60941. * Overrides the position setter to recompute the projection texture view light Matrix.
  60942. */
  60943. protected _setPosition(value: Vector3): void;
  60944. /**
  60945. * 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.
  60946. * Returns the SpotLight.
  60947. */
  60948. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60949. protected _computeProjectionTextureViewLightMatrix(): void;
  60950. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60951. /**
  60952. * Main function for light texture projection matrix computing.
  60953. */
  60954. protected _computeProjectionTextureMatrix(): void;
  60955. protected _buildUniformLayout(): void;
  60956. private _computeAngleValues;
  60957. /**
  60958. * Sets the passed Effect "effect" with the Light textures.
  60959. * @param effect The effect to update
  60960. * @param lightIndex The index of the light in the effect to update
  60961. * @returns The light
  60962. */
  60963. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60964. /**
  60965. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60966. * @param effect The effect to update
  60967. * @param lightIndex The index of the light in the effect to update
  60968. * @returns The spot light
  60969. */
  60970. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60971. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60972. /**
  60973. * Disposes the light and the associated resources.
  60974. */
  60975. dispose(): void;
  60976. /**
  60977. * Prepares the list of defines specific to the light type.
  60978. * @param defines the list of defines
  60979. * @param lightIndex defines the index of the light for the effect
  60980. */
  60981. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60982. }
  60983. }
  60984. declare module BABYLON {
  60985. /**
  60986. * Gizmo that enables viewing a light
  60987. */
  60988. export class LightGizmo extends Gizmo {
  60989. private _lightMesh;
  60990. private _material;
  60991. private _cachedPosition;
  60992. private _cachedForward;
  60993. private _attachedMeshParent;
  60994. private _pointerObserver;
  60995. /**
  60996. * Event that fires each time the gizmo is clicked
  60997. */
  60998. onClickedObservable: Observable<Light>;
  60999. /**
  61000. * Creates a LightGizmo
  61001. * @param gizmoLayer The utility layer the gizmo will be added to
  61002. */
  61003. constructor(gizmoLayer?: UtilityLayerRenderer);
  61004. private _light;
  61005. /**
  61006. * The light that the gizmo is attached to
  61007. */
  61008. set light(light: Nullable<Light>);
  61009. get light(): Nullable<Light>;
  61010. /**
  61011. * Gets the material used to render the light gizmo
  61012. */
  61013. get material(): StandardMaterial;
  61014. /**
  61015. * @hidden
  61016. * Updates the gizmo to match the attached mesh's position/rotation
  61017. */
  61018. protected _update(): void;
  61019. private static _Scale;
  61020. /**
  61021. * Creates the lines for a light mesh
  61022. */
  61023. private static _CreateLightLines;
  61024. /**
  61025. * Disposes of the light gizmo
  61026. */
  61027. dispose(): void;
  61028. private static _CreateHemisphericLightMesh;
  61029. private static _CreatePointLightMesh;
  61030. private static _CreateSpotLightMesh;
  61031. private static _CreateDirectionalLightMesh;
  61032. }
  61033. }
  61034. declare module BABYLON {
  61035. /**
  61036. * Gizmo that enables viewing a camera
  61037. */
  61038. export class CameraGizmo extends Gizmo {
  61039. private _cameraMesh;
  61040. private _cameraLinesMesh;
  61041. private _material;
  61042. private _pointerObserver;
  61043. /**
  61044. * Event that fires each time the gizmo is clicked
  61045. */
  61046. onClickedObservable: Observable<Camera>;
  61047. /**
  61048. * Creates a CameraGizmo
  61049. * @param gizmoLayer The utility layer the gizmo will be added to
  61050. */
  61051. constructor(gizmoLayer?: UtilityLayerRenderer);
  61052. private _camera;
  61053. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61054. get displayFrustum(): boolean;
  61055. set displayFrustum(value: boolean);
  61056. /**
  61057. * The camera that the gizmo is attached to
  61058. */
  61059. set camera(camera: Nullable<Camera>);
  61060. get camera(): Nullable<Camera>;
  61061. /**
  61062. * Gets the material used to render the camera gizmo
  61063. */
  61064. get material(): StandardMaterial;
  61065. /**
  61066. * @hidden
  61067. * Updates the gizmo to match the attached mesh's position/rotation
  61068. */
  61069. protected _update(): void;
  61070. private static _Scale;
  61071. private _invProjection;
  61072. /**
  61073. * Disposes of the camera gizmo
  61074. */
  61075. dispose(): void;
  61076. private static _CreateCameraMesh;
  61077. private static _CreateCameraFrustum;
  61078. }
  61079. }
  61080. declare module BABYLON {
  61081. /** @hidden */
  61082. export var backgroundFragmentDeclaration: {
  61083. name: string;
  61084. shader: string;
  61085. };
  61086. }
  61087. declare module BABYLON {
  61088. /** @hidden */
  61089. export var backgroundUboDeclaration: {
  61090. name: string;
  61091. shader: string;
  61092. };
  61093. }
  61094. declare module BABYLON {
  61095. /** @hidden */
  61096. export var backgroundPixelShader: {
  61097. name: string;
  61098. shader: string;
  61099. };
  61100. }
  61101. declare module BABYLON {
  61102. /** @hidden */
  61103. export var backgroundVertexDeclaration: {
  61104. name: string;
  61105. shader: string;
  61106. };
  61107. }
  61108. declare module BABYLON {
  61109. /** @hidden */
  61110. export var backgroundVertexShader: {
  61111. name: string;
  61112. shader: string;
  61113. };
  61114. }
  61115. declare module BABYLON {
  61116. /**
  61117. * Background material used to create an efficient environement around your scene.
  61118. */
  61119. export class BackgroundMaterial extends PushMaterial {
  61120. /**
  61121. * Standard reflectance value at parallel view angle.
  61122. */
  61123. static StandardReflectance0: number;
  61124. /**
  61125. * Standard reflectance value at grazing angle.
  61126. */
  61127. static StandardReflectance90: number;
  61128. protected _primaryColor: Color3;
  61129. /**
  61130. * Key light Color (multiply against the environement texture)
  61131. */
  61132. primaryColor: Color3;
  61133. protected __perceptualColor: Nullable<Color3>;
  61134. /**
  61135. * Experimental Internal Use Only.
  61136. *
  61137. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61138. * This acts as a helper to set the primary color to a more "human friendly" value.
  61139. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61140. * output color as close as possible from the chosen value.
  61141. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61142. * part of lighting setup.)
  61143. */
  61144. get _perceptualColor(): Nullable<Color3>;
  61145. set _perceptualColor(value: Nullable<Color3>);
  61146. protected _primaryColorShadowLevel: float;
  61147. /**
  61148. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61149. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61150. */
  61151. get primaryColorShadowLevel(): float;
  61152. set primaryColorShadowLevel(value: float);
  61153. protected _primaryColorHighlightLevel: float;
  61154. /**
  61155. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  61156. * The primary color is used at the level chosen to define what the white area would look.
  61157. */
  61158. get primaryColorHighlightLevel(): float;
  61159. set primaryColorHighlightLevel(value: float);
  61160. protected _reflectionTexture: Nullable<BaseTexture>;
  61161. /**
  61162. * Reflection Texture used in the material.
  61163. * Should be author in a specific way for the best result (refer to the documentation).
  61164. */
  61165. reflectionTexture: Nullable<BaseTexture>;
  61166. protected _reflectionBlur: float;
  61167. /**
  61168. * Reflection Texture level of blur.
  61169. *
  61170. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61171. * texture twice.
  61172. */
  61173. reflectionBlur: float;
  61174. protected _diffuseTexture: Nullable<BaseTexture>;
  61175. /**
  61176. * Diffuse Texture used in the material.
  61177. * Should be author in a specific way for the best result (refer to the documentation).
  61178. */
  61179. diffuseTexture: Nullable<BaseTexture>;
  61180. protected _shadowLights: Nullable<IShadowLight[]>;
  61181. /**
  61182. * Specify the list of lights casting shadow on the material.
  61183. * All scene shadow lights will be included if null.
  61184. */
  61185. shadowLights: Nullable<IShadowLight[]>;
  61186. protected _shadowLevel: float;
  61187. /**
  61188. * Helps adjusting the shadow to a softer level if required.
  61189. * 0 means black shadows and 1 means no shadows.
  61190. */
  61191. shadowLevel: float;
  61192. protected _sceneCenter: Vector3;
  61193. /**
  61194. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61195. * It is usually zero but might be interesting to modify according to your setup.
  61196. */
  61197. sceneCenter: Vector3;
  61198. protected _opacityFresnel: boolean;
  61199. /**
  61200. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61201. * This helps ensuring a nice transition when the camera goes under the ground.
  61202. */
  61203. opacityFresnel: boolean;
  61204. protected _reflectionFresnel: boolean;
  61205. /**
  61206. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61207. * This helps adding a mirror texture on the ground.
  61208. */
  61209. reflectionFresnel: boolean;
  61210. protected _reflectionFalloffDistance: number;
  61211. /**
  61212. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61213. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61214. */
  61215. reflectionFalloffDistance: number;
  61216. protected _reflectionAmount: number;
  61217. /**
  61218. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61219. */
  61220. reflectionAmount: number;
  61221. protected _reflectionReflectance0: number;
  61222. /**
  61223. * This specifies the weight of the reflection at grazing angle.
  61224. */
  61225. reflectionReflectance0: number;
  61226. protected _reflectionReflectance90: number;
  61227. /**
  61228. * This specifies the weight of the reflection at a perpendicular point of view.
  61229. */
  61230. reflectionReflectance90: number;
  61231. /**
  61232. * Sets the reflection reflectance fresnel values according to the default standard
  61233. * empirically know to work well :-)
  61234. */
  61235. set reflectionStandardFresnelWeight(value: number);
  61236. protected _useRGBColor: boolean;
  61237. /**
  61238. * Helps to directly use the maps channels instead of their level.
  61239. */
  61240. useRGBColor: boolean;
  61241. protected _enableNoise: boolean;
  61242. /**
  61243. * This helps reducing the banding effect that could occur on the background.
  61244. */
  61245. enableNoise: boolean;
  61246. /**
  61247. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61248. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61249. * Recommended to be keep at 1.0 except for special cases.
  61250. */
  61251. get fovMultiplier(): number;
  61252. set fovMultiplier(value: number);
  61253. private _fovMultiplier;
  61254. /**
  61255. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61256. */
  61257. useEquirectangularFOV: boolean;
  61258. private _maxSimultaneousLights;
  61259. /**
  61260. * Number of Simultaneous lights allowed on the material.
  61261. */
  61262. maxSimultaneousLights: int;
  61263. private _shadowOnly;
  61264. /**
  61265. * Make the material only render shadows
  61266. */
  61267. shadowOnly: boolean;
  61268. /**
  61269. * Default configuration related to image processing available in the Background Material.
  61270. */
  61271. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61272. /**
  61273. * Keep track of the image processing observer to allow dispose and replace.
  61274. */
  61275. private _imageProcessingObserver;
  61276. /**
  61277. * Attaches a new image processing configuration to the PBR Material.
  61278. * @param configuration (if null the scene configuration will be use)
  61279. */
  61280. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61281. /**
  61282. * Gets the image processing configuration used either in this material.
  61283. */
  61284. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61285. /**
  61286. * Sets the Default image processing configuration used either in the this material.
  61287. *
  61288. * If sets to null, the scene one is in use.
  61289. */
  61290. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61291. /**
  61292. * Gets wether the color curves effect is enabled.
  61293. */
  61294. get cameraColorCurvesEnabled(): boolean;
  61295. /**
  61296. * Sets wether the color curves effect is enabled.
  61297. */
  61298. set cameraColorCurvesEnabled(value: boolean);
  61299. /**
  61300. * Gets wether the color grading effect is enabled.
  61301. */
  61302. get cameraColorGradingEnabled(): boolean;
  61303. /**
  61304. * Gets wether the color grading effect is enabled.
  61305. */
  61306. set cameraColorGradingEnabled(value: boolean);
  61307. /**
  61308. * Gets wether tonemapping is enabled or not.
  61309. */
  61310. get cameraToneMappingEnabled(): boolean;
  61311. /**
  61312. * Sets wether tonemapping is enabled or not
  61313. */
  61314. set cameraToneMappingEnabled(value: boolean);
  61315. /**
  61316. * The camera exposure used on this material.
  61317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61318. * This corresponds to a photographic exposure.
  61319. */
  61320. get cameraExposure(): float;
  61321. /**
  61322. * The camera exposure used on this material.
  61323. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61324. * This corresponds to a photographic exposure.
  61325. */
  61326. set cameraExposure(value: float);
  61327. /**
  61328. * Gets The camera contrast used on this material.
  61329. */
  61330. get cameraContrast(): float;
  61331. /**
  61332. * Sets The camera contrast used on this material.
  61333. */
  61334. set cameraContrast(value: float);
  61335. /**
  61336. * Gets the Color Grading 2D Lookup Texture.
  61337. */
  61338. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61339. /**
  61340. * Sets the Color Grading 2D Lookup Texture.
  61341. */
  61342. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61343. /**
  61344. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61345. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61346. * 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;
  61347. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61348. */
  61349. get cameraColorCurves(): Nullable<ColorCurves>;
  61350. /**
  61351. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61352. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61353. * 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;
  61354. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61355. */
  61356. set cameraColorCurves(value: Nullable<ColorCurves>);
  61357. /**
  61358. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61359. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61360. */
  61361. switchToBGR: boolean;
  61362. private _renderTargets;
  61363. private _reflectionControls;
  61364. private _white;
  61365. private _primaryShadowColor;
  61366. private _primaryHighlightColor;
  61367. /**
  61368. * Instantiates a Background Material in the given scene
  61369. * @param name The friendly name of the material
  61370. * @param scene The scene to add the material to
  61371. */
  61372. constructor(name: string, scene: Scene);
  61373. /**
  61374. * Gets a boolean indicating that current material needs to register RTT
  61375. */
  61376. get hasRenderTargetTextures(): boolean;
  61377. /**
  61378. * The entire material has been created in order to prevent overdraw.
  61379. * @returns false
  61380. */
  61381. needAlphaTesting(): boolean;
  61382. /**
  61383. * The entire material has been created in order to prevent overdraw.
  61384. * @returns true if blending is enable
  61385. */
  61386. needAlphaBlending(): boolean;
  61387. /**
  61388. * Checks wether the material is ready to be rendered for a given mesh.
  61389. * @param mesh The mesh to render
  61390. * @param subMesh The submesh to check against
  61391. * @param useInstances Specify wether or not the material is used with instances
  61392. * @returns true if all the dependencies are ready (Textures, Effects...)
  61393. */
  61394. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61395. /**
  61396. * Compute the primary color according to the chosen perceptual color.
  61397. */
  61398. private _computePrimaryColorFromPerceptualColor;
  61399. /**
  61400. * Compute the highlights and shadow colors according to their chosen levels.
  61401. */
  61402. private _computePrimaryColors;
  61403. /**
  61404. * Build the uniform buffer used in the material.
  61405. */
  61406. buildUniformLayout(): void;
  61407. /**
  61408. * Unbind the material.
  61409. */
  61410. unbind(): void;
  61411. /**
  61412. * Bind only the world matrix to the material.
  61413. * @param world The world matrix to bind.
  61414. */
  61415. bindOnlyWorldMatrix(world: Matrix): void;
  61416. /**
  61417. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61418. * @param world The world matrix to bind.
  61419. * @param subMesh The submesh to bind for.
  61420. */
  61421. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61422. /**
  61423. * Checks to see if a texture is used in the material.
  61424. * @param texture - Base texture to use.
  61425. * @returns - Boolean specifying if a texture is used in the material.
  61426. */
  61427. hasTexture(texture: BaseTexture): boolean;
  61428. /**
  61429. * Dispose the material.
  61430. * @param forceDisposeEffect Force disposal of the associated effect.
  61431. * @param forceDisposeTextures Force disposal of the associated textures.
  61432. */
  61433. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61434. /**
  61435. * Clones the material.
  61436. * @param name The cloned name.
  61437. * @returns The cloned material.
  61438. */
  61439. clone(name: string): BackgroundMaterial;
  61440. /**
  61441. * Serializes the current material to its JSON representation.
  61442. * @returns The JSON representation.
  61443. */
  61444. serialize(): any;
  61445. /**
  61446. * Gets the class name of the material
  61447. * @returns "BackgroundMaterial"
  61448. */
  61449. getClassName(): string;
  61450. /**
  61451. * Parse a JSON input to create back a background material.
  61452. * @param source The JSON data to parse
  61453. * @param scene The scene to create the parsed material in
  61454. * @param rootUrl The root url of the assets the material depends upon
  61455. * @returns the instantiated BackgroundMaterial.
  61456. */
  61457. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61458. }
  61459. }
  61460. declare module BABYLON {
  61461. /**
  61462. * Represents the different options available during the creation of
  61463. * a Environment helper.
  61464. *
  61465. * This can control the default ground, skybox and image processing setup of your scene.
  61466. */
  61467. export interface IEnvironmentHelperOptions {
  61468. /**
  61469. * Specifies whether or not to create a ground.
  61470. * True by default.
  61471. */
  61472. createGround: boolean;
  61473. /**
  61474. * Specifies the ground size.
  61475. * 15 by default.
  61476. */
  61477. groundSize: number;
  61478. /**
  61479. * The texture used on the ground for the main color.
  61480. * Comes from the BabylonJS CDN by default.
  61481. *
  61482. * Remarks: Can be either a texture or a url.
  61483. */
  61484. groundTexture: string | BaseTexture;
  61485. /**
  61486. * The color mixed in the ground texture by default.
  61487. * BabylonJS clearColor by default.
  61488. */
  61489. groundColor: Color3;
  61490. /**
  61491. * Specifies the ground opacity.
  61492. * 1 by default.
  61493. */
  61494. groundOpacity: number;
  61495. /**
  61496. * Enables the ground to receive shadows.
  61497. * True by default.
  61498. */
  61499. enableGroundShadow: boolean;
  61500. /**
  61501. * Helps preventing the shadow to be fully black on the ground.
  61502. * 0.5 by default.
  61503. */
  61504. groundShadowLevel: number;
  61505. /**
  61506. * Creates a mirror texture attach to the ground.
  61507. * false by default.
  61508. */
  61509. enableGroundMirror: boolean;
  61510. /**
  61511. * Specifies the ground mirror size ratio.
  61512. * 0.3 by default as the default kernel is 64.
  61513. */
  61514. groundMirrorSizeRatio: number;
  61515. /**
  61516. * Specifies the ground mirror blur kernel size.
  61517. * 64 by default.
  61518. */
  61519. groundMirrorBlurKernel: number;
  61520. /**
  61521. * Specifies the ground mirror visibility amount.
  61522. * 1 by default
  61523. */
  61524. groundMirrorAmount: number;
  61525. /**
  61526. * Specifies the ground mirror reflectance weight.
  61527. * This uses the standard weight of the background material to setup the fresnel effect
  61528. * of the mirror.
  61529. * 1 by default.
  61530. */
  61531. groundMirrorFresnelWeight: number;
  61532. /**
  61533. * Specifies the ground mirror Falloff distance.
  61534. * This can helps reducing the size of the reflection.
  61535. * 0 by Default.
  61536. */
  61537. groundMirrorFallOffDistance: number;
  61538. /**
  61539. * Specifies the ground mirror texture type.
  61540. * Unsigned Int by Default.
  61541. */
  61542. groundMirrorTextureType: number;
  61543. /**
  61544. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61545. * the shown objects.
  61546. */
  61547. groundYBias: number;
  61548. /**
  61549. * Specifies whether or not to create a skybox.
  61550. * True by default.
  61551. */
  61552. createSkybox: boolean;
  61553. /**
  61554. * Specifies the skybox size.
  61555. * 20 by default.
  61556. */
  61557. skyboxSize: number;
  61558. /**
  61559. * The texture used on the skybox for the main color.
  61560. * Comes from the BabylonJS CDN by default.
  61561. *
  61562. * Remarks: Can be either a texture or a url.
  61563. */
  61564. skyboxTexture: string | BaseTexture;
  61565. /**
  61566. * The color mixed in the skybox texture by default.
  61567. * BabylonJS clearColor by default.
  61568. */
  61569. skyboxColor: Color3;
  61570. /**
  61571. * The background rotation around the Y axis of the scene.
  61572. * This helps aligning the key lights of your scene with the background.
  61573. * 0 by default.
  61574. */
  61575. backgroundYRotation: number;
  61576. /**
  61577. * Compute automatically the size of the elements to best fit with the scene.
  61578. */
  61579. sizeAuto: boolean;
  61580. /**
  61581. * Default position of the rootMesh if autoSize is not true.
  61582. */
  61583. rootPosition: Vector3;
  61584. /**
  61585. * Sets up the image processing in the scene.
  61586. * true by default.
  61587. */
  61588. setupImageProcessing: boolean;
  61589. /**
  61590. * The texture used as your environment texture in the scene.
  61591. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61592. *
  61593. * Remarks: Can be either a texture or a url.
  61594. */
  61595. environmentTexture: string | BaseTexture;
  61596. /**
  61597. * The value of the exposure to apply to the scene.
  61598. * 0.6 by default if setupImageProcessing is true.
  61599. */
  61600. cameraExposure: number;
  61601. /**
  61602. * The value of the contrast to apply to the scene.
  61603. * 1.6 by default if setupImageProcessing is true.
  61604. */
  61605. cameraContrast: number;
  61606. /**
  61607. * Specifies whether or not tonemapping should be enabled in the scene.
  61608. * true by default if setupImageProcessing is true.
  61609. */
  61610. toneMappingEnabled: boolean;
  61611. }
  61612. /**
  61613. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61614. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61615. * It also helps with the default setup of your imageProcessing configuration.
  61616. */
  61617. export class EnvironmentHelper {
  61618. /**
  61619. * Default ground texture URL.
  61620. */
  61621. private static _groundTextureCDNUrl;
  61622. /**
  61623. * Default skybox texture URL.
  61624. */
  61625. private static _skyboxTextureCDNUrl;
  61626. /**
  61627. * Default environment texture URL.
  61628. */
  61629. private static _environmentTextureCDNUrl;
  61630. /**
  61631. * Creates the default options for the helper.
  61632. */
  61633. private static _getDefaultOptions;
  61634. private _rootMesh;
  61635. /**
  61636. * Gets the root mesh created by the helper.
  61637. */
  61638. get rootMesh(): Mesh;
  61639. private _skybox;
  61640. /**
  61641. * Gets the skybox created by the helper.
  61642. */
  61643. get skybox(): Nullable<Mesh>;
  61644. private _skyboxTexture;
  61645. /**
  61646. * Gets the skybox texture created by the helper.
  61647. */
  61648. get skyboxTexture(): Nullable<BaseTexture>;
  61649. private _skyboxMaterial;
  61650. /**
  61651. * Gets the skybox material created by the helper.
  61652. */
  61653. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61654. private _ground;
  61655. /**
  61656. * Gets the ground mesh created by the helper.
  61657. */
  61658. get ground(): Nullable<Mesh>;
  61659. private _groundTexture;
  61660. /**
  61661. * Gets the ground texture created by the helper.
  61662. */
  61663. get groundTexture(): Nullable<BaseTexture>;
  61664. private _groundMirror;
  61665. /**
  61666. * Gets the ground mirror created by the helper.
  61667. */
  61668. get groundMirror(): Nullable<MirrorTexture>;
  61669. /**
  61670. * Gets the ground mirror render list to helps pushing the meshes
  61671. * you wish in the ground reflection.
  61672. */
  61673. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61674. private _groundMaterial;
  61675. /**
  61676. * Gets the ground material created by the helper.
  61677. */
  61678. get groundMaterial(): Nullable<BackgroundMaterial>;
  61679. /**
  61680. * Stores the creation options.
  61681. */
  61682. private readonly _scene;
  61683. private _options;
  61684. /**
  61685. * This observable will be notified with any error during the creation of the environment,
  61686. * mainly texture creation errors.
  61687. */
  61688. onErrorObservable: Observable<{
  61689. message?: string;
  61690. exception?: any;
  61691. }>;
  61692. /**
  61693. * constructor
  61694. * @param options Defines the options we want to customize the helper
  61695. * @param scene The scene to add the material to
  61696. */
  61697. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61698. /**
  61699. * Updates the background according to the new options
  61700. * @param options
  61701. */
  61702. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61703. /**
  61704. * Sets the primary color of all the available elements.
  61705. * @param color the main color to affect to the ground and the background
  61706. */
  61707. setMainColor(color: Color3): void;
  61708. /**
  61709. * Setup the image processing according to the specified options.
  61710. */
  61711. private _setupImageProcessing;
  61712. /**
  61713. * Setup the environment texture according to the specified options.
  61714. */
  61715. private _setupEnvironmentTexture;
  61716. /**
  61717. * Setup the background according to the specified options.
  61718. */
  61719. private _setupBackground;
  61720. /**
  61721. * Get the scene sizes according to the setup.
  61722. */
  61723. private _getSceneSize;
  61724. /**
  61725. * Setup the ground according to the specified options.
  61726. */
  61727. private _setupGround;
  61728. /**
  61729. * Setup the ground material according to the specified options.
  61730. */
  61731. private _setupGroundMaterial;
  61732. /**
  61733. * Setup the ground diffuse texture according to the specified options.
  61734. */
  61735. private _setupGroundDiffuseTexture;
  61736. /**
  61737. * Setup the ground mirror texture according to the specified options.
  61738. */
  61739. private _setupGroundMirrorTexture;
  61740. /**
  61741. * Setup the ground to receive the mirror texture.
  61742. */
  61743. private _setupMirrorInGroundMaterial;
  61744. /**
  61745. * Setup the skybox according to the specified options.
  61746. */
  61747. private _setupSkybox;
  61748. /**
  61749. * Setup the skybox material according to the specified options.
  61750. */
  61751. private _setupSkyboxMaterial;
  61752. /**
  61753. * Setup the skybox reflection texture according to the specified options.
  61754. */
  61755. private _setupSkyboxReflectionTexture;
  61756. private _errorHandler;
  61757. /**
  61758. * Dispose all the elements created by the Helper.
  61759. */
  61760. dispose(): void;
  61761. }
  61762. }
  61763. declare module BABYLON {
  61764. /**
  61765. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61766. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61767. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61768. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61769. */
  61770. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61771. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61772. /**
  61773. * Define the source as a Monoscopic panoramic 360/180.
  61774. */
  61775. static readonly MODE_MONOSCOPIC: number;
  61776. /**
  61777. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61778. */
  61779. static readonly MODE_TOPBOTTOM: number;
  61780. /**
  61781. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61782. */
  61783. static readonly MODE_SIDEBYSIDE: number;
  61784. private _halfDome;
  61785. private _crossEye;
  61786. protected _useDirectMapping: boolean;
  61787. /**
  61788. * The texture being displayed on the sphere
  61789. */
  61790. protected _texture: T;
  61791. /**
  61792. * Gets the texture being displayed on the sphere
  61793. */
  61794. get texture(): T;
  61795. /**
  61796. * Sets the texture being displayed on the sphere
  61797. */
  61798. set texture(newTexture: T);
  61799. /**
  61800. * The skybox material
  61801. */
  61802. protected _material: BackgroundMaterial;
  61803. /**
  61804. * The surface used for the dome
  61805. */
  61806. protected _mesh: Mesh;
  61807. /**
  61808. * Gets the mesh used for the dome.
  61809. */
  61810. get mesh(): Mesh;
  61811. /**
  61812. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61813. */
  61814. private _halfDomeMask;
  61815. /**
  61816. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61817. * Also see the options.resolution property.
  61818. */
  61819. get fovMultiplier(): number;
  61820. set fovMultiplier(value: number);
  61821. protected _textureMode: number;
  61822. /**
  61823. * Gets or set the current texture mode for the texture. It can be:
  61824. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61825. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61826. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61827. */
  61828. get textureMode(): number;
  61829. /**
  61830. * Sets the current texture mode for the texture. It can be:
  61831. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61832. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61833. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61834. */
  61835. set textureMode(value: number);
  61836. /**
  61837. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61838. */
  61839. get halfDome(): boolean;
  61840. /**
  61841. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61842. */
  61843. set halfDome(enabled: boolean);
  61844. /**
  61845. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61846. */
  61847. set crossEye(enabled: boolean);
  61848. /**
  61849. * Is it a cross-eye texture?
  61850. */
  61851. get crossEye(): boolean;
  61852. /**
  61853. * The background material of this dome.
  61854. */
  61855. get material(): BackgroundMaterial;
  61856. /**
  61857. * Oberserver used in Stereoscopic VR Mode.
  61858. */
  61859. private _onBeforeCameraRenderObserver;
  61860. /**
  61861. * Observable raised when an error occured while loading the 360 image
  61862. */
  61863. onLoadErrorObservable: Observable<string>;
  61864. /**
  61865. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61866. * @param name Element's name, child elements will append suffixes for their own names.
  61867. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61868. * @param options An object containing optional or exposed sub element properties
  61869. */
  61870. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61871. resolution?: number;
  61872. clickToPlay?: boolean;
  61873. autoPlay?: boolean;
  61874. loop?: boolean;
  61875. size?: number;
  61876. poster?: string;
  61877. faceForward?: boolean;
  61878. useDirectMapping?: boolean;
  61879. halfDomeMode?: boolean;
  61880. crossEyeMode?: boolean;
  61881. generateMipMaps?: boolean;
  61882. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61883. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61884. protected _changeTextureMode(value: number): void;
  61885. /**
  61886. * Releases resources associated with this node.
  61887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61889. */
  61890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61891. }
  61892. }
  61893. declare module BABYLON {
  61894. /**
  61895. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61896. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61897. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61898. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61899. */
  61900. export class PhotoDome extends TextureDome<Texture> {
  61901. /**
  61902. * Define the image as a Monoscopic panoramic 360 image.
  61903. */
  61904. static readonly MODE_MONOSCOPIC: number;
  61905. /**
  61906. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61907. */
  61908. static readonly MODE_TOPBOTTOM: number;
  61909. /**
  61910. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61911. */
  61912. static readonly MODE_SIDEBYSIDE: number;
  61913. /**
  61914. * Gets or sets the texture being displayed on the sphere
  61915. */
  61916. get photoTexture(): Texture;
  61917. /**
  61918. * sets the texture being displayed on the sphere
  61919. */
  61920. set photoTexture(value: Texture);
  61921. /**
  61922. * Gets the current video mode for the video. It can be:
  61923. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61924. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61925. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61926. */
  61927. get imageMode(): number;
  61928. /**
  61929. * Sets the current video mode for the video. It can be:
  61930. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61931. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61932. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61933. */
  61934. set imageMode(value: number);
  61935. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61936. }
  61937. }
  61938. declare module BABYLON {
  61939. /**
  61940. * Direct draw surface info
  61941. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61942. */
  61943. export interface DDSInfo {
  61944. /**
  61945. * Width of the texture
  61946. */
  61947. width: number;
  61948. /**
  61949. * Width of the texture
  61950. */
  61951. height: number;
  61952. /**
  61953. * Number of Mipmaps for the texture
  61954. * @see https://en.wikipedia.org/wiki/Mipmap
  61955. */
  61956. mipmapCount: number;
  61957. /**
  61958. * If the textures format is a known fourCC format
  61959. * @see https://www.fourcc.org/
  61960. */
  61961. isFourCC: boolean;
  61962. /**
  61963. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61964. */
  61965. isRGB: boolean;
  61966. /**
  61967. * If the texture is a lumincance format
  61968. */
  61969. isLuminance: boolean;
  61970. /**
  61971. * If this is a cube texture
  61972. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61973. */
  61974. isCube: boolean;
  61975. /**
  61976. * If the texture is a compressed format eg. FOURCC_DXT1
  61977. */
  61978. isCompressed: boolean;
  61979. /**
  61980. * The dxgiFormat of the texture
  61981. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61982. */
  61983. dxgiFormat: number;
  61984. /**
  61985. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61986. */
  61987. textureType: number;
  61988. /**
  61989. * Sphericle polynomial created for the dds texture
  61990. */
  61991. sphericalPolynomial?: SphericalPolynomial;
  61992. }
  61993. /**
  61994. * Class used to provide DDS decompression tools
  61995. */
  61996. export class DDSTools {
  61997. /**
  61998. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61999. */
  62000. static StoreLODInAlphaChannel: boolean;
  62001. /**
  62002. * Gets DDS information from an array buffer
  62003. * @param data defines the array buffer view to read data from
  62004. * @returns the DDS information
  62005. */
  62006. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62007. private static _FloatView;
  62008. private static _Int32View;
  62009. private static _ToHalfFloat;
  62010. private static _FromHalfFloat;
  62011. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62012. private static _GetHalfFloatRGBAArrayBuffer;
  62013. private static _GetFloatRGBAArrayBuffer;
  62014. private static _GetFloatAsUIntRGBAArrayBuffer;
  62015. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62016. private static _GetRGBAArrayBuffer;
  62017. private static _ExtractLongWordOrder;
  62018. private static _GetRGBArrayBuffer;
  62019. private static _GetLuminanceArrayBuffer;
  62020. /**
  62021. * Uploads DDS Levels to a Babylon Texture
  62022. * @hidden
  62023. */
  62024. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62025. }
  62026. interface ThinEngine {
  62027. /**
  62028. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62029. * @param rootUrl defines the url where the file to load is located
  62030. * @param scene defines the current scene
  62031. * @param lodScale defines scale to apply to the mip map selection
  62032. * @param lodOffset defines offset to apply to the mip map selection
  62033. * @param onLoad defines an optional callback raised when the texture is loaded
  62034. * @param onError defines an optional callback raised if there is an issue to load the texture
  62035. * @param format defines the format of the data
  62036. * @param forcedExtension defines the extension to use to pick the right loader
  62037. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62038. * @returns the cube texture as an InternalTexture
  62039. */
  62040. 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;
  62041. }
  62042. }
  62043. declare module BABYLON {
  62044. /**
  62045. * Implementation of the DDS Texture Loader.
  62046. * @hidden
  62047. */
  62048. export class _DDSTextureLoader implements IInternalTextureLoader {
  62049. /**
  62050. * Defines wether the loader supports cascade loading the different faces.
  62051. */
  62052. readonly supportCascades: boolean;
  62053. /**
  62054. * This returns if the loader support the current file information.
  62055. * @param extension defines the file extension of the file being loaded
  62056. * @returns true if the loader can load the specified file
  62057. */
  62058. canLoad(extension: string): boolean;
  62059. /**
  62060. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62061. * @param data contains the texture data
  62062. * @param texture defines the BabylonJS internal texture
  62063. * @param createPolynomials will be true if polynomials have been requested
  62064. * @param onLoad defines the callback to trigger once the texture is ready
  62065. * @param onError defines the callback to trigger in case of error
  62066. */
  62067. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62068. /**
  62069. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62070. * @param data contains the texture data
  62071. * @param texture defines the BabylonJS internal texture
  62072. * @param callback defines the method to call once ready to upload
  62073. */
  62074. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62075. }
  62076. }
  62077. declare module BABYLON {
  62078. /**
  62079. * Implementation of the ENV Texture Loader.
  62080. * @hidden
  62081. */
  62082. export class _ENVTextureLoader implements IInternalTextureLoader {
  62083. /**
  62084. * Defines wether the loader supports cascade loading the different faces.
  62085. */
  62086. readonly supportCascades: boolean;
  62087. /**
  62088. * This returns if the loader support the current file information.
  62089. * @param extension defines the file extension of the file being loaded
  62090. * @returns true if the loader can load the specified file
  62091. */
  62092. canLoad(extension: string): boolean;
  62093. /**
  62094. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62095. * @param data contains the texture data
  62096. * @param texture defines the BabylonJS internal texture
  62097. * @param createPolynomials will be true if polynomials have been requested
  62098. * @param onLoad defines the callback to trigger once the texture is ready
  62099. * @param onError defines the callback to trigger in case of error
  62100. */
  62101. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62102. /**
  62103. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62104. * @param data contains the texture data
  62105. * @param texture defines the BabylonJS internal texture
  62106. * @param callback defines the method to call once ready to upload
  62107. */
  62108. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62109. }
  62110. }
  62111. declare module BABYLON {
  62112. /**
  62113. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62114. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62115. */
  62116. export class KhronosTextureContainer {
  62117. /** contents of the KTX container file */
  62118. data: ArrayBufferView;
  62119. private static HEADER_LEN;
  62120. private static COMPRESSED_2D;
  62121. private static COMPRESSED_3D;
  62122. private static TEX_2D;
  62123. private static TEX_3D;
  62124. /**
  62125. * Gets the openGL type
  62126. */
  62127. glType: number;
  62128. /**
  62129. * Gets the openGL type size
  62130. */
  62131. glTypeSize: number;
  62132. /**
  62133. * Gets the openGL format
  62134. */
  62135. glFormat: number;
  62136. /**
  62137. * Gets the openGL internal format
  62138. */
  62139. glInternalFormat: number;
  62140. /**
  62141. * Gets the base internal format
  62142. */
  62143. glBaseInternalFormat: number;
  62144. /**
  62145. * Gets image width in pixel
  62146. */
  62147. pixelWidth: number;
  62148. /**
  62149. * Gets image height in pixel
  62150. */
  62151. pixelHeight: number;
  62152. /**
  62153. * Gets image depth in pixels
  62154. */
  62155. pixelDepth: number;
  62156. /**
  62157. * Gets the number of array elements
  62158. */
  62159. numberOfArrayElements: number;
  62160. /**
  62161. * Gets the number of faces
  62162. */
  62163. numberOfFaces: number;
  62164. /**
  62165. * Gets the number of mipmap levels
  62166. */
  62167. numberOfMipmapLevels: number;
  62168. /**
  62169. * Gets the bytes of key value data
  62170. */
  62171. bytesOfKeyValueData: number;
  62172. /**
  62173. * Gets the load type
  62174. */
  62175. loadType: number;
  62176. /**
  62177. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62178. */
  62179. isInvalid: boolean;
  62180. /**
  62181. * Creates a new KhronosTextureContainer
  62182. * @param data contents of the KTX container file
  62183. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62184. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62185. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62186. */
  62187. constructor(
  62188. /** contents of the KTX container file */
  62189. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62190. /**
  62191. * Uploads KTX content to a Babylon Texture.
  62192. * It is assumed that the texture has already been created & is currently bound
  62193. * @hidden
  62194. */
  62195. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62196. private _upload2DCompressedLevels;
  62197. /**
  62198. * Checks if the given data starts with a KTX file identifier.
  62199. * @param data the data to check
  62200. * @returns true if the data is a KTX file or false otherwise
  62201. */
  62202. static IsValid(data: ArrayBufferView): boolean;
  62203. }
  62204. }
  62205. declare module BABYLON {
  62206. /**
  62207. * Helper class to push actions to a pool of workers.
  62208. */
  62209. export class WorkerPool implements IDisposable {
  62210. private _workerInfos;
  62211. private _pendingActions;
  62212. /**
  62213. * Constructor
  62214. * @param workers Array of workers to use for actions
  62215. */
  62216. constructor(workers: Array<Worker>);
  62217. /**
  62218. * Terminates all workers and clears any pending actions.
  62219. */
  62220. dispose(): void;
  62221. /**
  62222. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62223. * pended until a worker has completed its action.
  62224. * @param action The action to perform. Call onComplete when the action is complete.
  62225. */
  62226. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62227. private _execute;
  62228. }
  62229. }
  62230. declare module BABYLON {
  62231. /**
  62232. * Class for loading KTX2 files
  62233. */
  62234. export class KhronosTextureContainer2 {
  62235. private static _WorkerPoolPromise?;
  62236. private static _Initialized;
  62237. private static _Ktx2Decoder;
  62238. /**
  62239. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62240. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62241. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62242. * Urls you can change:
  62243. * URLConfig.jsDecoderModule
  62244. * URLConfig.wasmUASTCToASTC
  62245. * URLConfig.wasmUASTCToBC7
  62246. * URLConfig.wasmUASTCToRGBA_UNORM
  62247. * URLConfig.wasmUASTCToRGBA_SRGB
  62248. * URLConfig.jsMSCTranscoder
  62249. * URLConfig.wasmMSCTranscoder
  62250. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62251. */
  62252. static URLConfig: {
  62253. jsDecoderModule: string;
  62254. wasmUASTCToASTC: null;
  62255. wasmUASTCToBC7: null;
  62256. wasmUASTCToRGBA_UNORM: null;
  62257. wasmUASTCToRGBA_SRGB: null;
  62258. jsMSCTranscoder: null;
  62259. wasmMSCTranscoder: null;
  62260. };
  62261. /**
  62262. * Default number of workers used to handle data decoding
  62263. */
  62264. static DefaultNumWorkers: number;
  62265. private static GetDefaultNumWorkers;
  62266. private _engine;
  62267. private static _CreateWorkerPool;
  62268. /**
  62269. * Constructor
  62270. * @param engine The engine to use
  62271. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62272. */
  62273. constructor(engine: ThinEngine, numWorkers?: number);
  62274. /** @hidden */
  62275. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62276. /**
  62277. * Stop all async operations and release resources.
  62278. */
  62279. dispose(): void;
  62280. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62281. /**
  62282. * Checks if the given data starts with a KTX2 file identifier.
  62283. * @param data the data to check
  62284. * @returns true if the data is a KTX2 file or false otherwise
  62285. */
  62286. static IsValid(data: ArrayBufferView): boolean;
  62287. }
  62288. }
  62289. declare module BABYLON {
  62290. /**
  62291. * Implementation of the KTX Texture Loader.
  62292. * @hidden
  62293. */
  62294. export class _KTXTextureLoader implements IInternalTextureLoader {
  62295. /**
  62296. * Defines wether the loader supports cascade loading the different faces.
  62297. */
  62298. readonly supportCascades: boolean;
  62299. /**
  62300. * This returns if the loader support the current file information.
  62301. * @param extension defines the file extension of the file being loaded
  62302. * @param mimeType defines the optional mime type of the file being loaded
  62303. * @returns true if the loader can load the specified file
  62304. */
  62305. canLoad(extension: string, mimeType?: string): boolean;
  62306. /**
  62307. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62308. * @param data contains the texture data
  62309. * @param texture defines the BabylonJS internal texture
  62310. * @param createPolynomials will be true if polynomials have been requested
  62311. * @param onLoad defines the callback to trigger once the texture is ready
  62312. * @param onError defines the callback to trigger in case of error
  62313. */
  62314. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62315. /**
  62316. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62317. * @param data contains the texture data
  62318. * @param texture defines the BabylonJS internal texture
  62319. * @param callback defines the method to call once ready to upload
  62320. */
  62321. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62322. }
  62323. }
  62324. declare module BABYLON {
  62325. /** @hidden */
  62326. export var _forceSceneHelpersToBundle: boolean;
  62327. interface Scene {
  62328. /**
  62329. * Creates a default light for the scene.
  62330. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62331. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62332. */
  62333. createDefaultLight(replace?: boolean): void;
  62334. /**
  62335. * Creates a default camera for the scene.
  62336. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62337. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62338. * @param replace has default false, when true replaces the active camera in the scene
  62339. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62340. */
  62341. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62342. /**
  62343. * Creates a default camera and a default light.
  62344. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62345. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62346. * @param replace has the default false, when true replaces the active camera/light in the scene
  62347. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62348. */
  62349. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62350. /**
  62351. * Creates a new sky box
  62352. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62353. * @param environmentTexture defines the texture to use as environment texture
  62354. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62355. * @param scale defines the overall scale of the skybox
  62356. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62357. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62358. * @returns a new mesh holding the sky box
  62359. */
  62360. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62361. /**
  62362. * Creates a new environment
  62363. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62364. * @param options defines the options you can use to configure the environment
  62365. * @returns the new EnvironmentHelper
  62366. */
  62367. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62368. /**
  62369. * Creates a new VREXperienceHelper
  62370. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62371. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62372. * @returns a new VREXperienceHelper
  62373. */
  62374. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62375. /**
  62376. * Creates a new WebXRDefaultExperience
  62377. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62378. * @param options experience options
  62379. * @returns a promise for a new WebXRDefaultExperience
  62380. */
  62381. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62382. }
  62383. }
  62384. declare module BABYLON {
  62385. /**
  62386. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62387. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62388. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62389. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62390. */
  62391. export class VideoDome extends TextureDome<VideoTexture> {
  62392. /**
  62393. * Define the video source as a Monoscopic panoramic 360 video.
  62394. */
  62395. static readonly MODE_MONOSCOPIC: number;
  62396. /**
  62397. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62398. */
  62399. static readonly MODE_TOPBOTTOM: number;
  62400. /**
  62401. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62402. */
  62403. static readonly MODE_SIDEBYSIDE: number;
  62404. /**
  62405. * Get the video texture associated with this video dome
  62406. */
  62407. get videoTexture(): VideoTexture;
  62408. /**
  62409. * Get the video mode of this dome
  62410. */
  62411. get videoMode(): number;
  62412. /**
  62413. * Set the video mode of this dome.
  62414. * @see textureMode
  62415. */
  62416. set videoMode(value: number);
  62417. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62418. }
  62419. }
  62420. declare module BABYLON {
  62421. /**
  62422. * This class can be used to get instrumentation data from a Babylon engine
  62423. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62424. */
  62425. export class EngineInstrumentation implements IDisposable {
  62426. /**
  62427. * Define the instrumented engine.
  62428. */
  62429. engine: Engine;
  62430. private _captureGPUFrameTime;
  62431. private _gpuFrameTimeToken;
  62432. private _gpuFrameTime;
  62433. private _captureShaderCompilationTime;
  62434. private _shaderCompilationTime;
  62435. private _onBeginFrameObserver;
  62436. private _onEndFrameObserver;
  62437. private _onBeforeShaderCompilationObserver;
  62438. private _onAfterShaderCompilationObserver;
  62439. /**
  62440. * Gets the perf counter used for GPU frame time
  62441. */
  62442. get gpuFrameTimeCounter(): PerfCounter;
  62443. /**
  62444. * Gets the GPU frame time capture status
  62445. */
  62446. get captureGPUFrameTime(): boolean;
  62447. /**
  62448. * Enable or disable the GPU frame time capture
  62449. */
  62450. set captureGPUFrameTime(value: boolean);
  62451. /**
  62452. * Gets the perf counter used for shader compilation time
  62453. */
  62454. get shaderCompilationTimeCounter(): PerfCounter;
  62455. /**
  62456. * Gets the shader compilation time capture status
  62457. */
  62458. get captureShaderCompilationTime(): boolean;
  62459. /**
  62460. * Enable or disable the shader compilation time capture
  62461. */
  62462. set captureShaderCompilationTime(value: boolean);
  62463. /**
  62464. * Instantiates a new engine instrumentation.
  62465. * This class can be used to get instrumentation data from a Babylon engine
  62466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62467. * @param engine Defines the engine to instrument
  62468. */
  62469. constructor(
  62470. /**
  62471. * Define the instrumented engine.
  62472. */
  62473. engine: Engine);
  62474. /**
  62475. * Dispose and release associated resources.
  62476. */
  62477. dispose(): void;
  62478. }
  62479. }
  62480. declare module BABYLON {
  62481. /**
  62482. * This class can be used to get instrumentation data from a Babylon engine
  62483. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62484. */
  62485. export class SceneInstrumentation implements IDisposable {
  62486. /**
  62487. * Defines the scene to instrument
  62488. */
  62489. scene: Scene;
  62490. private _captureActiveMeshesEvaluationTime;
  62491. private _activeMeshesEvaluationTime;
  62492. private _captureRenderTargetsRenderTime;
  62493. private _renderTargetsRenderTime;
  62494. private _captureFrameTime;
  62495. private _frameTime;
  62496. private _captureRenderTime;
  62497. private _renderTime;
  62498. private _captureInterFrameTime;
  62499. private _interFrameTime;
  62500. private _captureParticlesRenderTime;
  62501. private _particlesRenderTime;
  62502. private _captureSpritesRenderTime;
  62503. private _spritesRenderTime;
  62504. private _capturePhysicsTime;
  62505. private _physicsTime;
  62506. private _captureAnimationsTime;
  62507. private _animationsTime;
  62508. private _captureCameraRenderTime;
  62509. private _cameraRenderTime;
  62510. private _onBeforeActiveMeshesEvaluationObserver;
  62511. private _onAfterActiveMeshesEvaluationObserver;
  62512. private _onBeforeRenderTargetsRenderObserver;
  62513. private _onAfterRenderTargetsRenderObserver;
  62514. private _onAfterRenderObserver;
  62515. private _onBeforeDrawPhaseObserver;
  62516. private _onAfterDrawPhaseObserver;
  62517. private _onBeforeAnimationsObserver;
  62518. private _onBeforeParticlesRenderingObserver;
  62519. private _onAfterParticlesRenderingObserver;
  62520. private _onBeforeSpritesRenderingObserver;
  62521. private _onAfterSpritesRenderingObserver;
  62522. private _onBeforePhysicsObserver;
  62523. private _onAfterPhysicsObserver;
  62524. private _onAfterAnimationsObserver;
  62525. private _onBeforeCameraRenderObserver;
  62526. private _onAfterCameraRenderObserver;
  62527. /**
  62528. * Gets the perf counter used for active meshes evaluation time
  62529. */
  62530. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62531. /**
  62532. * Gets the active meshes evaluation time capture status
  62533. */
  62534. get captureActiveMeshesEvaluationTime(): boolean;
  62535. /**
  62536. * Enable or disable the active meshes evaluation time capture
  62537. */
  62538. set captureActiveMeshesEvaluationTime(value: boolean);
  62539. /**
  62540. * Gets the perf counter used for render targets render time
  62541. */
  62542. get renderTargetsRenderTimeCounter(): PerfCounter;
  62543. /**
  62544. * Gets the render targets render time capture status
  62545. */
  62546. get captureRenderTargetsRenderTime(): boolean;
  62547. /**
  62548. * Enable or disable the render targets render time capture
  62549. */
  62550. set captureRenderTargetsRenderTime(value: boolean);
  62551. /**
  62552. * Gets the perf counter used for particles render time
  62553. */
  62554. get particlesRenderTimeCounter(): PerfCounter;
  62555. /**
  62556. * Gets the particles render time capture status
  62557. */
  62558. get captureParticlesRenderTime(): boolean;
  62559. /**
  62560. * Enable or disable the particles render time capture
  62561. */
  62562. set captureParticlesRenderTime(value: boolean);
  62563. /**
  62564. * Gets the perf counter used for sprites render time
  62565. */
  62566. get spritesRenderTimeCounter(): PerfCounter;
  62567. /**
  62568. * Gets the sprites render time capture status
  62569. */
  62570. get captureSpritesRenderTime(): boolean;
  62571. /**
  62572. * Enable or disable the sprites render time capture
  62573. */
  62574. set captureSpritesRenderTime(value: boolean);
  62575. /**
  62576. * Gets the perf counter used for physics time
  62577. */
  62578. get physicsTimeCounter(): PerfCounter;
  62579. /**
  62580. * Gets the physics time capture status
  62581. */
  62582. get capturePhysicsTime(): boolean;
  62583. /**
  62584. * Enable or disable the physics time capture
  62585. */
  62586. set capturePhysicsTime(value: boolean);
  62587. /**
  62588. * Gets the perf counter used for animations time
  62589. */
  62590. get animationsTimeCounter(): PerfCounter;
  62591. /**
  62592. * Gets the animations time capture status
  62593. */
  62594. get captureAnimationsTime(): boolean;
  62595. /**
  62596. * Enable or disable the animations time capture
  62597. */
  62598. set captureAnimationsTime(value: boolean);
  62599. /**
  62600. * Gets the perf counter used for frame time capture
  62601. */
  62602. get frameTimeCounter(): PerfCounter;
  62603. /**
  62604. * Gets the frame time capture status
  62605. */
  62606. get captureFrameTime(): boolean;
  62607. /**
  62608. * Enable or disable the frame time capture
  62609. */
  62610. set captureFrameTime(value: boolean);
  62611. /**
  62612. * Gets the perf counter used for inter-frames time capture
  62613. */
  62614. get interFrameTimeCounter(): PerfCounter;
  62615. /**
  62616. * Gets the inter-frames time capture status
  62617. */
  62618. get captureInterFrameTime(): boolean;
  62619. /**
  62620. * Enable or disable the inter-frames time capture
  62621. */
  62622. set captureInterFrameTime(value: boolean);
  62623. /**
  62624. * Gets the perf counter used for render time capture
  62625. */
  62626. get renderTimeCounter(): PerfCounter;
  62627. /**
  62628. * Gets the render time capture status
  62629. */
  62630. get captureRenderTime(): boolean;
  62631. /**
  62632. * Enable or disable the render time capture
  62633. */
  62634. set captureRenderTime(value: boolean);
  62635. /**
  62636. * Gets the perf counter used for camera render time capture
  62637. */
  62638. get cameraRenderTimeCounter(): PerfCounter;
  62639. /**
  62640. * Gets the camera render time capture status
  62641. */
  62642. get captureCameraRenderTime(): boolean;
  62643. /**
  62644. * Enable or disable the camera render time capture
  62645. */
  62646. set captureCameraRenderTime(value: boolean);
  62647. /**
  62648. * Gets the perf counter used for draw calls
  62649. */
  62650. get drawCallsCounter(): PerfCounter;
  62651. /**
  62652. * Instantiates a new scene instrumentation.
  62653. * This class can be used to get instrumentation data from a Babylon engine
  62654. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62655. * @param scene Defines the scene to instrument
  62656. */
  62657. constructor(
  62658. /**
  62659. * Defines the scene to instrument
  62660. */
  62661. scene: Scene);
  62662. /**
  62663. * Dispose and release associated resources.
  62664. */
  62665. dispose(): void;
  62666. }
  62667. }
  62668. declare module BABYLON {
  62669. /** @hidden */
  62670. export var glowMapGenerationPixelShader: {
  62671. name: string;
  62672. shader: string;
  62673. };
  62674. }
  62675. declare module BABYLON {
  62676. /** @hidden */
  62677. export var glowMapGenerationVertexShader: {
  62678. name: string;
  62679. shader: string;
  62680. };
  62681. }
  62682. declare module BABYLON {
  62683. /**
  62684. * Effect layer options. This helps customizing the behaviour
  62685. * of the effect layer.
  62686. */
  62687. export interface IEffectLayerOptions {
  62688. /**
  62689. * Multiplication factor apply to the canvas size to compute the render target size
  62690. * used to generated the objects (the smaller the faster).
  62691. */
  62692. mainTextureRatio: number;
  62693. /**
  62694. * Enforces a fixed size texture to ensure effect stability across devices.
  62695. */
  62696. mainTextureFixedSize?: number;
  62697. /**
  62698. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62699. */
  62700. alphaBlendingMode: number;
  62701. /**
  62702. * The camera attached to the layer.
  62703. */
  62704. camera: Nullable<Camera>;
  62705. /**
  62706. * The rendering group to draw the layer in.
  62707. */
  62708. renderingGroupId: number;
  62709. }
  62710. /**
  62711. * The effect layer Helps adding post process effect blended with the main pass.
  62712. *
  62713. * This can be for instance use to generate glow or higlight effects on the scene.
  62714. *
  62715. * The effect layer class can not be used directly and is intented to inherited from to be
  62716. * customized per effects.
  62717. */
  62718. export abstract class EffectLayer {
  62719. private _vertexBuffers;
  62720. private _indexBuffer;
  62721. private _cachedDefines;
  62722. private _effectLayerMapGenerationEffect;
  62723. private _effectLayerOptions;
  62724. private _mergeEffect;
  62725. protected _scene: Scene;
  62726. protected _engine: Engine;
  62727. protected _maxSize: number;
  62728. protected _mainTextureDesiredSize: ISize;
  62729. protected _mainTexture: RenderTargetTexture;
  62730. protected _shouldRender: boolean;
  62731. protected _postProcesses: PostProcess[];
  62732. protected _textures: BaseTexture[];
  62733. protected _emissiveTextureAndColor: {
  62734. texture: Nullable<BaseTexture>;
  62735. color: Color4;
  62736. };
  62737. /**
  62738. * The name of the layer
  62739. */
  62740. name: string;
  62741. /**
  62742. * The clear color of the texture used to generate the glow map.
  62743. */
  62744. neutralColor: Color4;
  62745. /**
  62746. * Specifies whether the highlight layer is enabled or not.
  62747. */
  62748. isEnabled: boolean;
  62749. /**
  62750. * Gets the camera attached to the layer.
  62751. */
  62752. get camera(): Nullable<Camera>;
  62753. /**
  62754. * Gets the rendering group id the layer should render in.
  62755. */
  62756. get renderingGroupId(): number;
  62757. set renderingGroupId(renderingGroupId: number);
  62758. /**
  62759. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62760. */
  62761. disableBoundingBoxesFromEffectLayer: boolean;
  62762. /**
  62763. * An event triggered when the effect layer has been disposed.
  62764. */
  62765. onDisposeObservable: Observable<EffectLayer>;
  62766. /**
  62767. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62768. */
  62769. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62770. /**
  62771. * An event triggered when the generated texture is being merged in the scene.
  62772. */
  62773. onBeforeComposeObservable: Observable<EffectLayer>;
  62774. /**
  62775. * An event triggered when the mesh is rendered into the effect render target.
  62776. */
  62777. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62778. /**
  62779. * An event triggered after the mesh has been rendered into the effect render target.
  62780. */
  62781. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62782. /**
  62783. * An event triggered when the generated texture has been merged in the scene.
  62784. */
  62785. onAfterComposeObservable: Observable<EffectLayer>;
  62786. /**
  62787. * An event triggered when the efffect layer changes its size.
  62788. */
  62789. onSizeChangedObservable: Observable<EffectLayer>;
  62790. /** @hidden */
  62791. static _SceneComponentInitialization: (scene: Scene) => void;
  62792. /**
  62793. * Instantiates a new effect Layer and references it in the scene.
  62794. * @param name The name of the layer
  62795. * @param scene The scene to use the layer in
  62796. */
  62797. constructor(
  62798. /** The Friendly of the effect in the scene */
  62799. name: string, scene: Scene);
  62800. /**
  62801. * Get the effect name of the layer.
  62802. * @return The effect name
  62803. */
  62804. abstract getEffectName(): string;
  62805. /**
  62806. * Checks for the readiness of the element composing the layer.
  62807. * @param subMesh the mesh to check for
  62808. * @param useInstances specify whether or not to use instances to render the mesh
  62809. * @return true if ready otherwise, false
  62810. */
  62811. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62812. /**
  62813. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62814. * @returns true if the effect requires stencil during the main canvas render pass.
  62815. */
  62816. abstract needStencil(): boolean;
  62817. /**
  62818. * Create the merge effect. This is the shader use to blit the information back
  62819. * to the main canvas at the end of the scene rendering.
  62820. * @returns The effect containing the shader used to merge the effect on the main canvas
  62821. */
  62822. protected abstract _createMergeEffect(): Effect;
  62823. /**
  62824. * Creates the render target textures and post processes used in the effect layer.
  62825. */
  62826. protected abstract _createTextureAndPostProcesses(): void;
  62827. /**
  62828. * Implementation specific of rendering the generating effect on the main canvas.
  62829. * @param effect The effect used to render through
  62830. */
  62831. protected abstract _internalRender(effect: Effect): void;
  62832. /**
  62833. * Sets the required values for both the emissive texture and and the main color.
  62834. */
  62835. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62836. /**
  62837. * Free any resources and references associated to a mesh.
  62838. * Internal use
  62839. * @param mesh The mesh to free.
  62840. */
  62841. abstract _disposeMesh(mesh: Mesh): void;
  62842. /**
  62843. * Serializes this layer (Glow or Highlight for example)
  62844. * @returns a serialized layer object
  62845. */
  62846. abstract serialize?(): any;
  62847. /**
  62848. * Initializes the effect layer with the required options.
  62849. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62850. */
  62851. protected _init(options: Partial<IEffectLayerOptions>): void;
  62852. /**
  62853. * Generates the index buffer of the full screen quad blending to the main canvas.
  62854. */
  62855. private _generateIndexBuffer;
  62856. /**
  62857. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62858. */
  62859. private _generateVertexBuffer;
  62860. /**
  62861. * Sets the main texture desired size which is the closest power of two
  62862. * of the engine canvas size.
  62863. */
  62864. private _setMainTextureSize;
  62865. /**
  62866. * Creates the main texture for the effect layer.
  62867. */
  62868. protected _createMainTexture(): void;
  62869. /**
  62870. * Adds specific effects defines.
  62871. * @param defines The defines to add specifics to.
  62872. */
  62873. protected _addCustomEffectDefines(defines: string[]): void;
  62874. /**
  62875. * Checks for the readiness of the element composing the layer.
  62876. * @param subMesh the mesh to check for
  62877. * @param useInstances specify whether or not to use instances to render the mesh
  62878. * @param emissiveTexture the associated emissive texture used to generate the glow
  62879. * @return true if ready otherwise, false
  62880. */
  62881. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62882. /**
  62883. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62884. */
  62885. render(): void;
  62886. /**
  62887. * Determine if a given mesh will be used in the current effect.
  62888. * @param mesh mesh to test
  62889. * @returns true if the mesh will be used
  62890. */
  62891. hasMesh(mesh: AbstractMesh): boolean;
  62892. /**
  62893. * Returns true if the layer contains information to display, otherwise false.
  62894. * @returns true if the glow layer should be rendered
  62895. */
  62896. shouldRender(): boolean;
  62897. /**
  62898. * Returns true if the mesh should render, otherwise false.
  62899. * @param mesh The mesh to render
  62900. * @returns true if it should render otherwise false
  62901. */
  62902. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62903. /**
  62904. * Returns true if the mesh can be rendered, otherwise false.
  62905. * @param mesh The mesh to render
  62906. * @param material The material used on the mesh
  62907. * @returns true if it can be rendered otherwise false
  62908. */
  62909. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62910. /**
  62911. * Returns true if the mesh should render, otherwise false.
  62912. * @param mesh The mesh to render
  62913. * @returns true if it should render otherwise false
  62914. */
  62915. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62916. /**
  62917. * Renders the submesh passed in parameter to the generation map.
  62918. */
  62919. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62920. /**
  62921. * Defines whether the current material of the mesh should be use to render the effect.
  62922. * @param mesh defines the current mesh to render
  62923. */
  62924. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62925. /**
  62926. * Rebuild the required buffers.
  62927. * @hidden Internal use only.
  62928. */
  62929. _rebuild(): void;
  62930. /**
  62931. * Dispose only the render target textures and post process.
  62932. */
  62933. private _disposeTextureAndPostProcesses;
  62934. /**
  62935. * Dispose the highlight layer and free resources.
  62936. */
  62937. dispose(): void;
  62938. /**
  62939. * Gets the class name of the effect layer
  62940. * @returns the string with the class name of the effect layer
  62941. */
  62942. getClassName(): string;
  62943. /**
  62944. * Creates an effect layer from parsed effect layer data
  62945. * @param parsedEffectLayer defines effect layer data
  62946. * @param scene defines the current scene
  62947. * @param rootUrl defines the root URL containing the effect layer information
  62948. * @returns a parsed effect Layer
  62949. */
  62950. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62951. }
  62952. }
  62953. declare module BABYLON {
  62954. interface AbstractScene {
  62955. /**
  62956. * The list of effect layers (highlights/glow) added to the scene
  62957. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62958. * @see https://doc.babylonjs.com/how_to/glow_layer
  62959. */
  62960. effectLayers: Array<EffectLayer>;
  62961. /**
  62962. * Removes the given effect layer from this scene.
  62963. * @param toRemove defines the effect layer to remove
  62964. * @returns the index of the removed effect layer
  62965. */
  62966. removeEffectLayer(toRemove: EffectLayer): number;
  62967. /**
  62968. * Adds the given effect layer to this scene
  62969. * @param newEffectLayer defines the effect layer to add
  62970. */
  62971. addEffectLayer(newEffectLayer: EffectLayer): void;
  62972. }
  62973. /**
  62974. * Defines the layer scene component responsible to manage any effect layers
  62975. * in a given scene.
  62976. */
  62977. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62978. /**
  62979. * The component name helpfull to identify the component in the list of scene components.
  62980. */
  62981. readonly name: string;
  62982. /**
  62983. * The scene the component belongs to.
  62984. */
  62985. scene: Scene;
  62986. private _engine;
  62987. private _renderEffects;
  62988. private _needStencil;
  62989. private _previousStencilState;
  62990. /**
  62991. * Creates a new instance of the component for the given scene
  62992. * @param scene Defines the scene to register the component in
  62993. */
  62994. constructor(scene: Scene);
  62995. /**
  62996. * Registers the component in a given scene
  62997. */
  62998. register(): void;
  62999. /**
  63000. * Rebuilds the elements related to this component in case of
  63001. * context lost for instance.
  63002. */
  63003. rebuild(): void;
  63004. /**
  63005. * Serializes the component data to the specified json object
  63006. * @param serializationObject The object to serialize to
  63007. */
  63008. serialize(serializationObject: any): void;
  63009. /**
  63010. * Adds all the elements from the container to the scene
  63011. * @param container the container holding the elements
  63012. */
  63013. addFromContainer(container: AbstractScene): void;
  63014. /**
  63015. * Removes all the elements in the container from the scene
  63016. * @param container contains the elements to remove
  63017. * @param dispose if the removed element should be disposed (default: false)
  63018. */
  63019. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63020. /**
  63021. * Disposes the component and the associated ressources.
  63022. */
  63023. dispose(): void;
  63024. private _isReadyForMesh;
  63025. private _renderMainTexture;
  63026. private _setStencil;
  63027. private _setStencilBack;
  63028. private _draw;
  63029. private _drawCamera;
  63030. private _drawRenderingGroup;
  63031. }
  63032. }
  63033. declare module BABYLON {
  63034. /** @hidden */
  63035. export var glowMapMergePixelShader: {
  63036. name: string;
  63037. shader: string;
  63038. };
  63039. }
  63040. declare module BABYLON {
  63041. /** @hidden */
  63042. export var glowMapMergeVertexShader: {
  63043. name: string;
  63044. shader: string;
  63045. };
  63046. }
  63047. declare module BABYLON {
  63048. interface AbstractScene {
  63049. /**
  63050. * Return a the first highlight layer of the scene with a given name.
  63051. * @param name The name of the highlight layer to look for.
  63052. * @return The highlight layer if found otherwise null.
  63053. */
  63054. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63055. }
  63056. /**
  63057. * Glow layer options. This helps customizing the behaviour
  63058. * of the glow layer.
  63059. */
  63060. export interface IGlowLayerOptions {
  63061. /**
  63062. * Multiplication factor apply to the canvas size to compute the render target size
  63063. * used to generated the glowing objects (the smaller the faster).
  63064. */
  63065. mainTextureRatio: number;
  63066. /**
  63067. * Enforces a fixed size texture to ensure resize independant blur.
  63068. */
  63069. mainTextureFixedSize?: number;
  63070. /**
  63071. * How big is the kernel of the blur texture.
  63072. */
  63073. blurKernelSize: number;
  63074. /**
  63075. * The camera attached to the layer.
  63076. */
  63077. camera: Nullable<Camera>;
  63078. /**
  63079. * Enable MSAA by chosing the number of samples.
  63080. */
  63081. mainTextureSamples?: number;
  63082. /**
  63083. * The rendering group to draw the layer in.
  63084. */
  63085. renderingGroupId: number;
  63086. }
  63087. /**
  63088. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63089. *
  63090. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63091. *
  63092. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63093. */
  63094. export class GlowLayer extends EffectLayer {
  63095. /**
  63096. * Effect Name of the layer.
  63097. */
  63098. static readonly EffectName: string;
  63099. /**
  63100. * The default blur kernel size used for the glow.
  63101. */
  63102. static DefaultBlurKernelSize: number;
  63103. /**
  63104. * The default texture size ratio used for the glow.
  63105. */
  63106. static DefaultTextureRatio: number;
  63107. /**
  63108. * Sets the kernel size of the blur.
  63109. */
  63110. set blurKernelSize(value: number);
  63111. /**
  63112. * Gets the kernel size of the blur.
  63113. */
  63114. get blurKernelSize(): number;
  63115. /**
  63116. * Sets the glow intensity.
  63117. */
  63118. set intensity(value: number);
  63119. /**
  63120. * Gets the glow intensity.
  63121. */
  63122. get intensity(): number;
  63123. private _options;
  63124. private _intensity;
  63125. private _horizontalBlurPostprocess1;
  63126. private _verticalBlurPostprocess1;
  63127. private _horizontalBlurPostprocess2;
  63128. private _verticalBlurPostprocess2;
  63129. private _blurTexture1;
  63130. private _blurTexture2;
  63131. private _postProcesses1;
  63132. private _postProcesses2;
  63133. private _includedOnlyMeshes;
  63134. private _excludedMeshes;
  63135. private _meshesUsingTheirOwnMaterials;
  63136. /**
  63137. * Callback used to let the user override the color selection on a per mesh basis
  63138. */
  63139. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63140. /**
  63141. * Callback used to let the user override the texture selection on a per mesh basis
  63142. */
  63143. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63144. /**
  63145. * Instantiates a new glow Layer and references it to the scene.
  63146. * @param name The name of the layer
  63147. * @param scene The scene to use the layer in
  63148. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63149. */
  63150. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63151. /**
  63152. * Get the effect name of the layer.
  63153. * @return The effect name
  63154. */
  63155. getEffectName(): string;
  63156. /**
  63157. * Create the merge effect. This is the shader use to blit the information back
  63158. * to the main canvas at the end of the scene rendering.
  63159. */
  63160. protected _createMergeEffect(): Effect;
  63161. /**
  63162. * Creates the render target textures and post processes used in the glow layer.
  63163. */
  63164. protected _createTextureAndPostProcesses(): void;
  63165. /**
  63166. * Checks for the readiness of the element composing the layer.
  63167. * @param subMesh the mesh to check for
  63168. * @param useInstances specify wether or not to use instances to render the mesh
  63169. * @param emissiveTexture the associated emissive texture used to generate the glow
  63170. * @return true if ready otherwise, false
  63171. */
  63172. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63173. /**
  63174. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63175. */
  63176. needStencil(): boolean;
  63177. /**
  63178. * Returns true if the mesh can be rendered, otherwise false.
  63179. * @param mesh The mesh to render
  63180. * @param material The material used on the mesh
  63181. * @returns true if it can be rendered otherwise false
  63182. */
  63183. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63184. /**
  63185. * Implementation specific of rendering the generating effect on the main canvas.
  63186. * @param effect The effect used to render through
  63187. */
  63188. protected _internalRender(effect: Effect): void;
  63189. /**
  63190. * Sets the required values for both the emissive texture and and the main color.
  63191. */
  63192. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63193. /**
  63194. * Returns true if the mesh should render, otherwise false.
  63195. * @param mesh The mesh to render
  63196. * @returns true if it should render otherwise false
  63197. */
  63198. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63199. /**
  63200. * Adds specific effects defines.
  63201. * @param defines The defines to add specifics to.
  63202. */
  63203. protected _addCustomEffectDefines(defines: string[]): void;
  63204. /**
  63205. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63206. * @param mesh The mesh to exclude from the glow layer
  63207. */
  63208. addExcludedMesh(mesh: Mesh): void;
  63209. /**
  63210. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63211. * @param mesh The mesh to remove
  63212. */
  63213. removeExcludedMesh(mesh: Mesh): void;
  63214. /**
  63215. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63216. * @param mesh The mesh to include in the glow layer
  63217. */
  63218. addIncludedOnlyMesh(mesh: Mesh): void;
  63219. /**
  63220. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63221. * @param mesh The mesh to remove
  63222. */
  63223. removeIncludedOnlyMesh(mesh: Mesh): void;
  63224. /**
  63225. * Determine if a given mesh will be used in the glow layer
  63226. * @param mesh The mesh to test
  63227. * @returns true if the mesh will be highlighted by the current glow layer
  63228. */
  63229. hasMesh(mesh: AbstractMesh): boolean;
  63230. /**
  63231. * Defines whether the current material of the mesh should be use to render the effect.
  63232. * @param mesh defines the current mesh to render
  63233. */
  63234. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63235. /**
  63236. * Add a mesh to be rendered through its own material and not with emissive only.
  63237. * @param mesh The mesh for which we need to use its material
  63238. */
  63239. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63240. /**
  63241. * Remove a mesh from being rendered through its own material and not with emissive only.
  63242. * @param mesh The mesh for which we need to not use its material
  63243. */
  63244. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63245. /**
  63246. * Free any resources and references associated to a mesh.
  63247. * Internal use
  63248. * @param mesh The mesh to free.
  63249. * @hidden
  63250. */
  63251. _disposeMesh(mesh: Mesh): void;
  63252. /**
  63253. * Gets the class name of the effect layer
  63254. * @returns the string with the class name of the effect layer
  63255. */
  63256. getClassName(): string;
  63257. /**
  63258. * Serializes this glow layer
  63259. * @returns a serialized glow layer object
  63260. */
  63261. serialize(): any;
  63262. /**
  63263. * Creates a Glow Layer from parsed glow layer data
  63264. * @param parsedGlowLayer defines glow layer data
  63265. * @param scene defines the current scene
  63266. * @param rootUrl defines the root URL containing the glow layer information
  63267. * @returns a parsed Glow Layer
  63268. */
  63269. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63270. }
  63271. }
  63272. declare module BABYLON {
  63273. /** @hidden */
  63274. export var glowBlurPostProcessPixelShader: {
  63275. name: string;
  63276. shader: string;
  63277. };
  63278. }
  63279. declare module BABYLON {
  63280. interface AbstractScene {
  63281. /**
  63282. * Return a the first highlight layer of the scene with a given name.
  63283. * @param name The name of the highlight layer to look for.
  63284. * @return The highlight layer if found otherwise null.
  63285. */
  63286. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63287. }
  63288. /**
  63289. * Highlight layer options. This helps customizing the behaviour
  63290. * of the highlight layer.
  63291. */
  63292. export interface IHighlightLayerOptions {
  63293. /**
  63294. * Multiplication factor apply to the canvas size to compute the render target size
  63295. * used to generated the glowing objects (the smaller the faster).
  63296. */
  63297. mainTextureRatio: number;
  63298. /**
  63299. * Enforces a fixed size texture to ensure resize independant blur.
  63300. */
  63301. mainTextureFixedSize?: number;
  63302. /**
  63303. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63304. * of the picture to blur (the smaller the faster).
  63305. */
  63306. blurTextureSizeRatio: number;
  63307. /**
  63308. * How big in texel of the blur texture is the vertical blur.
  63309. */
  63310. blurVerticalSize: number;
  63311. /**
  63312. * How big in texel of the blur texture is the horizontal blur.
  63313. */
  63314. blurHorizontalSize: number;
  63315. /**
  63316. * Alpha blending mode used to apply the blur. Default is combine.
  63317. */
  63318. alphaBlendingMode: number;
  63319. /**
  63320. * The camera attached to the layer.
  63321. */
  63322. camera: Nullable<Camera>;
  63323. /**
  63324. * Should we display highlight as a solid stroke?
  63325. */
  63326. isStroke?: boolean;
  63327. /**
  63328. * The rendering group to draw the layer in.
  63329. */
  63330. renderingGroupId: number;
  63331. }
  63332. /**
  63333. * The highlight layer Helps adding a glow effect around a mesh.
  63334. *
  63335. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63336. * glowy meshes to your scene.
  63337. *
  63338. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63339. */
  63340. export class HighlightLayer extends EffectLayer {
  63341. name: string;
  63342. /**
  63343. * Effect Name of the highlight layer.
  63344. */
  63345. static readonly EffectName: string;
  63346. /**
  63347. * The neutral color used during the preparation of the glow effect.
  63348. * This is black by default as the blend operation is a blend operation.
  63349. */
  63350. static NeutralColor: Color4;
  63351. /**
  63352. * Stencil value used for glowing meshes.
  63353. */
  63354. static GlowingMeshStencilReference: number;
  63355. /**
  63356. * Stencil value used for the other meshes in the scene.
  63357. */
  63358. static NormalMeshStencilReference: number;
  63359. /**
  63360. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63361. */
  63362. innerGlow: boolean;
  63363. /**
  63364. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63365. */
  63366. outerGlow: boolean;
  63367. /**
  63368. * Specifies the horizontal size of the blur.
  63369. */
  63370. set blurHorizontalSize(value: number);
  63371. /**
  63372. * Specifies the vertical size of the blur.
  63373. */
  63374. set blurVerticalSize(value: number);
  63375. /**
  63376. * Gets the horizontal size of the blur.
  63377. */
  63378. get blurHorizontalSize(): number;
  63379. /**
  63380. * Gets the vertical size of the blur.
  63381. */
  63382. get blurVerticalSize(): number;
  63383. /**
  63384. * An event triggered when the highlight layer is being blurred.
  63385. */
  63386. onBeforeBlurObservable: Observable<HighlightLayer>;
  63387. /**
  63388. * An event triggered when the highlight layer has been blurred.
  63389. */
  63390. onAfterBlurObservable: Observable<HighlightLayer>;
  63391. private _instanceGlowingMeshStencilReference;
  63392. private _options;
  63393. private _downSamplePostprocess;
  63394. private _horizontalBlurPostprocess;
  63395. private _verticalBlurPostprocess;
  63396. private _blurTexture;
  63397. private _meshes;
  63398. private _excludedMeshes;
  63399. /**
  63400. * Instantiates a new highlight Layer and references it to the scene..
  63401. * @param name The name of the layer
  63402. * @param scene The scene to use the layer in
  63403. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63404. */
  63405. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63406. /**
  63407. * Get the effect name of the layer.
  63408. * @return The effect name
  63409. */
  63410. getEffectName(): string;
  63411. /**
  63412. * Create the merge effect. This is the shader use to blit the information back
  63413. * to the main canvas at the end of the scene rendering.
  63414. */
  63415. protected _createMergeEffect(): Effect;
  63416. /**
  63417. * Creates the render target textures and post processes used in the highlight layer.
  63418. */
  63419. protected _createTextureAndPostProcesses(): void;
  63420. /**
  63421. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63422. */
  63423. needStencil(): boolean;
  63424. /**
  63425. * Checks for the readiness of the element composing the layer.
  63426. * @param subMesh the mesh to check for
  63427. * @param useInstances specify wether or not to use instances to render the mesh
  63428. * @param emissiveTexture the associated emissive texture used to generate the glow
  63429. * @return true if ready otherwise, false
  63430. */
  63431. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63432. /**
  63433. * Implementation specific of rendering the generating effect on the main canvas.
  63434. * @param effect The effect used to render through
  63435. */
  63436. protected _internalRender(effect: Effect): void;
  63437. /**
  63438. * Returns true if the layer contains information to display, otherwise false.
  63439. */
  63440. shouldRender(): boolean;
  63441. /**
  63442. * Returns true if the mesh should render, otherwise false.
  63443. * @param mesh The mesh to render
  63444. * @returns true if it should render otherwise false
  63445. */
  63446. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63447. /**
  63448. * Returns true if the mesh can be rendered, otherwise false.
  63449. * @param mesh The mesh to render
  63450. * @param material The material used on the mesh
  63451. * @returns true if it can be rendered otherwise false
  63452. */
  63453. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63454. /**
  63455. * Adds specific effects defines.
  63456. * @param defines The defines to add specifics to.
  63457. */
  63458. protected _addCustomEffectDefines(defines: string[]): void;
  63459. /**
  63460. * Sets the required values for both the emissive texture and and the main color.
  63461. */
  63462. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63463. /**
  63464. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63465. * @param mesh The mesh to exclude from the highlight layer
  63466. */
  63467. addExcludedMesh(mesh: Mesh): void;
  63468. /**
  63469. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63470. * @param mesh The mesh to highlight
  63471. */
  63472. removeExcludedMesh(mesh: Mesh): void;
  63473. /**
  63474. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63475. * @param mesh mesh to test
  63476. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63477. */
  63478. hasMesh(mesh: AbstractMesh): boolean;
  63479. /**
  63480. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63481. * @param mesh The mesh to highlight
  63482. * @param color The color of the highlight
  63483. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63484. */
  63485. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63486. /**
  63487. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63488. * @param mesh The mesh to highlight
  63489. */
  63490. removeMesh(mesh: Mesh): void;
  63491. /**
  63492. * Remove all the meshes currently referenced in the highlight layer
  63493. */
  63494. removeAllMeshes(): void;
  63495. /**
  63496. * Force the stencil to the normal expected value for none glowing parts
  63497. */
  63498. private _defaultStencilReference;
  63499. /**
  63500. * Free any resources and references associated to a mesh.
  63501. * Internal use
  63502. * @param mesh The mesh to free.
  63503. * @hidden
  63504. */
  63505. _disposeMesh(mesh: Mesh): void;
  63506. /**
  63507. * Dispose the highlight layer and free resources.
  63508. */
  63509. dispose(): void;
  63510. /**
  63511. * Gets the class name of the effect layer
  63512. * @returns the string with the class name of the effect layer
  63513. */
  63514. getClassName(): string;
  63515. /**
  63516. * Serializes this Highlight layer
  63517. * @returns a serialized Highlight layer object
  63518. */
  63519. serialize(): any;
  63520. /**
  63521. * Creates a Highlight layer from parsed Highlight layer data
  63522. * @param parsedHightlightLayer defines the Highlight layer data
  63523. * @param scene defines the current scene
  63524. * @param rootUrl defines the root URL containing the Highlight layer information
  63525. * @returns a parsed Highlight layer
  63526. */
  63527. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63528. }
  63529. }
  63530. declare module BABYLON {
  63531. interface AbstractScene {
  63532. /**
  63533. * The list of layers (background and foreground) of the scene
  63534. */
  63535. layers: Array<Layer>;
  63536. }
  63537. /**
  63538. * Defines the layer scene component responsible to manage any layers
  63539. * in a given scene.
  63540. */
  63541. export class LayerSceneComponent implements ISceneComponent {
  63542. /**
  63543. * The component name helpfull to identify the component in the list of scene components.
  63544. */
  63545. readonly name: string;
  63546. /**
  63547. * The scene the component belongs to.
  63548. */
  63549. scene: Scene;
  63550. private _engine;
  63551. /**
  63552. * Creates a new instance of the component for the given scene
  63553. * @param scene Defines the scene to register the component in
  63554. */
  63555. constructor(scene: Scene);
  63556. /**
  63557. * Registers the component in a given scene
  63558. */
  63559. register(): void;
  63560. /**
  63561. * Rebuilds the elements related to this component in case of
  63562. * context lost for instance.
  63563. */
  63564. rebuild(): void;
  63565. /**
  63566. * Disposes the component and the associated ressources.
  63567. */
  63568. dispose(): void;
  63569. private _draw;
  63570. private _drawCameraPredicate;
  63571. private _drawCameraBackground;
  63572. private _drawCameraForeground;
  63573. private _drawRenderTargetPredicate;
  63574. private _drawRenderTargetBackground;
  63575. private _drawRenderTargetForeground;
  63576. /**
  63577. * Adds all the elements from the container to the scene
  63578. * @param container the container holding the elements
  63579. */
  63580. addFromContainer(container: AbstractScene): void;
  63581. /**
  63582. * Removes all the elements in the container from the scene
  63583. * @param container contains the elements to remove
  63584. * @param dispose if the removed element should be disposed (default: false)
  63585. */
  63586. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63587. }
  63588. }
  63589. declare module BABYLON {
  63590. /** @hidden */
  63591. export var layerPixelShader: {
  63592. name: string;
  63593. shader: string;
  63594. };
  63595. }
  63596. declare module BABYLON {
  63597. /** @hidden */
  63598. export var layerVertexShader: {
  63599. name: string;
  63600. shader: string;
  63601. };
  63602. }
  63603. declare module BABYLON {
  63604. /**
  63605. * This represents a full screen 2d layer.
  63606. * This can be useful to display a picture in the background of your scene for instance.
  63607. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63608. */
  63609. export class Layer {
  63610. /**
  63611. * Define the name of the layer.
  63612. */
  63613. name: string;
  63614. /**
  63615. * Define the texture the layer should display.
  63616. */
  63617. texture: Nullable<Texture>;
  63618. /**
  63619. * Is the layer in background or foreground.
  63620. */
  63621. isBackground: boolean;
  63622. /**
  63623. * Define the color of the layer (instead of texture).
  63624. */
  63625. color: Color4;
  63626. /**
  63627. * Define the scale of the layer in order to zoom in out of the texture.
  63628. */
  63629. scale: Vector2;
  63630. /**
  63631. * Define an offset for the layer in order to shift the texture.
  63632. */
  63633. offset: Vector2;
  63634. /**
  63635. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63636. */
  63637. alphaBlendingMode: number;
  63638. /**
  63639. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63640. * Alpha test will not mix with the background color in case of transparency.
  63641. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63642. */
  63643. alphaTest: boolean;
  63644. /**
  63645. * Define a mask to restrict the layer to only some of the scene cameras.
  63646. */
  63647. layerMask: number;
  63648. /**
  63649. * Define the list of render target the layer is visible into.
  63650. */
  63651. renderTargetTextures: RenderTargetTexture[];
  63652. /**
  63653. * Define if the layer is only used in renderTarget or if it also
  63654. * renders in the main frame buffer of the canvas.
  63655. */
  63656. renderOnlyInRenderTargetTextures: boolean;
  63657. private _scene;
  63658. private _vertexBuffers;
  63659. private _indexBuffer;
  63660. private _effect;
  63661. private _previousDefines;
  63662. /**
  63663. * An event triggered when the layer is disposed.
  63664. */
  63665. onDisposeObservable: Observable<Layer>;
  63666. private _onDisposeObserver;
  63667. /**
  63668. * Back compatibility with callback before the onDisposeObservable existed.
  63669. * The set callback will be triggered when the layer has been disposed.
  63670. */
  63671. set onDispose(callback: () => void);
  63672. /**
  63673. * An event triggered before rendering the scene
  63674. */
  63675. onBeforeRenderObservable: Observable<Layer>;
  63676. private _onBeforeRenderObserver;
  63677. /**
  63678. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63679. * The set callback will be triggered just before rendering the layer.
  63680. */
  63681. set onBeforeRender(callback: () => void);
  63682. /**
  63683. * An event triggered after rendering the scene
  63684. */
  63685. onAfterRenderObservable: Observable<Layer>;
  63686. private _onAfterRenderObserver;
  63687. /**
  63688. * Back compatibility with callback before the onAfterRenderObservable existed.
  63689. * The set callback will be triggered just after rendering the layer.
  63690. */
  63691. set onAfterRender(callback: () => void);
  63692. /**
  63693. * Instantiates a new layer.
  63694. * This represents a full screen 2d layer.
  63695. * This can be useful to display a picture in the background of your scene for instance.
  63696. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63697. * @param name Define the name of the layer in the scene
  63698. * @param imgUrl Define the url of the texture to display in the layer
  63699. * @param scene Define the scene the layer belongs to
  63700. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63701. * @param color Defines a color for the layer
  63702. */
  63703. constructor(
  63704. /**
  63705. * Define the name of the layer.
  63706. */
  63707. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63708. private _createIndexBuffer;
  63709. /** @hidden */
  63710. _rebuild(): void;
  63711. /**
  63712. * Renders the layer in the scene.
  63713. */
  63714. render(): void;
  63715. /**
  63716. * Disposes and releases the associated ressources.
  63717. */
  63718. dispose(): void;
  63719. }
  63720. }
  63721. declare module BABYLON {
  63722. /** @hidden */
  63723. export var lensFlarePixelShader: {
  63724. name: string;
  63725. shader: string;
  63726. };
  63727. }
  63728. declare module BABYLON {
  63729. /** @hidden */
  63730. export var lensFlareVertexShader: {
  63731. name: string;
  63732. shader: string;
  63733. };
  63734. }
  63735. declare module BABYLON {
  63736. /**
  63737. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63738. * It is usually composed of several `lensFlare`.
  63739. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63740. */
  63741. export class LensFlareSystem {
  63742. /**
  63743. * Define the name of the lens flare system
  63744. */
  63745. name: string;
  63746. /**
  63747. * List of lens flares used in this system.
  63748. */
  63749. lensFlares: LensFlare[];
  63750. /**
  63751. * Define a limit from the border the lens flare can be visible.
  63752. */
  63753. borderLimit: number;
  63754. /**
  63755. * Define a viewport border we do not want to see the lens flare in.
  63756. */
  63757. viewportBorder: number;
  63758. /**
  63759. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63760. */
  63761. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63762. /**
  63763. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63764. */
  63765. layerMask: number;
  63766. /**
  63767. * Define the id of the lens flare system in the scene.
  63768. * (equal to name by default)
  63769. */
  63770. id: string;
  63771. private _scene;
  63772. private _emitter;
  63773. private _vertexBuffers;
  63774. private _indexBuffer;
  63775. private _effect;
  63776. private _positionX;
  63777. private _positionY;
  63778. private _isEnabled;
  63779. /** @hidden */
  63780. static _SceneComponentInitialization: (scene: Scene) => void;
  63781. /**
  63782. * Instantiates a lens flare system.
  63783. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63784. * It is usually composed of several `lensFlare`.
  63785. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63786. * @param name Define the name of the lens flare system in the scene
  63787. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63788. * @param scene Define the scene the lens flare system belongs to
  63789. */
  63790. constructor(
  63791. /**
  63792. * Define the name of the lens flare system
  63793. */
  63794. name: string, emitter: any, scene: Scene);
  63795. /**
  63796. * Define if the lens flare system is enabled.
  63797. */
  63798. get isEnabled(): boolean;
  63799. set isEnabled(value: boolean);
  63800. /**
  63801. * Get the scene the effects belongs to.
  63802. * @returns the scene holding the lens flare system
  63803. */
  63804. getScene(): Scene;
  63805. /**
  63806. * Get the emitter of the lens flare system.
  63807. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63808. * @returns the emitter of the lens flare system
  63809. */
  63810. getEmitter(): any;
  63811. /**
  63812. * Set the emitter of the lens flare system.
  63813. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63814. * @param newEmitter Define the new emitter of the system
  63815. */
  63816. setEmitter(newEmitter: any): void;
  63817. /**
  63818. * Get the lens flare system emitter position.
  63819. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63820. * @returns the position
  63821. */
  63822. getEmitterPosition(): Vector3;
  63823. /**
  63824. * @hidden
  63825. */
  63826. computeEffectivePosition(globalViewport: Viewport): boolean;
  63827. /** @hidden */
  63828. _isVisible(): boolean;
  63829. /**
  63830. * @hidden
  63831. */
  63832. render(): boolean;
  63833. /**
  63834. * Dispose and release the lens flare with its associated resources.
  63835. */
  63836. dispose(): void;
  63837. /**
  63838. * Parse a lens flare system from a JSON repressentation
  63839. * @param parsedLensFlareSystem Define the JSON to parse
  63840. * @param scene Define the scene the parsed system should be instantiated in
  63841. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63842. * @returns the parsed system
  63843. */
  63844. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63845. /**
  63846. * Serialize the current Lens Flare System into a JSON representation.
  63847. * @returns the serialized JSON
  63848. */
  63849. serialize(): any;
  63850. }
  63851. }
  63852. declare module BABYLON {
  63853. /**
  63854. * This represents one of the lens effect in a `lensFlareSystem`.
  63855. * It controls one of the indiviual texture used in the effect.
  63856. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63857. */
  63858. export class LensFlare {
  63859. /**
  63860. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63861. */
  63862. size: number;
  63863. /**
  63864. * 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.
  63865. */
  63866. position: number;
  63867. /**
  63868. * Define the lens color.
  63869. */
  63870. color: Color3;
  63871. /**
  63872. * Define the lens texture.
  63873. */
  63874. texture: Nullable<Texture>;
  63875. /**
  63876. * Define the alpha mode to render this particular lens.
  63877. */
  63878. alphaMode: number;
  63879. private _system;
  63880. /**
  63881. * Creates a new Lens Flare.
  63882. * This represents one of the lens effect in a `lensFlareSystem`.
  63883. * It controls one of the indiviual texture used in the effect.
  63884. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63885. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63886. * @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.
  63887. * @param color Define the lens color
  63888. * @param imgUrl Define the lens texture url
  63889. * @param system Define the `lensFlareSystem` this flare is part of
  63890. * @returns The newly created Lens Flare
  63891. */
  63892. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63893. /**
  63894. * Instantiates a new Lens Flare.
  63895. * This represents one of the lens effect in a `lensFlareSystem`.
  63896. * It controls one of the indiviual texture used in the effect.
  63897. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63898. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63899. * @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.
  63900. * @param color Define the lens color
  63901. * @param imgUrl Define the lens texture url
  63902. * @param system Define the `lensFlareSystem` this flare is part of
  63903. */
  63904. constructor(
  63905. /**
  63906. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63907. */
  63908. size: number,
  63909. /**
  63910. * 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.
  63911. */
  63912. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63913. /**
  63914. * Dispose and release the lens flare with its associated resources.
  63915. */
  63916. dispose(): void;
  63917. }
  63918. }
  63919. declare module BABYLON {
  63920. interface AbstractScene {
  63921. /**
  63922. * The list of lens flare system added to the scene
  63923. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63924. */
  63925. lensFlareSystems: Array<LensFlareSystem>;
  63926. /**
  63927. * Removes the given lens flare system from this scene.
  63928. * @param toRemove The lens flare system to remove
  63929. * @returns The index of the removed lens flare system
  63930. */
  63931. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63932. /**
  63933. * Adds the given lens flare system to this scene
  63934. * @param newLensFlareSystem The lens flare system to add
  63935. */
  63936. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63937. /**
  63938. * Gets a lens flare system using its name
  63939. * @param name defines the name to look for
  63940. * @returns the lens flare system or null if not found
  63941. */
  63942. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63943. /**
  63944. * Gets a lens flare system using its id
  63945. * @param id defines the id to look for
  63946. * @returns the lens flare system or null if not found
  63947. */
  63948. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63949. }
  63950. /**
  63951. * Defines the lens flare scene component responsible to manage any lens flares
  63952. * in a given scene.
  63953. */
  63954. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63955. /**
  63956. * The component name helpfull to identify the component in the list of scene components.
  63957. */
  63958. readonly name: string;
  63959. /**
  63960. * The scene the component belongs to.
  63961. */
  63962. scene: Scene;
  63963. /**
  63964. * Creates a new instance of the component for the given scene
  63965. * @param scene Defines the scene to register the component in
  63966. */
  63967. constructor(scene: Scene);
  63968. /**
  63969. * Registers the component in a given scene
  63970. */
  63971. register(): void;
  63972. /**
  63973. * Rebuilds the elements related to this component in case of
  63974. * context lost for instance.
  63975. */
  63976. rebuild(): void;
  63977. /**
  63978. * Adds all the elements from the container to the scene
  63979. * @param container the container holding the elements
  63980. */
  63981. addFromContainer(container: AbstractScene): void;
  63982. /**
  63983. * Removes all the elements in the container from the scene
  63984. * @param container contains the elements to remove
  63985. * @param dispose if the removed element should be disposed (default: false)
  63986. */
  63987. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63988. /**
  63989. * Serializes the component data to the specified json object
  63990. * @param serializationObject The object to serialize to
  63991. */
  63992. serialize(serializationObject: any): void;
  63993. /**
  63994. * Disposes the component and the associated ressources.
  63995. */
  63996. dispose(): void;
  63997. private _draw;
  63998. }
  63999. }
  64000. declare module BABYLON {
  64001. /** @hidden */
  64002. export var depthPixelShader: {
  64003. name: string;
  64004. shader: string;
  64005. };
  64006. }
  64007. declare module BABYLON {
  64008. /** @hidden */
  64009. export var depthVertexShader: {
  64010. name: string;
  64011. shader: string;
  64012. };
  64013. }
  64014. declare module BABYLON {
  64015. /**
  64016. * This represents a depth renderer in Babylon.
  64017. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64018. */
  64019. export class DepthRenderer {
  64020. private _scene;
  64021. private _depthMap;
  64022. private _effect;
  64023. private readonly _storeNonLinearDepth;
  64024. private readonly _clearColor;
  64025. /** Get if the depth renderer is using packed depth or not */
  64026. readonly isPacked: boolean;
  64027. private _cachedDefines;
  64028. private _camera;
  64029. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64030. enabled: boolean;
  64031. /**
  64032. * Specifiess that the depth renderer will only be used within
  64033. * the camera it is created for.
  64034. * This can help forcing its rendering during the camera processing.
  64035. */
  64036. useOnlyInActiveCamera: boolean;
  64037. /** @hidden */
  64038. static _SceneComponentInitialization: (scene: Scene) => void;
  64039. /**
  64040. * Instantiates a depth renderer
  64041. * @param scene The scene the renderer belongs to
  64042. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64043. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64044. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64045. */
  64046. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64047. /**
  64048. * Creates the depth rendering effect and checks if the effect is ready.
  64049. * @param subMesh The submesh to be used to render the depth map of
  64050. * @param useInstances If multiple world instances should be used
  64051. * @returns if the depth renderer is ready to render the depth map
  64052. */
  64053. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64054. /**
  64055. * Gets the texture which the depth map will be written to.
  64056. * @returns The depth map texture
  64057. */
  64058. getDepthMap(): RenderTargetTexture;
  64059. /**
  64060. * Disposes of the depth renderer.
  64061. */
  64062. dispose(): void;
  64063. }
  64064. }
  64065. declare module BABYLON {
  64066. /** @hidden */
  64067. export var minmaxReduxPixelShader: {
  64068. name: string;
  64069. shader: string;
  64070. };
  64071. }
  64072. declare module BABYLON {
  64073. /**
  64074. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64075. * and maximum values from all values of the texture.
  64076. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64077. * The source values are read from the red channel of the texture.
  64078. */
  64079. export class MinMaxReducer {
  64080. /**
  64081. * Observable triggered when the computation has been performed
  64082. */
  64083. onAfterReductionPerformed: Observable<{
  64084. min: number;
  64085. max: number;
  64086. }>;
  64087. protected _camera: Camera;
  64088. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64089. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64090. protected _postProcessManager: PostProcessManager;
  64091. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64092. protected _forceFullscreenViewport: boolean;
  64093. /**
  64094. * Creates a min/max reducer
  64095. * @param camera The camera to use for the post processes
  64096. */
  64097. constructor(camera: Camera);
  64098. /**
  64099. * Gets the texture used to read the values from.
  64100. */
  64101. get sourceTexture(): Nullable<RenderTargetTexture>;
  64102. /**
  64103. * Sets the source texture to read the values from.
  64104. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64105. * because in such textures '1' value must not be taken into account to compute the maximum
  64106. * as this value is used to clear the texture.
  64107. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64108. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64109. * @param depthRedux Indicates if the texture is a depth texture or not
  64110. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64111. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64112. */
  64113. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64114. /**
  64115. * Defines the refresh rate of the computation.
  64116. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64117. */
  64118. get refreshRate(): number;
  64119. set refreshRate(value: number);
  64120. protected _activated: boolean;
  64121. /**
  64122. * Gets the activation status of the reducer
  64123. */
  64124. get activated(): boolean;
  64125. /**
  64126. * Activates the reduction computation.
  64127. * When activated, the observers registered in onAfterReductionPerformed are
  64128. * called after the compuation is performed
  64129. */
  64130. activate(): void;
  64131. /**
  64132. * Deactivates the reduction computation.
  64133. */
  64134. deactivate(): void;
  64135. /**
  64136. * Disposes the min/max reducer
  64137. * @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.
  64138. */
  64139. dispose(disposeAll?: boolean): void;
  64140. }
  64141. }
  64142. declare module BABYLON {
  64143. /**
  64144. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64145. */
  64146. export class DepthReducer extends MinMaxReducer {
  64147. private _depthRenderer;
  64148. private _depthRendererId;
  64149. /**
  64150. * Gets the depth renderer used for the computation.
  64151. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64152. */
  64153. get depthRenderer(): Nullable<DepthRenderer>;
  64154. /**
  64155. * Creates a depth reducer
  64156. * @param camera The camera used to render the depth texture
  64157. */
  64158. constructor(camera: Camera);
  64159. /**
  64160. * Sets the depth renderer to use to generate the depth map
  64161. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64162. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64163. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64164. */
  64165. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64166. /** @hidden */
  64167. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64168. /**
  64169. * Activates the reduction computation.
  64170. * When activated, the observers registered in onAfterReductionPerformed are
  64171. * called after the compuation is performed
  64172. */
  64173. activate(): void;
  64174. /**
  64175. * Deactivates the reduction computation.
  64176. */
  64177. deactivate(): void;
  64178. /**
  64179. * Disposes the depth reducer
  64180. * @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.
  64181. */
  64182. dispose(disposeAll?: boolean): void;
  64183. }
  64184. }
  64185. declare module BABYLON {
  64186. /**
  64187. * A CSM implementation allowing casting shadows on large scenes.
  64188. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64189. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64190. */
  64191. export class CascadedShadowGenerator extends ShadowGenerator {
  64192. private static readonly frustumCornersNDCSpace;
  64193. /**
  64194. * Name of the CSM class
  64195. */
  64196. static CLASSNAME: string;
  64197. /**
  64198. * Defines the default number of cascades used by the CSM.
  64199. */
  64200. static readonly DEFAULT_CASCADES_COUNT: number;
  64201. /**
  64202. * Defines the minimum number of cascades used by the CSM.
  64203. */
  64204. static readonly MIN_CASCADES_COUNT: number;
  64205. /**
  64206. * Defines the maximum number of cascades used by the CSM.
  64207. */
  64208. static readonly MAX_CASCADES_COUNT: number;
  64209. protected _validateFilter(filter: number): number;
  64210. /**
  64211. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64212. */
  64213. penumbraDarkness: number;
  64214. private _numCascades;
  64215. /**
  64216. * Gets or set the number of cascades used by the CSM.
  64217. */
  64218. get numCascades(): number;
  64219. set numCascades(value: number);
  64220. /**
  64221. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64222. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64223. */
  64224. stabilizeCascades: boolean;
  64225. private _freezeShadowCastersBoundingInfo;
  64226. private _freezeShadowCastersBoundingInfoObservable;
  64227. /**
  64228. * Enables or disables the shadow casters bounding info computation.
  64229. * If your shadow casters don't move, you can disable this feature.
  64230. * If it is enabled, the bounding box computation is done every frame.
  64231. */
  64232. get freezeShadowCastersBoundingInfo(): boolean;
  64233. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64234. private _scbiMin;
  64235. private _scbiMax;
  64236. protected _computeShadowCastersBoundingInfo(): void;
  64237. protected _shadowCastersBoundingInfo: BoundingInfo;
  64238. /**
  64239. * Gets or sets the shadow casters bounding info.
  64240. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64241. * so that the system won't overwrite the bounds you provide
  64242. */
  64243. get shadowCastersBoundingInfo(): BoundingInfo;
  64244. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64245. protected _breaksAreDirty: boolean;
  64246. protected _minDistance: number;
  64247. protected _maxDistance: number;
  64248. /**
  64249. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64250. *
  64251. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64252. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64253. * @param min minimal distance for the breaks (default to 0.)
  64254. * @param max maximal distance for the breaks (default to 1.)
  64255. */
  64256. setMinMaxDistance(min: number, max: number): void;
  64257. /** Gets the minimal distance used in the cascade break computation */
  64258. get minDistance(): number;
  64259. /** Gets the maximal distance used in the cascade break computation */
  64260. get maxDistance(): number;
  64261. /**
  64262. * Gets the class name of that object
  64263. * @returns "CascadedShadowGenerator"
  64264. */
  64265. getClassName(): string;
  64266. private _cascadeMinExtents;
  64267. private _cascadeMaxExtents;
  64268. /**
  64269. * Gets a cascade minimum extents
  64270. * @param cascadeIndex index of the cascade
  64271. * @returns the minimum cascade extents
  64272. */
  64273. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64274. /**
  64275. * Gets a cascade maximum extents
  64276. * @param cascadeIndex index of the cascade
  64277. * @returns the maximum cascade extents
  64278. */
  64279. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64280. private _cascades;
  64281. private _currentLayer;
  64282. private _viewSpaceFrustumsZ;
  64283. private _viewMatrices;
  64284. private _projectionMatrices;
  64285. private _transformMatrices;
  64286. private _transformMatricesAsArray;
  64287. private _frustumLengths;
  64288. private _lightSizeUVCorrection;
  64289. private _depthCorrection;
  64290. private _frustumCornersWorldSpace;
  64291. private _frustumCenter;
  64292. private _shadowCameraPos;
  64293. private _shadowMaxZ;
  64294. /**
  64295. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64296. * It defaults to camera.maxZ
  64297. */
  64298. get shadowMaxZ(): number;
  64299. /**
  64300. * Sets the shadow max z distance.
  64301. */
  64302. set shadowMaxZ(value: number);
  64303. protected _debug: boolean;
  64304. /**
  64305. * Gets or sets the debug flag.
  64306. * When enabled, the cascades are materialized by different colors on the screen.
  64307. */
  64308. get debug(): boolean;
  64309. set debug(dbg: boolean);
  64310. private _depthClamp;
  64311. /**
  64312. * Gets or sets the depth clamping value.
  64313. *
  64314. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64315. * to account for the shadow casters far away.
  64316. *
  64317. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64318. */
  64319. get depthClamp(): boolean;
  64320. set depthClamp(value: boolean);
  64321. private _cascadeBlendPercentage;
  64322. /**
  64323. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64324. * It defaults to 0.1 (10% blending).
  64325. */
  64326. get cascadeBlendPercentage(): number;
  64327. set cascadeBlendPercentage(value: number);
  64328. private _lambda;
  64329. /**
  64330. * Gets or set the lambda parameter.
  64331. * This parameter is used to split the camera frustum and create the cascades.
  64332. * 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.
  64333. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64334. */
  64335. get lambda(): number;
  64336. set lambda(value: number);
  64337. /**
  64338. * Gets the view matrix corresponding to a given cascade
  64339. * @param cascadeNum cascade to retrieve the view matrix from
  64340. * @returns the cascade view matrix
  64341. */
  64342. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64343. /**
  64344. * Gets the projection matrix corresponding to a given cascade
  64345. * @param cascadeNum cascade to retrieve the projection matrix from
  64346. * @returns the cascade projection matrix
  64347. */
  64348. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64349. /**
  64350. * Gets the transformation matrix corresponding to a given cascade
  64351. * @param cascadeNum cascade to retrieve the transformation matrix from
  64352. * @returns the cascade transformation matrix
  64353. */
  64354. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64355. private _depthRenderer;
  64356. /**
  64357. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64358. *
  64359. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64360. *
  64361. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64362. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64363. * @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
  64364. */
  64365. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64366. private _depthReducer;
  64367. private _autoCalcDepthBounds;
  64368. /**
  64369. * Gets or sets the autoCalcDepthBounds property.
  64370. *
  64371. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64372. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64373. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64374. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64375. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64376. */
  64377. get autoCalcDepthBounds(): boolean;
  64378. set autoCalcDepthBounds(value: boolean);
  64379. /**
  64380. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64381. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64382. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64383. * for setting the refresh rate on the renderer yourself!
  64384. */
  64385. get autoCalcDepthBoundsRefreshRate(): number;
  64386. set autoCalcDepthBoundsRefreshRate(value: number);
  64387. /**
  64388. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64389. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64390. * you change the camera near/far planes!
  64391. */
  64392. splitFrustum(): void;
  64393. private _splitFrustum;
  64394. private _computeMatrices;
  64395. private _computeFrustumInWorldSpace;
  64396. private _computeCascadeFrustum;
  64397. /**
  64398. * Support test.
  64399. */
  64400. static get IsSupported(): boolean;
  64401. /** @hidden */
  64402. static _SceneComponentInitialization: (scene: Scene) => void;
  64403. /**
  64404. * Creates a Cascaded Shadow Generator object.
  64405. * A ShadowGenerator is the required tool to use the shadows.
  64406. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64407. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64408. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64409. * @param light The directional light object generating the shadows.
  64410. * @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.
  64411. */
  64412. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64413. protected _initializeGenerator(): void;
  64414. protected _createTargetRenderTexture(): void;
  64415. protected _initializeShadowMap(): void;
  64416. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64417. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64418. /**
  64419. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64420. * @param defines Defines of the material we want to update
  64421. * @param lightIndex Index of the light in the enabled light list of the material
  64422. */
  64423. prepareDefines(defines: any, lightIndex: number): void;
  64424. /**
  64425. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64426. * defined in the generator but impacting the effect).
  64427. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64428. * @param effect The effect we are binfing the information for
  64429. */
  64430. bindShadowLight(lightIndex: string, effect: Effect): void;
  64431. /**
  64432. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64433. * (eq to view projection * shadow projection matrices)
  64434. * @returns The transform matrix used to create the shadow map
  64435. */
  64436. getTransformMatrix(): Matrix;
  64437. /**
  64438. * Disposes the ShadowGenerator.
  64439. * Returns nothing.
  64440. */
  64441. dispose(): void;
  64442. /**
  64443. * Serializes the shadow generator setup to a json object.
  64444. * @returns The serialized JSON object
  64445. */
  64446. serialize(): any;
  64447. /**
  64448. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64449. * @param parsedShadowGenerator The JSON object to parse
  64450. * @param scene The scene to create the shadow map for
  64451. * @returns The parsed shadow generator
  64452. */
  64453. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64454. }
  64455. }
  64456. declare module BABYLON {
  64457. /**
  64458. * Defines the shadow generator component responsible to manage any shadow generators
  64459. * in a given scene.
  64460. */
  64461. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64462. /**
  64463. * The component name helpfull to identify the component in the list of scene components.
  64464. */
  64465. readonly name: string;
  64466. /**
  64467. * The scene the component belongs to.
  64468. */
  64469. scene: Scene;
  64470. /**
  64471. * Creates a new instance of the component for the given scene
  64472. * @param scene Defines the scene to register the component in
  64473. */
  64474. constructor(scene: Scene);
  64475. /**
  64476. * Registers the component in a given scene
  64477. */
  64478. register(): void;
  64479. /**
  64480. * Rebuilds the elements related to this component in case of
  64481. * context lost for instance.
  64482. */
  64483. rebuild(): void;
  64484. /**
  64485. * Serializes the component data to the specified json object
  64486. * @param serializationObject The object to serialize to
  64487. */
  64488. serialize(serializationObject: any): void;
  64489. /**
  64490. * Adds all the elements from the container to the scene
  64491. * @param container the container holding the elements
  64492. */
  64493. addFromContainer(container: AbstractScene): void;
  64494. /**
  64495. * Removes all the elements in the container from the scene
  64496. * @param container contains the elements to remove
  64497. * @param dispose if the removed element should be disposed (default: false)
  64498. */
  64499. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64500. /**
  64501. * Rebuilds the elements related to this component in case of
  64502. * context lost for instance.
  64503. */
  64504. dispose(): void;
  64505. private _gatherRenderTargets;
  64506. }
  64507. }
  64508. declare module BABYLON {
  64509. /**
  64510. * A point light is a light defined by an unique point in world space.
  64511. * The light is emitted in every direction from this point.
  64512. * A good example of a point light is a standard light bulb.
  64513. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64514. */
  64515. export class PointLight extends ShadowLight {
  64516. private _shadowAngle;
  64517. /**
  64518. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64519. * This specifies what angle the shadow will use to be created.
  64520. *
  64521. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64522. */
  64523. get shadowAngle(): number;
  64524. /**
  64525. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64526. * This specifies what angle the shadow will use to be created.
  64527. *
  64528. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64529. */
  64530. set shadowAngle(value: number);
  64531. /**
  64532. * Gets the direction if it has been set.
  64533. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64534. */
  64535. get direction(): Vector3;
  64536. /**
  64537. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64538. */
  64539. set direction(value: Vector3);
  64540. /**
  64541. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64542. * A PointLight emits the light in every direction.
  64543. * It can cast shadows.
  64544. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64545. * ```javascript
  64546. * var pointLight = new PointLight("pl", camera.position, scene);
  64547. * ```
  64548. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64549. * @param name The light friendly name
  64550. * @param position The position of the point light in the scene
  64551. * @param scene The scene the lights belongs to
  64552. */
  64553. constructor(name: string, position: Vector3, scene: Scene);
  64554. /**
  64555. * Returns the string "PointLight"
  64556. * @returns the class name
  64557. */
  64558. getClassName(): string;
  64559. /**
  64560. * Returns the integer 0.
  64561. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64562. */
  64563. getTypeID(): number;
  64564. /**
  64565. * Specifies wether or not the shadowmap should be a cube texture.
  64566. * @returns true if the shadowmap needs to be a cube texture.
  64567. */
  64568. needCube(): boolean;
  64569. /**
  64570. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64571. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64572. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64573. */
  64574. getShadowDirection(faceIndex?: number): Vector3;
  64575. /**
  64576. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64577. * - fov = PI / 2
  64578. * - aspect ratio : 1.0
  64579. * - z-near and far equal to the active camera minZ and maxZ.
  64580. * Returns the PointLight.
  64581. */
  64582. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64583. protected _buildUniformLayout(): void;
  64584. /**
  64585. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64586. * @param effect The effect to update
  64587. * @param lightIndex The index of the light in the effect to update
  64588. * @returns The point light
  64589. */
  64590. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64591. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64592. /**
  64593. * Prepares the list of defines specific to the light type.
  64594. * @param defines the list of defines
  64595. * @param lightIndex defines the index of the light for the effect
  64596. */
  64597. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64598. }
  64599. }
  64600. declare module BABYLON {
  64601. /**
  64602. * Header information of HDR texture files.
  64603. */
  64604. export interface HDRInfo {
  64605. /**
  64606. * The height of the texture in pixels.
  64607. */
  64608. height: number;
  64609. /**
  64610. * The width of the texture in pixels.
  64611. */
  64612. width: number;
  64613. /**
  64614. * The index of the beginning of the data in the binary file.
  64615. */
  64616. dataPosition: number;
  64617. }
  64618. /**
  64619. * This groups tools to convert HDR texture to native colors array.
  64620. */
  64621. export class HDRTools {
  64622. private static Ldexp;
  64623. private static Rgbe2float;
  64624. private static readStringLine;
  64625. /**
  64626. * Reads header information from an RGBE texture stored in a native array.
  64627. * More information on this format are available here:
  64628. * https://en.wikipedia.org/wiki/RGBE_image_format
  64629. *
  64630. * @param uint8array The binary file stored in native array.
  64631. * @return The header information.
  64632. */
  64633. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64634. /**
  64635. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64636. * This RGBE texture needs to store the information as a panorama.
  64637. *
  64638. * More information on this format are available here:
  64639. * https://en.wikipedia.org/wiki/RGBE_image_format
  64640. *
  64641. * @param buffer The binary file stored in an array buffer.
  64642. * @param size The expected size of the extracted cubemap.
  64643. * @return The Cube Map information.
  64644. */
  64645. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64646. /**
  64647. * Returns the pixels data extracted from an RGBE texture.
  64648. * This pixels will be stored left to right up to down in the R G B order in one array.
  64649. *
  64650. * More information on this format are available here:
  64651. * https://en.wikipedia.org/wiki/RGBE_image_format
  64652. *
  64653. * @param uint8array The binary file stored in an array buffer.
  64654. * @param hdrInfo The header information of the file.
  64655. * @return The pixels data in RGB right to left up to down order.
  64656. */
  64657. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64658. private static RGBE_ReadPixels_RLE;
  64659. private static RGBE_ReadPixels_NOT_RLE;
  64660. }
  64661. }
  64662. declare module BABYLON {
  64663. /**
  64664. * Effect Render Options
  64665. */
  64666. export interface IEffectRendererOptions {
  64667. /**
  64668. * Defines the vertices positions.
  64669. */
  64670. positions?: number[];
  64671. /**
  64672. * Defines the indices.
  64673. */
  64674. indices?: number[];
  64675. }
  64676. /**
  64677. * Helper class to render one or more effects.
  64678. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64679. */
  64680. export class EffectRenderer {
  64681. private engine;
  64682. private static _DefaultOptions;
  64683. private _vertexBuffers;
  64684. private _indexBuffer;
  64685. private _fullscreenViewport;
  64686. /**
  64687. * Creates an effect renderer
  64688. * @param engine the engine to use for rendering
  64689. * @param options defines the options of the effect renderer
  64690. */
  64691. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64692. /**
  64693. * Sets the current viewport in normalized coordinates 0-1
  64694. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64695. */
  64696. setViewport(viewport?: Viewport): void;
  64697. /**
  64698. * Binds the embedded attributes buffer to the effect.
  64699. * @param effect Defines the effect to bind the attributes for
  64700. */
  64701. bindBuffers(effect: Effect): void;
  64702. /**
  64703. * Sets the current effect wrapper to use during draw.
  64704. * The effect needs to be ready before calling this api.
  64705. * This also sets the default full screen position attribute.
  64706. * @param effectWrapper Defines the effect to draw with
  64707. */
  64708. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64709. /**
  64710. * Restores engine states
  64711. */
  64712. restoreStates(): void;
  64713. /**
  64714. * Draws a full screen quad.
  64715. */
  64716. draw(): void;
  64717. private isRenderTargetTexture;
  64718. /**
  64719. * renders one or more effects to a specified texture
  64720. * @param effectWrapper the effect to renderer
  64721. * @param outputTexture texture to draw to, if null it will render to the screen.
  64722. */
  64723. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64724. /**
  64725. * Disposes of the effect renderer
  64726. */
  64727. dispose(): void;
  64728. }
  64729. /**
  64730. * Options to create an EffectWrapper
  64731. */
  64732. interface EffectWrapperCreationOptions {
  64733. /**
  64734. * Engine to use to create the effect
  64735. */
  64736. engine: ThinEngine;
  64737. /**
  64738. * Fragment shader for the effect
  64739. */
  64740. fragmentShader: string;
  64741. /**
  64742. * Use the shader store instead of direct source code
  64743. */
  64744. useShaderStore?: boolean;
  64745. /**
  64746. * Vertex shader for the effect
  64747. */
  64748. vertexShader?: string;
  64749. /**
  64750. * Attributes to use in the shader
  64751. */
  64752. attributeNames?: Array<string>;
  64753. /**
  64754. * Uniforms to use in the shader
  64755. */
  64756. uniformNames?: Array<string>;
  64757. /**
  64758. * Texture sampler names to use in the shader
  64759. */
  64760. samplerNames?: Array<string>;
  64761. /**
  64762. * Defines to use in the shader
  64763. */
  64764. defines?: Array<string>;
  64765. /**
  64766. * Callback when effect is compiled
  64767. */
  64768. onCompiled?: Nullable<(effect: Effect) => void>;
  64769. /**
  64770. * The friendly name of the effect displayed in Spector.
  64771. */
  64772. name?: string;
  64773. }
  64774. /**
  64775. * Wraps an effect to be used for rendering
  64776. */
  64777. export class EffectWrapper {
  64778. /**
  64779. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64780. */
  64781. onApplyObservable: Observable<{}>;
  64782. /**
  64783. * The underlying effect
  64784. */
  64785. effect: Effect;
  64786. /**
  64787. * Creates an effect to be renderer
  64788. * @param creationOptions options to create the effect
  64789. */
  64790. constructor(creationOptions: EffectWrapperCreationOptions);
  64791. /**
  64792. * Disposes of the effect wrapper
  64793. */
  64794. dispose(): void;
  64795. }
  64796. }
  64797. declare module BABYLON {
  64798. /** @hidden */
  64799. export var hdrFilteringVertexShader: {
  64800. name: string;
  64801. shader: string;
  64802. };
  64803. }
  64804. declare module BABYLON {
  64805. /** @hidden */
  64806. export var hdrFilteringPixelShader: {
  64807. name: string;
  64808. shader: string;
  64809. };
  64810. }
  64811. declare module BABYLON {
  64812. /**
  64813. * Options for texture filtering
  64814. */
  64815. interface IHDRFilteringOptions {
  64816. /**
  64817. * Scales pixel intensity for the input HDR map.
  64818. */
  64819. hdrScale?: number;
  64820. /**
  64821. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64822. */
  64823. quality?: number;
  64824. }
  64825. /**
  64826. * Filters HDR maps to get correct renderings of PBR reflections
  64827. */
  64828. export class HDRFiltering {
  64829. private _engine;
  64830. private _effectRenderer;
  64831. private _effectWrapper;
  64832. private _lodGenerationOffset;
  64833. private _lodGenerationScale;
  64834. /**
  64835. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64836. * you care about baking speed.
  64837. */
  64838. quality: number;
  64839. /**
  64840. * Scales pixel intensity for the input HDR map.
  64841. */
  64842. hdrScale: number;
  64843. /**
  64844. * Instantiates HDR filter for reflection maps
  64845. *
  64846. * @param engine Thin engine
  64847. * @param options Options
  64848. */
  64849. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64850. private _createRenderTarget;
  64851. private _prefilterInternal;
  64852. private _createEffect;
  64853. /**
  64854. * Get a value indicating if the filter is ready to be used
  64855. * @param texture Texture to filter
  64856. * @returns true if the filter is ready
  64857. */
  64858. isReady(texture: BaseTexture): boolean;
  64859. /**
  64860. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64861. * Prefiltering will be invoked at the end of next rendering pass.
  64862. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64863. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64864. * @param texture Texture to filter
  64865. * @param onFinished Callback when filtering is done
  64866. * @return Promise called when prefiltering is done
  64867. */
  64868. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64869. }
  64870. }
  64871. declare module BABYLON {
  64872. /**
  64873. * This represents a texture coming from an HDR input.
  64874. *
  64875. * The only supported format is currently panorama picture stored in RGBE format.
  64876. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64877. */
  64878. export class HDRCubeTexture extends BaseTexture {
  64879. private static _facesMapping;
  64880. private _generateHarmonics;
  64881. private _noMipmap;
  64882. private _prefilterOnLoad;
  64883. private _textureMatrix;
  64884. private _size;
  64885. private _onLoad;
  64886. private _onError;
  64887. /**
  64888. * The texture URL.
  64889. */
  64890. url: string;
  64891. protected _isBlocking: boolean;
  64892. /**
  64893. * Sets wether or not the texture is blocking during loading.
  64894. */
  64895. set isBlocking(value: boolean);
  64896. /**
  64897. * Gets wether or not the texture is blocking during loading.
  64898. */
  64899. get isBlocking(): boolean;
  64900. protected _rotationY: number;
  64901. /**
  64902. * Sets texture matrix rotation angle around Y axis in radians.
  64903. */
  64904. set rotationY(value: number);
  64905. /**
  64906. * Gets texture matrix rotation angle around Y axis radians.
  64907. */
  64908. get rotationY(): number;
  64909. /**
  64910. * Gets or sets the center of the bounding box associated with the cube texture
  64911. * It must define where the camera used to render the texture was set
  64912. */
  64913. boundingBoxPosition: Vector3;
  64914. private _boundingBoxSize;
  64915. /**
  64916. * Gets or sets the size of the bounding box associated with the cube texture
  64917. * When defined, the cubemap will switch to local mode
  64918. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64919. * @example https://www.babylonjs-playground.com/#RNASML
  64920. */
  64921. set boundingBoxSize(value: Vector3);
  64922. get boundingBoxSize(): Vector3;
  64923. /**
  64924. * Instantiates an HDRTexture from the following parameters.
  64925. *
  64926. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64927. * @param sceneOrEngine The scene or engine the texture will be used in
  64928. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64929. * @param noMipmap Forces to not generate the mipmap if true
  64930. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64931. * @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)
  64932. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64933. */
  64934. 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>);
  64935. /**
  64936. * Get the current class name of the texture useful for serialization or dynamic coding.
  64937. * @returns "HDRCubeTexture"
  64938. */
  64939. getClassName(): string;
  64940. /**
  64941. * Occurs when the file is raw .hdr file.
  64942. */
  64943. private loadTexture;
  64944. clone(): HDRCubeTexture;
  64945. delayLoad(): void;
  64946. /**
  64947. * Get the texture reflection matrix used to rotate/transform the reflection.
  64948. * @returns the reflection matrix
  64949. */
  64950. getReflectionTextureMatrix(): Matrix;
  64951. /**
  64952. * Set the texture reflection matrix used to rotate/transform the reflection.
  64953. * @param value Define the reflection matrix to set
  64954. */
  64955. setReflectionTextureMatrix(value: Matrix): void;
  64956. /**
  64957. * Parses a JSON representation of an HDR Texture in order to create the texture
  64958. * @param parsedTexture Define the JSON representation
  64959. * @param scene Define the scene the texture should be created in
  64960. * @param rootUrl Define the root url in case we need to load relative dependencies
  64961. * @returns the newly created texture after parsing
  64962. */
  64963. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64964. serialize(): any;
  64965. }
  64966. }
  64967. declare module BABYLON {
  64968. /**
  64969. * Class used to control physics engine
  64970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64971. */
  64972. export class PhysicsEngine implements IPhysicsEngine {
  64973. private _physicsPlugin;
  64974. /**
  64975. * Global value used to control the smallest number supported by the simulation
  64976. */
  64977. static Epsilon: number;
  64978. private _impostors;
  64979. private _joints;
  64980. private _subTimeStep;
  64981. /**
  64982. * Gets the gravity vector used by the simulation
  64983. */
  64984. gravity: Vector3;
  64985. /**
  64986. * Factory used to create the default physics plugin.
  64987. * @returns The default physics plugin
  64988. */
  64989. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64990. /**
  64991. * Creates a new Physics Engine
  64992. * @param gravity defines the gravity vector used by the simulation
  64993. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64994. */
  64995. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64996. /**
  64997. * Sets the gravity vector used by the simulation
  64998. * @param gravity defines the gravity vector to use
  64999. */
  65000. setGravity(gravity: Vector3): void;
  65001. /**
  65002. * Set the time step of the physics engine.
  65003. * Default is 1/60.
  65004. * To slow it down, enter 1/600 for example.
  65005. * To speed it up, 1/30
  65006. * @param newTimeStep defines the new timestep to apply to this world.
  65007. */
  65008. setTimeStep(newTimeStep?: number): void;
  65009. /**
  65010. * Get the time step of the physics engine.
  65011. * @returns the current time step
  65012. */
  65013. getTimeStep(): number;
  65014. /**
  65015. * Set the sub time step of the physics engine.
  65016. * Default is 0 meaning there is no sub steps
  65017. * To increase physics resolution precision, set a small value (like 1 ms)
  65018. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65019. */
  65020. setSubTimeStep(subTimeStep?: number): void;
  65021. /**
  65022. * Get the sub time step of the physics engine.
  65023. * @returns the current sub time step
  65024. */
  65025. getSubTimeStep(): number;
  65026. /**
  65027. * Release all resources
  65028. */
  65029. dispose(): void;
  65030. /**
  65031. * Gets the name of the current physics plugin
  65032. * @returns the name of the plugin
  65033. */
  65034. getPhysicsPluginName(): string;
  65035. /**
  65036. * Adding a new impostor for the impostor tracking.
  65037. * This will be done by the impostor itself.
  65038. * @param impostor the impostor to add
  65039. */
  65040. addImpostor(impostor: PhysicsImpostor): void;
  65041. /**
  65042. * Remove an impostor from the engine.
  65043. * This impostor and its mesh will not longer be updated by the physics engine.
  65044. * @param impostor the impostor to remove
  65045. */
  65046. removeImpostor(impostor: PhysicsImpostor): void;
  65047. /**
  65048. * Add a joint to the physics engine
  65049. * @param mainImpostor defines the main impostor to which the joint is added.
  65050. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65051. * @param joint defines the joint that will connect both impostors.
  65052. */
  65053. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65054. /**
  65055. * Removes a joint from the simulation
  65056. * @param mainImpostor defines the impostor used with the joint
  65057. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65058. * @param joint defines the joint to remove
  65059. */
  65060. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65061. /**
  65062. * Called by the scene. No need to call it.
  65063. * @param delta defines the timespam between frames
  65064. */
  65065. _step(delta: number): void;
  65066. /**
  65067. * Gets the current plugin used to run the simulation
  65068. * @returns current plugin
  65069. */
  65070. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65071. /**
  65072. * Gets the list of physic impostors
  65073. * @returns an array of PhysicsImpostor
  65074. */
  65075. getImpostors(): Array<PhysicsImpostor>;
  65076. /**
  65077. * Gets the impostor for a physics enabled object
  65078. * @param object defines the object impersonated by the impostor
  65079. * @returns the PhysicsImpostor or null if not found
  65080. */
  65081. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65082. /**
  65083. * Gets the impostor for a physics body object
  65084. * @param body defines physics body used by the impostor
  65085. * @returns the PhysicsImpostor or null if not found
  65086. */
  65087. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65088. /**
  65089. * Does a raycast in the physics world
  65090. * @param from when should the ray start?
  65091. * @param to when should the ray end?
  65092. * @returns PhysicsRaycastResult
  65093. */
  65094. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65095. }
  65096. }
  65097. declare module BABYLON {
  65098. /** @hidden */
  65099. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65100. private _useDeltaForWorldStep;
  65101. world: any;
  65102. name: string;
  65103. private _physicsMaterials;
  65104. private _fixedTimeStep;
  65105. private _cannonRaycastResult;
  65106. private _raycastResult;
  65107. private _physicsBodysToRemoveAfterStep;
  65108. private _firstFrame;
  65109. BJSCANNON: any;
  65110. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65111. setGravity(gravity: Vector3): void;
  65112. setTimeStep(timeStep: number): void;
  65113. getTimeStep(): number;
  65114. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65115. private _removeMarkedPhysicsBodiesFromWorld;
  65116. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65117. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65118. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65119. private _processChildMeshes;
  65120. removePhysicsBody(impostor: PhysicsImpostor): void;
  65121. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65122. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65123. private _addMaterial;
  65124. private _checkWithEpsilon;
  65125. private _createShape;
  65126. private _createHeightmap;
  65127. private _minus90X;
  65128. private _plus90X;
  65129. private _tmpPosition;
  65130. private _tmpDeltaPosition;
  65131. private _tmpUnityRotation;
  65132. private _updatePhysicsBodyTransformation;
  65133. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65134. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65135. isSupported(): boolean;
  65136. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65137. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65138. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65139. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65140. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65141. getBodyMass(impostor: PhysicsImpostor): number;
  65142. getBodyFriction(impostor: PhysicsImpostor): number;
  65143. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65144. getBodyRestitution(impostor: PhysicsImpostor): number;
  65145. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65146. sleepBody(impostor: PhysicsImpostor): void;
  65147. wakeUpBody(impostor: PhysicsImpostor): void;
  65148. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65149. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65150. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65151. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65152. getRadius(impostor: PhysicsImpostor): number;
  65153. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65154. dispose(): void;
  65155. private _extendNamespace;
  65156. /**
  65157. * Does a raycast in the physics world
  65158. * @param from when should the ray start?
  65159. * @param to when should the ray end?
  65160. * @returns PhysicsRaycastResult
  65161. */
  65162. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65163. }
  65164. }
  65165. declare module BABYLON {
  65166. /** @hidden */
  65167. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65168. private _useDeltaForWorldStep;
  65169. world: any;
  65170. name: string;
  65171. BJSOIMO: any;
  65172. private _raycastResult;
  65173. private _fixedTimeStep;
  65174. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65175. setGravity(gravity: Vector3): void;
  65176. setTimeStep(timeStep: number): void;
  65177. getTimeStep(): number;
  65178. private _tmpImpostorsArray;
  65179. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65180. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65181. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65182. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65183. private _tmpPositionVector;
  65184. removePhysicsBody(impostor: PhysicsImpostor): void;
  65185. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65186. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65187. isSupported(): boolean;
  65188. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65189. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65190. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65191. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65192. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65193. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65194. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65195. getBodyMass(impostor: PhysicsImpostor): number;
  65196. getBodyFriction(impostor: PhysicsImpostor): number;
  65197. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65198. getBodyRestitution(impostor: PhysicsImpostor): number;
  65199. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65200. sleepBody(impostor: PhysicsImpostor): void;
  65201. wakeUpBody(impostor: PhysicsImpostor): void;
  65202. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65203. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65204. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65205. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65206. getRadius(impostor: PhysicsImpostor): number;
  65207. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65208. dispose(): void;
  65209. /**
  65210. * Does a raycast in the physics world
  65211. * @param from when should the ray start?
  65212. * @param to when should the ray end?
  65213. * @returns PhysicsRaycastResult
  65214. */
  65215. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65216. }
  65217. }
  65218. declare module BABYLON {
  65219. /**
  65220. * AmmoJS Physics plugin
  65221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65222. * @see https://github.com/kripken/ammo.js/
  65223. */
  65224. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65225. private _useDeltaForWorldStep;
  65226. /**
  65227. * Reference to the Ammo library
  65228. */
  65229. bjsAMMO: any;
  65230. /**
  65231. * Created ammoJS world which physics bodies are added to
  65232. */
  65233. world: any;
  65234. /**
  65235. * Name of the plugin
  65236. */
  65237. name: string;
  65238. private _timeStep;
  65239. private _fixedTimeStep;
  65240. private _maxSteps;
  65241. private _tmpQuaternion;
  65242. private _tmpAmmoTransform;
  65243. private _tmpAmmoQuaternion;
  65244. private _tmpAmmoConcreteContactResultCallback;
  65245. private _collisionConfiguration;
  65246. private _dispatcher;
  65247. private _overlappingPairCache;
  65248. private _solver;
  65249. private _softBodySolver;
  65250. private _tmpAmmoVectorA;
  65251. private _tmpAmmoVectorB;
  65252. private _tmpAmmoVectorC;
  65253. private _tmpAmmoVectorD;
  65254. private _tmpContactCallbackResult;
  65255. private _tmpAmmoVectorRCA;
  65256. private _tmpAmmoVectorRCB;
  65257. private _raycastResult;
  65258. private _tmpContactPoint;
  65259. private static readonly DISABLE_COLLISION_FLAG;
  65260. private static readonly KINEMATIC_FLAG;
  65261. private static readonly DISABLE_DEACTIVATION_FLAG;
  65262. /**
  65263. * Initializes the ammoJS plugin
  65264. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65265. * @param ammoInjection can be used to inject your own ammo reference
  65266. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65267. */
  65268. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65269. /**
  65270. * Sets the gravity of the physics world (m/(s^2))
  65271. * @param gravity Gravity to set
  65272. */
  65273. setGravity(gravity: Vector3): void;
  65274. /**
  65275. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65276. * @param timeStep timestep to use in seconds
  65277. */
  65278. setTimeStep(timeStep: number): void;
  65279. /**
  65280. * 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)
  65281. * @param fixedTimeStep fixedTimeStep to use in seconds
  65282. */
  65283. setFixedTimeStep(fixedTimeStep: number): void;
  65284. /**
  65285. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65286. * @param maxSteps the maximum number of steps by the physics engine per frame
  65287. */
  65288. setMaxSteps(maxSteps: number): void;
  65289. /**
  65290. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65291. * @returns the current timestep in seconds
  65292. */
  65293. getTimeStep(): number;
  65294. /**
  65295. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65296. */
  65297. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65298. private _isImpostorInContact;
  65299. private _isImpostorPairInContact;
  65300. private _stepSimulation;
  65301. /**
  65302. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65303. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65304. * After the step the babylon meshes are set to the position of the physics imposters
  65305. * @param delta amount of time to step forward
  65306. * @param impostors array of imposters to update before/after the step
  65307. */
  65308. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65309. /**
  65310. * Update babylon mesh to match physics world object
  65311. * @param impostor imposter to match
  65312. */
  65313. private _afterSoftStep;
  65314. /**
  65315. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65316. * @param impostor imposter to match
  65317. */
  65318. private _ropeStep;
  65319. /**
  65320. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65321. * @param impostor imposter to match
  65322. */
  65323. private _softbodyOrClothStep;
  65324. private _tmpMatrix;
  65325. /**
  65326. * Applies an impulse on the imposter
  65327. * @param impostor imposter to apply impulse to
  65328. * @param force amount of force to be applied to the imposter
  65329. * @param contactPoint the location to apply the impulse on the imposter
  65330. */
  65331. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65332. /**
  65333. * Applies a force on the imposter
  65334. * @param impostor imposter to apply force
  65335. * @param force amount of force to be applied to the imposter
  65336. * @param contactPoint the location to apply the force on the imposter
  65337. */
  65338. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65339. /**
  65340. * Creates a physics body using the plugin
  65341. * @param impostor the imposter to create the physics body on
  65342. */
  65343. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65344. /**
  65345. * Removes the physics body from the imposter and disposes of the body's memory
  65346. * @param impostor imposter to remove the physics body from
  65347. */
  65348. removePhysicsBody(impostor: PhysicsImpostor): void;
  65349. /**
  65350. * Generates a joint
  65351. * @param impostorJoint the imposter joint to create the joint with
  65352. */
  65353. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65354. /**
  65355. * Removes a joint
  65356. * @param impostorJoint the imposter joint to remove the joint from
  65357. */
  65358. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65359. private _addMeshVerts;
  65360. /**
  65361. * Initialise the soft body vertices to match its object's (mesh) vertices
  65362. * Softbody vertices (nodes) are in world space and to match this
  65363. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65364. * @param impostor to create the softbody for
  65365. */
  65366. private _softVertexData;
  65367. /**
  65368. * Create an impostor's soft body
  65369. * @param impostor to create the softbody for
  65370. */
  65371. private _createSoftbody;
  65372. /**
  65373. * Create cloth for an impostor
  65374. * @param impostor to create the softbody for
  65375. */
  65376. private _createCloth;
  65377. /**
  65378. * Create rope for an impostor
  65379. * @param impostor to create the softbody for
  65380. */
  65381. private _createRope;
  65382. /**
  65383. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65384. * @param impostor to create the custom physics shape for
  65385. */
  65386. private _createCustom;
  65387. private _addHullVerts;
  65388. private _createShape;
  65389. /**
  65390. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65391. * @param impostor imposter containing the physics body and babylon object
  65392. */
  65393. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65394. /**
  65395. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65396. * @param impostor imposter containing the physics body and babylon object
  65397. * @param newPosition new position
  65398. * @param newRotation new rotation
  65399. */
  65400. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65401. /**
  65402. * If this plugin is supported
  65403. * @returns true if its supported
  65404. */
  65405. isSupported(): boolean;
  65406. /**
  65407. * Sets the linear velocity of the physics body
  65408. * @param impostor imposter to set the velocity on
  65409. * @param velocity velocity to set
  65410. */
  65411. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65412. /**
  65413. * Sets the angular velocity of the physics body
  65414. * @param impostor imposter to set the velocity on
  65415. * @param velocity velocity to set
  65416. */
  65417. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65418. /**
  65419. * gets the linear velocity
  65420. * @param impostor imposter to get linear velocity from
  65421. * @returns linear velocity
  65422. */
  65423. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65424. /**
  65425. * gets the angular velocity
  65426. * @param impostor imposter to get angular velocity from
  65427. * @returns angular velocity
  65428. */
  65429. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65430. /**
  65431. * Sets the mass of physics body
  65432. * @param impostor imposter to set the mass on
  65433. * @param mass mass to set
  65434. */
  65435. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65436. /**
  65437. * Gets the mass of the physics body
  65438. * @param impostor imposter to get the mass from
  65439. * @returns mass
  65440. */
  65441. getBodyMass(impostor: PhysicsImpostor): number;
  65442. /**
  65443. * Gets friction of the impostor
  65444. * @param impostor impostor to get friction from
  65445. * @returns friction value
  65446. */
  65447. getBodyFriction(impostor: PhysicsImpostor): number;
  65448. /**
  65449. * Sets friction of the impostor
  65450. * @param impostor impostor to set friction on
  65451. * @param friction friction value
  65452. */
  65453. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65454. /**
  65455. * Gets restitution of the impostor
  65456. * @param impostor impostor to get restitution from
  65457. * @returns restitution value
  65458. */
  65459. getBodyRestitution(impostor: PhysicsImpostor): number;
  65460. /**
  65461. * Sets resitution of the impostor
  65462. * @param impostor impostor to set resitution on
  65463. * @param restitution resitution value
  65464. */
  65465. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65466. /**
  65467. * Gets pressure inside the impostor
  65468. * @param impostor impostor to get pressure from
  65469. * @returns pressure value
  65470. */
  65471. getBodyPressure(impostor: PhysicsImpostor): number;
  65472. /**
  65473. * Sets pressure inside a soft body impostor
  65474. * Cloth and rope must remain 0 pressure
  65475. * @param impostor impostor to set pressure on
  65476. * @param pressure pressure value
  65477. */
  65478. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65479. /**
  65480. * Gets stiffness of the impostor
  65481. * @param impostor impostor to get stiffness from
  65482. * @returns pressure value
  65483. */
  65484. getBodyStiffness(impostor: PhysicsImpostor): number;
  65485. /**
  65486. * Sets stiffness of the impostor
  65487. * @param impostor impostor to set stiffness on
  65488. * @param stiffness stiffness value from 0 to 1
  65489. */
  65490. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65491. /**
  65492. * Gets velocityIterations of the impostor
  65493. * @param impostor impostor to get velocity iterations from
  65494. * @returns velocityIterations value
  65495. */
  65496. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65497. /**
  65498. * Sets velocityIterations of the impostor
  65499. * @param impostor impostor to set velocity iterations on
  65500. * @param velocityIterations velocityIterations value
  65501. */
  65502. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65503. /**
  65504. * Gets positionIterations of the impostor
  65505. * @param impostor impostor to get position iterations from
  65506. * @returns positionIterations value
  65507. */
  65508. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65509. /**
  65510. * Sets positionIterations of the impostor
  65511. * @param impostor impostor to set position on
  65512. * @param positionIterations positionIterations value
  65513. */
  65514. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65515. /**
  65516. * Append an anchor to a cloth object
  65517. * @param impostor is the cloth impostor to add anchor to
  65518. * @param otherImpostor is the rigid impostor to anchor to
  65519. * @param width ratio across width from 0 to 1
  65520. * @param height ratio up height from 0 to 1
  65521. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65522. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65523. */
  65524. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65525. /**
  65526. * Append an hook to a rope object
  65527. * @param impostor is the rope impostor to add hook to
  65528. * @param otherImpostor is the rigid impostor to hook to
  65529. * @param length ratio along the rope from 0 to 1
  65530. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65531. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65532. */
  65533. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65534. /**
  65535. * Sleeps the physics body and stops it from being active
  65536. * @param impostor impostor to sleep
  65537. */
  65538. sleepBody(impostor: PhysicsImpostor): void;
  65539. /**
  65540. * Activates the physics body
  65541. * @param impostor impostor to activate
  65542. */
  65543. wakeUpBody(impostor: PhysicsImpostor): void;
  65544. /**
  65545. * Updates the distance parameters of the joint
  65546. * @param joint joint to update
  65547. * @param maxDistance maximum distance of the joint
  65548. * @param minDistance minimum distance of the joint
  65549. */
  65550. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65551. /**
  65552. * Sets a motor on the joint
  65553. * @param joint joint to set motor on
  65554. * @param speed speed of the motor
  65555. * @param maxForce maximum force of the motor
  65556. * @param motorIndex index of the motor
  65557. */
  65558. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65559. /**
  65560. * Sets the motors limit
  65561. * @param joint joint to set limit on
  65562. * @param upperLimit upper limit
  65563. * @param lowerLimit lower limit
  65564. */
  65565. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65566. /**
  65567. * Syncs the position and rotation of a mesh with the impostor
  65568. * @param mesh mesh to sync
  65569. * @param impostor impostor to update the mesh with
  65570. */
  65571. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65572. /**
  65573. * Gets the radius of the impostor
  65574. * @param impostor impostor to get radius from
  65575. * @returns the radius
  65576. */
  65577. getRadius(impostor: PhysicsImpostor): number;
  65578. /**
  65579. * Gets the box size of the impostor
  65580. * @param impostor impostor to get box size from
  65581. * @param result the resulting box size
  65582. */
  65583. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65584. /**
  65585. * Disposes of the impostor
  65586. */
  65587. dispose(): void;
  65588. /**
  65589. * Does a raycast in the physics world
  65590. * @param from when should the ray start?
  65591. * @param to when should the ray end?
  65592. * @returns PhysicsRaycastResult
  65593. */
  65594. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65595. }
  65596. }
  65597. declare module BABYLON {
  65598. interface AbstractScene {
  65599. /**
  65600. * The list of reflection probes added to the scene
  65601. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65602. */
  65603. reflectionProbes: Array<ReflectionProbe>;
  65604. /**
  65605. * Removes the given reflection probe from this scene.
  65606. * @param toRemove The reflection probe to remove
  65607. * @returns The index of the removed reflection probe
  65608. */
  65609. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65610. /**
  65611. * Adds the given reflection probe to this scene.
  65612. * @param newReflectionProbe The reflection probe to add
  65613. */
  65614. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65615. }
  65616. /**
  65617. * Class used to generate realtime reflection / refraction cube textures
  65618. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65619. */
  65620. export class ReflectionProbe {
  65621. /** defines the name of the probe */
  65622. name: string;
  65623. private _scene;
  65624. private _renderTargetTexture;
  65625. private _projectionMatrix;
  65626. private _viewMatrix;
  65627. private _target;
  65628. private _add;
  65629. private _attachedMesh;
  65630. private _invertYAxis;
  65631. /** Gets or sets probe position (center of the cube map) */
  65632. position: Vector3;
  65633. /**
  65634. * Creates a new reflection probe
  65635. * @param name defines the name of the probe
  65636. * @param size defines the texture resolution (for each face)
  65637. * @param scene defines the hosting scene
  65638. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65639. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65640. */
  65641. constructor(
  65642. /** defines the name of the probe */
  65643. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65644. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65645. get samples(): number;
  65646. set samples(value: number);
  65647. /** Gets or sets the refresh rate to use (on every frame by default) */
  65648. get refreshRate(): number;
  65649. set refreshRate(value: number);
  65650. /**
  65651. * Gets the hosting scene
  65652. * @returns a Scene
  65653. */
  65654. getScene(): Scene;
  65655. /** Gets the internal CubeTexture used to render to */
  65656. get cubeTexture(): RenderTargetTexture;
  65657. /** Gets the list of meshes to render */
  65658. get renderList(): Nullable<AbstractMesh[]>;
  65659. /**
  65660. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65661. * @param mesh defines the mesh to attach to
  65662. */
  65663. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65664. /**
  65665. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65666. * @param renderingGroupId The rendering group id corresponding to its index
  65667. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65668. */
  65669. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65670. /**
  65671. * Clean all associated resources
  65672. */
  65673. dispose(): void;
  65674. /**
  65675. * Converts the reflection probe information to a readable string for debug purpose.
  65676. * @param fullDetails Supports for multiple levels of logging within scene loading
  65677. * @returns the human readable reflection probe info
  65678. */
  65679. toString(fullDetails?: boolean): string;
  65680. /**
  65681. * Get the class name of the relfection probe.
  65682. * @returns "ReflectionProbe"
  65683. */
  65684. getClassName(): string;
  65685. /**
  65686. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65687. * @returns The JSON representation of the texture
  65688. */
  65689. serialize(): any;
  65690. /**
  65691. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65692. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65693. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65694. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65695. * @returns The parsed reflection probe if successful
  65696. */
  65697. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65698. }
  65699. }
  65700. declare module BABYLON {
  65701. /** @hidden */
  65702. export var _BabylonLoaderRegistered: boolean;
  65703. /**
  65704. * Helps setting up some configuration for the babylon file loader.
  65705. */
  65706. export class BabylonFileLoaderConfiguration {
  65707. /**
  65708. * The loader does not allow injecting custom physix engine into the plugins.
  65709. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65710. * So you could set this variable to your engine import to make it work.
  65711. */
  65712. static LoaderInjectedPhysicsEngine: any;
  65713. }
  65714. }
  65715. declare module BABYLON {
  65716. /**
  65717. * A material to use for fast depth-only rendering.
  65718. */
  65719. export class OcclusionMaterial extends ShaderMaterial {
  65720. constructor(name: string, scene: Scene);
  65721. }
  65722. }
  65723. declare module BABYLON {
  65724. /**
  65725. * The Physically based simple base material of BJS.
  65726. *
  65727. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65728. * It is used as the base class for both the specGloss and metalRough conventions.
  65729. */
  65730. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65731. /**
  65732. * Number of Simultaneous lights allowed on the material.
  65733. */
  65734. maxSimultaneousLights: number;
  65735. /**
  65736. * If sets to true, disables all the lights affecting the material.
  65737. */
  65738. disableLighting: boolean;
  65739. /**
  65740. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65741. */
  65742. environmentTexture: BaseTexture;
  65743. /**
  65744. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65745. */
  65746. invertNormalMapX: boolean;
  65747. /**
  65748. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65749. */
  65750. invertNormalMapY: boolean;
  65751. /**
  65752. * Normal map used in the model.
  65753. */
  65754. normalTexture: BaseTexture;
  65755. /**
  65756. * Emissivie color used to self-illuminate the model.
  65757. */
  65758. emissiveColor: Color3;
  65759. /**
  65760. * Emissivie texture used to self-illuminate the model.
  65761. */
  65762. emissiveTexture: BaseTexture;
  65763. /**
  65764. * Occlusion Channel Strenght.
  65765. */
  65766. occlusionStrength: number;
  65767. /**
  65768. * Occlusion Texture of the material (adding extra occlusion effects).
  65769. */
  65770. occlusionTexture: BaseTexture;
  65771. /**
  65772. * Defines the alpha limits in alpha test mode.
  65773. */
  65774. alphaCutOff: number;
  65775. /**
  65776. * Gets the current double sided mode.
  65777. */
  65778. get doubleSided(): boolean;
  65779. /**
  65780. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65781. */
  65782. set doubleSided(value: boolean);
  65783. /**
  65784. * Stores the pre-calculated light information of a mesh in a texture.
  65785. */
  65786. lightmapTexture: BaseTexture;
  65787. /**
  65788. * If true, the light map contains occlusion information instead of lighting info.
  65789. */
  65790. useLightmapAsShadowmap: boolean;
  65791. /**
  65792. * Instantiates a new PBRMaterial instance.
  65793. *
  65794. * @param name The material name
  65795. * @param scene The scene the material will be use in.
  65796. */
  65797. constructor(name: string, scene: Scene);
  65798. getClassName(): string;
  65799. }
  65800. }
  65801. declare module BABYLON {
  65802. /**
  65803. * The PBR material of BJS following the metal roughness convention.
  65804. *
  65805. * This fits to the PBR convention in the GLTF definition:
  65806. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65807. */
  65808. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65809. /**
  65810. * The base color has two different interpretations depending on the value of metalness.
  65811. * When the material is a metal, the base color is the specific measured reflectance value
  65812. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65813. * of the material.
  65814. */
  65815. baseColor: Color3;
  65816. /**
  65817. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65818. * well as opacity information in the alpha channel.
  65819. */
  65820. baseTexture: BaseTexture;
  65821. /**
  65822. * Specifies the metallic scalar value of the material.
  65823. * Can also be used to scale the metalness values of the metallic texture.
  65824. */
  65825. metallic: number;
  65826. /**
  65827. * Specifies the roughness scalar value of the material.
  65828. * Can also be used to scale the roughness values of the metallic texture.
  65829. */
  65830. roughness: number;
  65831. /**
  65832. * Texture containing both the metallic value in the B channel and the
  65833. * roughness value in the G channel to keep better precision.
  65834. */
  65835. metallicRoughnessTexture: BaseTexture;
  65836. /**
  65837. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65838. *
  65839. * @param name The material name
  65840. * @param scene The scene the material will be use in.
  65841. */
  65842. constructor(name: string, scene: Scene);
  65843. /**
  65844. * Return the currrent class name of the material.
  65845. */
  65846. getClassName(): string;
  65847. /**
  65848. * Makes a duplicate of the current material.
  65849. * @param name - name to use for the new material.
  65850. */
  65851. clone(name: string): PBRMetallicRoughnessMaterial;
  65852. /**
  65853. * Serialize the material to a parsable JSON object.
  65854. */
  65855. serialize(): any;
  65856. /**
  65857. * Parses a JSON object correponding to the serialize function.
  65858. */
  65859. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65860. }
  65861. }
  65862. declare module BABYLON {
  65863. /**
  65864. * The PBR material of BJS following the specular glossiness convention.
  65865. *
  65866. * This fits to the PBR convention in the GLTF definition:
  65867. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65868. */
  65869. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65870. /**
  65871. * Specifies the diffuse color of the material.
  65872. */
  65873. diffuseColor: Color3;
  65874. /**
  65875. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65876. * channel.
  65877. */
  65878. diffuseTexture: BaseTexture;
  65879. /**
  65880. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65881. */
  65882. specularColor: Color3;
  65883. /**
  65884. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65885. */
  65886. glossiness: number;
  65887. /**
  65888. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65889. */
  65890. specularGlossinessTexture: BaseTexture;
  65891. /**
  65892. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65893. */
  65894. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65895. /**
  65896. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65897. *
  65898. * @param name The material name
  65899. * @param scene The scene the material will be use in.
  65900. */
  65901. constructor(name: string, scene: Scene);
  65902. /**
  65903. * Return the currrent class name of the material.
  65904. */
  65905. getClassName(): string;
  65906. /**
  65907. * Makes a duplicate of the current material.
  65908. * @param name - name to use for the new material.
  65909. */
  65910. clone(name: string): PBRSpecularGlossinessMaterial;
  65911. /**
  65912. * Serialize the material to a parsable JSON object.
  65913. */
  65914. serialize(): any;
  65915. /**
  65916. * Parses a JSON object correponding to the serialize function.
  65917. */
  65918. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65919. }
  65920. }
  65921. declare module BABYLON {
  65922. /**
  65923. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65924. * It can help converting any input color in a desired output one. This can then be used to create effects
  65925. * from sepia, black and white to sixties or futuristic rendering...
  65926. *
  65927. * The only supported format is currently 3dl.
  65928. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65929. */
  65930. export class ColorGradingTexture extends BaseTexture {
  65931. /**
  65932. * The texture URL.
  65933. */
  65934. url: string;
  65935. /**
  65936. * Empty line regex stored for GC.
  65937. */
  65938. private static _noneEmptyLineRegex;
  65939. private _textureMatrix;
  65940. private _onLoad;
  65941. /**
  65942. * Instantiates a ColorGradingTexture from the following parameters.
  65943. *
  65944. * @param url The location of the color gradind data (currently only supporting 3dl)
  65945. * @param sceneOrEngine The scene or engine the texture will be used in
  65946. * @param onLoad defines a callback triggered when the texture has been loaded
  65947. */
  65948. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65949. /**
  65950. * Fires the onload event from the constructor if requested.
  65951. */
  65952. private _triggerOnLoad;
  65953. /**
  65954. * Returns the texture matrix used in most of the material.
  65955. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65956. */
  65957. getTextureMatrix(): Matrix;
  65958. /**
  65959. * Occurs when the file being loaded is a .3dl LUT file.
  65960. */
  65961. private load3dlTexture;
  65962. /**
  65963. * Starts the loading process of the texture.
  65964. */
  65965. private loadTexture;
  65966. /**
  65967. * Clones the color gradind texture.
  65968. */
  65969. clone(): ColorGradingTexture;
  65970. /**
  65971. * Called during delayed load for textures.
  65972. */
  65973. delayLoad(): void;
  65974. /**
  65975. * Parses a color grading texture serialized by Babylon.
  65976. * @param parsedTexture The texture information being parsedTexture
  65977. * @param scene The scene to load the texture in
  65978. * @param rootUrl The root url of the data assets to load
  65979. * @return A color gradind texture
  65980. */
  65981. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65982. /**
  65983. * Serializes the LUT texture to json format.
  65984. */
  65985. serialize(): any;
  65986. }
  65987. }
  65988. declare module BABYLON {
  65989. /**
  65990. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65991. */
  65992. export class EquiRectangularCubeTexture extends BaseTexture {
  65993. /** The six faces of the cube. */
  65994. private static _FacesMapping;
  65995. private _noMipmap;
  65996. private _onLoad;
  65997. private _onError;
  65998. /** The size of the cubemap. */
  65999. private _size;
  66000. /** The buffer of the image. */
  66001. private _buffer;
  66002. /** The width of the input image. */
  66003. private _width;
  66004. /** The height of the input image. */
  66005. private _height;
  66006. /** The URL to the image. */
  66007. url: string;
  66008. /**
  66009. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66010. * @param url The location of the image
  66011. * @param scene The scene the texture will be used in
  66012. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66013. * @param noMipmap Forces to not generate the mipmap if true
  66014. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66015. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66016. * @param onLoad — defines a callback called when texture is loaded
  66017. * @param onError — defines a callback called if there is an error
  66018. */
  66019. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66020. /**
  66021. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66022. */
  66023. private loadImage;
  66024. /**
  66025. * Convert the image buffer into a cubemap and create a CubeTexture.
  66026. */
  66027. private loadTexture;
  66028. /**
  66029. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66030. * @param buffer The ArrayBuffer that should be converted.
  66031. * @returns The buffer as Float32Array.
  66032. */
  66033. private getFloat32ArrayFromArrayBuffer;
  66034. /**
  66035. * Get the current class name of the texture useful for serialization or dynamic coding.
  66036. * @returns "EquiRectangularCubeTexture"
  66037. */
  66038. getClassName(): string;
  66039. /**
  66040. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66041. * @returns A clone of the current EquiRectangularCubeTexture.
  66042. */
  66043. clone(): EquiRectangularCubeTexture;
  66044. }
  66045. }
  66046. declare module BABYLON {
  66047. /**
  66048. * Defines the options related to the creation of an HtmlElementTexture
  66049. */
  66050. export interface IHtmlElementTextureOptions {
  66051. /**
  66052. * Defines wether mip maps should be created or not.
  66053. */
  66054. generateMipMaps?: boolean;
  66055. /**
  66056. * Defines the sampling mode of the texture.
  66057. */
  66058. samplingMode?: number;
  66059. /**
  66060. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66061. */
  66062. engine: Nullable<ThinEngine>;
  66063. /**
  66064. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66065. */
  66066. scene: Nullable<Scene>;
  66067. }
  66068. /**
  66069. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66070. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66071. * is automatically managed.
  66072. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66073. * in your application.
  66074. *
  66075. * As the update is not automatic, you need to call them manually.
  66076. */
  66077. export class HtmlElementTexture extends BaseTexture {
  66078. /**
  66079. * The texture URL.
  66080. */
  66081. element: HTMLVideoElement | HTMLCanvasElement;
  66082. private static readonly DefaultOptions;
  66083. private _textureMatrix;
  66084. private _isVideo;
  66085. private _generateMipMaps;
  66086. private _samplingMode;
  66087. /**
  66088. * Instantiates a HtmlElementTexture from the following parameters.
  66089. *
  66090. * @param name Defines the name of the texture
  66091. * @param element Defines the video or canvas the texture is filled with
  66092. * @param options Defines the other none mandatory texture creation options
  66093. */
  66094. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66095. private _createInternalTexture;
  66096. /**
  66097. * Returns the texture matrix used in most of the material.
  66098. */
  66099. getTextureMatrix(): Matrix;
  66100. /**
  66101. * Updates the content of the texture.
  66102. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66103. */
  66104. update(invertY?: Nullable<boolean>): void;
  66105. }
  66106. }
  66107. declare module BABYLON {
  66108. /**
  66109. * Based on jsTGALoader - Javascript loader for TGA file
  66110. * By Vincent Thibault
  66111. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66112. */
  66113. export class TGATools {
  66114. private static _TYPE_INDEXED;
  66115. private static _TYPE_RGB;
  66116. private static _TYPE_GREY;
  66117. private static _TYPE_RLE_INDEXED;
  66118. private static _TYPE_RLE_RGB;
  66119. private static _TYPE_RLE_GREY;
  66120. private static _ORIGIN_MASK;
  66121. private static _ORIGIN_SHIFT;
  66122. private static _ORIGIN_BL;
  66123. private static _ORIGIN_BR;
  66124. private static _ORIGIN_UL;
  66125. private static _ORIGIN_UR;
  66126. /**
  66127. * Gets the header of a TGA file
  66128. * @param data defines the TGA data
  66129. * @returns the header
  66130. */
  66131. static GetTGAHeader(data: Uint8Array): any;
  66132. /**
  66133. * Uploads TGA content to a Babylon Texture
  66134. * @hidden
  66135. */
  66136. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66137. /** @hidden */
  66138. 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;
  66139. /** @hidden */
  66140. 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;
  66141. /** @hidden */
  66142. 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;
  66143. /** @hidden */
  66144. 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;
  66145. /** @hidden */
  66146. 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;
  66147. /** @hidden */
  66148. 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;
  66149. }
  66150. }
  66151. declare module BABYLON {
  66152. /**
  66153. * Implementation of the TGA Texture Loader.
  66154. * @hidden
  66155. */
  66156. export class _TGATextureLoader implements IInternalTextureLoader {
  66157. /**
  66158. * Defines wether the loader supports cascade loading the different faces.
  66159. */
  66160. readonly supportCascades: boolean;
  66161. /**
  66162. * This returns if the loader support the current file information.
  66163. * @param extension defines the file extension of the file being loaded
  66164. * @returns true if the loader can load the specified file
  66165. */
  66166. canLoad(extension: string): boolean;
  66167. /**
  66168. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66169. * @param data contains the texture data
  66170. * @param texture defines the BabylonJS internal texture
  66171. * @param createPolynomials will be true if polynomials have been requested
  66172. * @param onLoad defines the callback to trigger once the texture is ready
  66173. * @param onError defines the callback to trigger in case of error
  66174. */
  66175. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66176. /**
  66177. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66178. * @param data contains the texture data
  66179. * @param texture defines the BabylonJS internal texture
  66180. * @param callback defines the method to call once ready to upload
  66181. */
  66182. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66183. }
  66184. }
  66185. declare module BABYLON {
  66186. /**
  66187. * Implementation of the HDR Texture Loader.
  66188. * @hidden
  66189. */
  66190. export class _HDRTextureLoader implements IInternalTextureLoader {
  66191. /**
  66192. * Defines wether the loader supports cascade loading the different faces.
  66193. */
  66194. readonly supportCascades: boolean;
  66195. /**
  66196. * This returns if the loader support the current file information.
  66197. * @param extension defines the file extension of the file being loaded
  66198. * @returns true if the loader can load the specified file
  66199. */
  66200. canLoad(extension: string): boolean;
  66201. /**
  66202. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66203. * @param data contains the texture data
  66204. * @param texture defines the BabylonJS internal texture
  66205. * @param createPolynomials will be true if polynomials have been requested
  66206. * @param onLoad defines the callback to trigger once the texture is ready
  66207. * @param onError defines the callback to trigger in case of error
  66208. */
  66209. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66210. /**
  66211. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66212. * @param data contains the texture data
  66213. * @param texture defines the BabylonJS internal texture
  66214. * @param callback defines the method to call once ready to upload
  66215. */
  66216. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66217. }
  66218. }
  66219. declare module BABYLON {
  66220. /**
  66221. * Info about the .basis files
  66222. */
  66223. class BasisFileInfo {
  66224. /**
  66225. * If the file has alpha
  66226. */
  66227. hasAlpha: boolean;
  66228. /**
  66229. * Info about each image of the basis file
  66230. */
  66231. images: Array<{
  66232. levels: Array<{
  66233. width: number;
  66234. height: number;
  66235. transcodedPixels: ArrayBufferView;
  66236. }>;
  66237. }>;
  66238. }
  66239. /**
  66240. * Result of transcoding a basis file
  66241. */
  66242. class TranscodeResult {
  66243. /**
  66244. * Info about the .basis file
  66245. */
  66246. fileInfo: BasisFileInfo;
  66247. /**
  66248. * Format to use when loading the file
  66249. */
  66250. format: number;
  66251. }
  66252. /**
  66253. * Configuration options for the Basis transcoder
  66254. */
  66255. export class BasisTranscodeConfiguration {
  66256. /**
  66257. * Supported compression formats used to determine the supported output format of the transcoder
  66258. */
  66259. supportedCompressionFormats?: {
  66260. /**
  66261. * etc1 compression format
  66262. */
  66263. etc1?: boolean;
  66264. /**
  66265. * s3tc compression format
  66266. */
  66267. s3tc?: boolean;
  66268. /**
  66269. * pvrtc compression format
  66270. */
  66271. pvrtc?: boolean;
  66272. /**
  66273. * etc2 compression format
  66274. */
  66275. etc2?: boolean;
  66276. };
  66277. /**
  66278. * If mipmap levels should be loaded for transcoded images (Default: true)
  66279. */
  66280. loadMipmapLevels?: boolean;
  66281. /**
  66282. * Index of a single image to load (Default: all images)
  66283. */
  66284. loadSingleImage?: number;
  66285. }
  66286. /**
  66287. * Used to load .Basis files
  66288. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66289. */
  66290. export class BasisTools {
  66291. private static _IgnoreSupportedFormats;
  66292. /**
  66293. * URL to use when loading the basis transcoder
  66294. */
  66295. static JSModuleURL: string;
  66296. /**
  66297. * URL to use when loading the wasm module for the transcoder
  66298. */
  66299. static WasmModuleURL: string;
  66300. /**
  66301. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66302. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66303. * @returns internal format corresponding to the Basis format
  66304. */
  66305. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66306. private static _WorkerPromise;
  66307. private static _Worker;
  66308. private static _actionId;
  66309. private static _CreateWorkerAsync;
  66310. /**
  66311. * Transcodes a loaded image file to compressed pixel data
  66312. * @param data image data to transcode
  66313. * @param config configuration options for the transcoding
  66314. * @returns a promise resulting in the transcoded image
  66315. */
  66316. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66317. /**
  66318. * Loads a texture from the transcode result
  66319. * @param texture texture load to
  66320. * @param transcodeResult the result of transcoding the basis file to load from
  66321. */
  66322. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66323. }
  66324. }
  66325. declare module BABYLON {
  66326. /**
  66327. * Loader for .basis file format
  66328. */
  66329. export class _BasisTextureLoader implements IInternalTextureLoader {
  66330. /**
  66331. * Defines whether the loader supports cascade loading the different faces.
  66332. */
  66333. readonly supportCascades: boolean;
  66334. /**
  66335. * This returns if the loader support the current file information.
  66336. * @param extension defines the file extension of the file being loaded
  66337. * @returns true if the loader can load the specified file
  66338. */
  66339. canLoad(extension: string): boolean;
  66340. /**
  66341. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66342. * @param data contains the texture data
  66343. * @param texture defines the BabylonJS internal texture
  66344. * @param createPolynomials will be true if polynomials have been requested
  66345. * @param onLoad defines the callback to trigger once the texture is ready
  66346. * @param onError defines the callback to trigger in case of error
  66347. */
  66348. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66349. /**
  66350. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66351. * @param data contains the texture data
  66352. * @param texture defines the BabylonJS internal texture
  66353. * @param callback defines the method to call once ready to upload
  66354. */
  66355. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66356. }
  66357. }
  66358. declare module BABYLON {
  66359. /**
  66360. * Defines the basic options interface of a TexturePacker Frame
  66361. */
  66362. export interface ITexturePackerFrame {
  66363. /**
  66364. * The frame ID
  66365. */
  66366. id: number;
  66367. /**
  66368. * The frames Scale
  66369. */
  66370. scale: Vector2;
  66371. /**
  66372. * The Frames offset
  66373. */
  66374. offset: Vector2;
  66375. }
  66376. /**
  66377. * This is a support class for frame Data on texture packer sets.
  66378. */
  66379. export class TexturePackerFrame implements ITexturePackerFrame {
  66380. /**
  66381. * The frame ID
  66382. */
  66383. id: number;
  66384. /**
  66385. * The frames Scale
  66386. */
  66387. scale: Vector2;
  66388. /**
  66389. * The Frames offset
  66390. */
  66391. offset: Vector2;
  66392. /**
  66393. * Initializes a texture package frame.
  66394. * @param id The numerical frame identifier
  66395. * @param scale Scalar Vector2 for UV frame
  66396. * @param offset Vector2 for the frame position in UV units.
  66397. * @returns TexturePackerFrame
  66398. */
  66399. constructor(id: number, scale: Vector2, offset: Vector2);
  66400. }
  66401. }
  66402. declare module BABYLON {
  66403. /**
  66404. * Defines the basic options interface of a TexturePacker
  66405. */
  66406. export interface ITexturePackerOptions {
  66407. /**
  66408. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66409. */
  66410. map?: string[];
  66411. /**
  66412. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66413. */
  66414. uvsIn?: string;
  66415. /**
  66416. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66417. */
  66418. uvsOut?: string;
  66419. /**
  66420. * number representing the layout style. Defaults to LAYOUT_STRIP
  66421. */
  66422. layout?: number;
  66423. /**
  66424. * number of columns if using custom column count layout(2). This defaults to 4.
  66425. */
  66426. colnum?: number;
  66427. /**
  66428. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66429. */
  66430. updateInputMeshes?: boolean;
  66431. /**
  66432. * boolean flag to dispose all the source textures. Defaults to true.
  66433. */
  66434. disposeSources?: boolean;
  66435. /**
  66436. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66437. */
  66438. fillBlanks?: boolean;
  66439. /**
  66440. * string value representing the context fill style color. Defaults to 'black'.
  66441. */
  66442. customFillColor?: string;
  66443. /**
  66444. * Width and Height Value of each Frame in the TexturePacker Sets
  66445. */
  66446. frameSize?: number;
  66447. /**
  66448. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66449. */
  66450. paddingRatio?: number;
  66451. /**
  66452. * Number that declares the fill method for the padding gutter.
  66453. */
  66454. paddingMode?: number;
  66455. /**
  66456. * If in SUBUV_COLOR padding mode what color to use.
  66457. */
  66458. paddingColor?: Color3 | Color4;
  66459. }
  66460. /**
  66461. * Defines the basic interface of a TexturePacker JSON File
  66462. */
  66463. export interface ITexturePackerJSON {
  66464. /**
  66465. * The frame ID
  66466. */
  66467. name: string;
  66468. /**
  66469. * The base64 channel data
  66470. */
  66471. sets: any;
  66472. /**
  66473. * The options of the Packer
  66474. */
  66475. options: ITexturePackerOptions;
  66476. /**
  66477. * The frame data of the Packer
  66478. */
  66479. frames: Array<number>;
  66480. }
  66481. /**
  66482. * This is a support class that generates a series of packed texture sets.
  66483. * @see https://doc.babylonjs.com/babylon101/materials
  66484. */
  66485. export class TexturePacker {
  66486. /** Packer Layout Constant 0 */
  66487. static readonly LAYOUT_STRIP: number;
  66488. /** Packer Layout Constant 1 */
  66489. static readonly LAYOUT_POWER2: number;
  66490. /** Packer Layout Constant 2 */
  66491. static readonly LAYOUT_COLNUM: number;
  66492. /** Packer Layout Constant 0 */
  66493. static readonly SUBUV_WRAP: number;
  66494. /** Packer Layout Constant 1 */
  66495. static readonly SUBUV_EXTEND: number;
  66496. /** Packer Layout Constant 2 */
  66497. static readonly SUBUV_COLOR: number;
  66498. /** The Name of the Texture Package */
  66499. name: string;
  66500. /** The scene scope of the TexturePacker */
  66501. scene: Scene;
  66502. /** The Meshes to target */
  66503. meshes: AbstractMesh[];
  66504. /** Arguments passed with the Constructor */
  66505. options: ITexturePackerOptions;
  66506. /** The promise that is started upon initialization */
  66507. promise: Nullable<Promise<TexturePacker | string>>;
  66508. /** The Container object for the channel sets that are generated */
  66509. sets: object;
  66510. /** The Container array for the frames that are generated */
  66511. frames: TexturePackerFrame[];
  66512. /** The expected number of textures the system is parsing. */
  66513. private _expecting;
  66514. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66515. private _paddingValue;
  66516. /**
  66517. * Initializes a texture package series from an array of meshes or a single mesh.
  66518. * @param name The name of the package
  66519. * @param meshes The target meshes to compose the package from
  66520. * @param options The arguments that texture packer should follow while building.
  66521. * @param scene The scene which the textures are scoped to.
  66522. * @returns TexturePacker
  66523. */
  66524. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66525. /**
  66526. * Starts the package process
  66527. * @param resolve The promises resolution function
  66528. * @returns TexturePacker
  66529. */
  66530. private _createFrames;
  66531. /**
  66532. * Calculates the Size of the Channel Sets
  66533. * @returns Vector2
  66534. */
  66535. private _calculateSize;
  66536. /**
  66537. * Calculates the UV data for the frames.
  66538. * @param baseSize the base frameSize
  66539. * @param padding the base frame padding
  66540. * @param dtSize size of the Dynamic Texture for that channel
  66541. * @param dtUnits is 1/dtSize
  66542. * @param update flag to update the input meshes
  66543. */
  66544. private _calculateMeshUVFrames;
  66545. /**
  66546. * Calculates the frames Offset.
  66547. * @param index of the frame
  66548. * @returns Vector2
  66549. */
  66550. private _getFrameOffset;
  66551. /**
  66552. * Updates a Mesh to the frame data
  66553. * @param mesh that is the target
  66554. * @param frameID or the frame index
  66555. */
  66556. private _updateMeshUV;
  66557. /**
  66558. * Updates a Meshes materials to use the texture packer channels
  66559. * @param m is the mesh to target
  66560. * @param force all channels on the packer to be set.
  66561. */
  66562. private _updateTextureReferences;
  66563. /**
  66564. * Public method to set a Mesh to a frame
  66565. * @param m that is the target
  66566. * @param frameID or the frame index
  66567. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66568. */
  66569. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66570. /**
  66571. * Starts the async promise to compile the texture packer.
  66572. * @returns Promise<void>
  66573. */
  66574. processAsync(): Promise<void>;
  66575. /**
  66576. * Disposes all textures associated with this packer
  66577. */
  66578. dispose(): void;
  66579. /**
  66580. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66581. * @param imageType is the image type to use.
  66582. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66583. */
  66584. download(imageType?: string, quality?: number): void;
  66585. /**
  66586. * Public method to load a texturePacker JSON file.
  66587. * @param data of the JSON file in string format.
  66588. */
  66589. updateFromJSON(data: string): void;
  66590. }
  66591. }
  66592. declare module BABYLON {
  66593. /**
  66594. * 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.
  66595. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66596. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66597. */
  66598. export class CustomProceduralTexture extends ProceduralTexture {
  66599. private _animate;
  66600. private _time;
  66601. private _config;
  66602. private _texturePath;
  66603. /**
  66604. * Instantiates a new Custom Procedural Texture.
  66605. * 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.
  66606. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66607. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66608. * @param name Define the name of the texture
  66609. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66610. * @param size Define the size of the texture to create
  66611. * @param scene Define the scene the texture belongs to
  66612. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66613. * @param generateMipMaps Define if the texture should creates mip maps or not
  66614. */
  66615. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66616. private _loadJson;
  66617. /**
  66618. * Is the texture ready to be used ? (rendered at least once)
  66619. * @returns true if ready, otherwise, false.
  66620. */
  66621. isReady(): boolean;
  66622. /**
  66623. * Render the texture to its associated render target.
  66624. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66625. */
  66626. render(useCameraPostProcess?: boolean): void;
  66627. /**
  66628. * Update the list of dependant textures samplers in the shader.
  66629. */
  66630. updateTextures(): void;
  66631. /**
  66632. * Update the uniform values of the procedural texture in the shader.
  66633. */
  66634. updateShaderUniforms(): void;
  66635. /**
  66636. * Define if the texture animates or not.
  66637. */
  66638. get animate(): boolean;
  66639. set animate(value: boolean);
  66640. }
  66641. }
  66642. declare module BABYLON {
  66643. /** @hidden */
  66644. export var noisePixelShader: {
  66645. name: string;
  66646. shader: string;
  66647. };
  66648. }
  66649. declare module BABYLON {
  66650. /**
  66651. * Class used to generate noise procedural textures
  66652. */
  66653. export class NoiseProceduralTexture extends ProceduralTexture {
  66654. /** Gets or sets the start time (default is 0) */
  66655. time: number;
  66656. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66657. brightness: number;
  66658. /** Defines the number of octaves to process */
  66659. octaves: number;
  66660. /** Defines the level of persistence (0.8 by default) */
  66661. persistence: number;
  66662. /** Gets or sets animation speed factor (default is 1) */
  66663. animationSpeedFactor: number;
  66664. /**
  66665. * Creates a new NoiseProceduralTexture
  66666. * @param name defines the name fo the texture
  66667. * @param size defines the size of the texture (default is 256)
  66668. * @param scene defines the hosting scene
  66669. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66670. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66671. */
  66672. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66673. private _updateShaderUniforms;
  66674. protected _getDefines(): string;
  66675. /** Generate the current state of the procedural texture */
  66676. render(useCameraPostProcess?: boolean): void;
  66677. /**
  66678. * Serializes this noise procedural texture
  66679. * @returns a serialized noise procedural texture object
  66680. */
  66681. serialize(): any;
  66682. /**
  66683. * Clone the texture.
  66684. * @returns the cloned texture
  66685. */
  66686. clone(): NoiseProceduralTexture;
  66687. /**
  66688. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66689. * @param parsedTexture defines parsed texture data
  66690. * @param scene defines the current scene
  66691. * @param rootUrl defines the root URL containing noise procedural texture information
  66692. * @returns a parsed NoiseProceduralTexture
  66693. */
  66694. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66695. }
  66696. }
  66697. declare module BABYLON {
  66698. /**
  66699. * Raw cube texture where the raw buffers are passed in
  66700. */
  66701. export class RawCubeTexture extends CubeTexture {
  66702. /**
  66703. * Creates a cube texture where the raw buffers are passed in.
  66704. * @param scene defines the scene the texture is attached to
  66705. * @param data defines the array of data to use to create each face
  66706. * @param size defines the size of the textures
  66707. * @param format defines the format of the data
  66708. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66709. * @param generateMipMaps defines if the engine should generate the mip levels
  66710. * @param invertY defines if data must be stored with Y axis inverted
  66711. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66712. * @param compression defines the compression used (null by default)
  66713. */
  66714. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66715. /**
  66716. * Updates the raw cube texture.
  66717. * @param data defines the data to store
  66718. * @param format defines the data format
  66719. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66720. * @param invertY defines if data must be stored with Y axis inverted
  66721. * @param compression defines the compression used (null by default)
  66722. * @param level defines which level of the texture to update
  66723. */
  66724. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66725. /**
  66726. * Updates a raw cube texture with RGBD encoded data.
  66727. * @param data defines the array of data [mipmap][face] to use to create each face
  66728. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66729. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66730. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66731. * @returns a promsie that resolves when the operation is complete
  66732. */
  66733. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66734. /**
  66735. * Clones the raw cube texture.
  66736. * @return a new cube texture
  66737. */
  66738. clone(): CubeTexture;
  66739. /** @hidden */
  66740. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66741. }
  66742. }
  66743. declare module BABYLON {
  66744. /**
  66745. * Class used to store 2D array textures containing user data
  66746. */
  66747. export class RawTexture2DArray extends Texture {
  66748. /** Gets or sets the texture format to use */
  66749. format: number;
  66750. /**
  66751. * Create a new RawTexture2DArray
  66752. * @param data defines the data of the texture
  66753. * @param width defines the width of the texture
  66754. * @param height defines the height of the texture
  66755. * @param depth defines the number of layers of the texture
  66756. * @param format defines the texture format to use
  66757. * @param scene defines the hosting scene
  66758. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66759. * @param invertY defines if texture must be stored with Y axis inverted
  66760. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66761. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66762. */
  66763. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66764. /** Gets or sets the texture format to use */
  66765. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66766. /**
  66767. * Update the texture with new data
  66768. * @param data defines the data to store in the texture
  66769. */
  66770. update(data: ArrayBufferView): void;
  66771. }
  66772. }
  66773. declare module BABYLON {
  66774. /**
  66775. * Class used to store 3D textures containing user data
  66776. */
  66777. export class RawTexture3D extends Texture {
  66778. /** Gets or sets the texture format to use */
  66779. format: number;
  66780. /**
  66781. * Create a new RawTexture3D
  66782. * @param data defines the data of the texture
  66783. * @param width defines the width of the texture
  66784. * @param height defines the height of the texture
  66785. * @param depth defines the depth of the texture
  66786. * @param format defines the texture format to use
  66787. * @param scene defines the hosting scene
  66788. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66789. * @param invertY defines if texture must be stored with Y axis inverted
  66790. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66791. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66792. */
  66793. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66794. /** Gets or sets the texture format to use */
  66795. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66796. /**
  66797. * Update the texture with new data
  66798. * @param data defines the data to store in the texture
  66799. */
  66800. update(data: ArrayBufferView): void;
  66801. }
  66802. }
  66803. declare module BABYLON {
  66804. /**
  66805. * Creates a refraction texture used by refraction channel of the standard material.
  66806. * It is like a mirror but to see through a material.
  66807. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66808. */
  66809. export class RefractionTexture extends RenderTargetTexture {
  66810. /**
  66811. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66812. * 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.
  66813. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66814. */
  66815. refractionPlane: Plane;
  66816. /**
  66817. * Define how deep under the surface we should see.
  66818. */
  66819. depth: number;
  66820. /**
  66821. * Creates a refraction texture used by refraction channel of the standard material.
  66822. * It is like a mirror but to see through a material.
  66823. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66824. * @param name Define the texture name
  66825. * @param size Define the size of the underlying texture
  66826. * @param scene Define the scene the refraction belongs to
  66827. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66828. */
  66829. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66830. /**
  66831. * Clone the refraction texture.
  66832. * @returns the cloned texture
  66833. */
  66834. clone(): RefractionTexture;
  66835. /**
  66836. * Serialize the texture to a JSON representation you could use in Parse later on
  66837. * @returns the serialized JSON representation
  66838. */
  66839. serialize(): any;
  66840. }
  66841. }
  66842. declare module BABYLON {
  66843. /**
  66844. * Block used to add support for vertex skinning (bones)
  66845. */
  66846. export class BonesBlock extends NodeMaterialBlock {
  66847. /**
  66848. * Creates a new BonesBlock
  66849. * @param name defines the block name
  66850. */
  66851. constructor(name: string);
  66852. /**
  66853. * Initialize the block and prepare the context for build
  66854. * @param state defines the state that will be used for the build
  66855. */
  66856. initialize(state: NodeMaterialBuildState): void;
  66857. /**
  66858. * Gets the current class name
  66859. * @returns the class name
  66860. */
  66861. getClassName(): string;
  66862. /**
  66863. * Gets the matrix indices input component
  66864. */
  66865. get matricesIndices(): NodeMaterialConnectionPoint;
  66866. /**
  66867. * Gets the matrix weights input component
  66868. */
  66869. get matricesWeights(): NodeMaterialConnectionPoint;
  66870. /**
  66871. * Gets the extra matrix indices input component
  66872. */
  66873. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66874. /**
  66875. * Gets the extra matrix weights input component
  66876. */
  66877. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66878. /**
  66879. * Gets the world input component
  66880. */
  66881. get world(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the output component
  66884. */
  66885. get output(): NodeMaterialConnectionPoint;
  66886. autoConfigure(material: NodeMaterial): void;
  66887. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66888. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66890. protected _buildBlock(state: NodeMaterialBuildState): this;
  66891. }
  66892. }
  66893. declare module BABYLON {
  66894. /**
  66895. * Block used to add support for instances
  66896. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66897. */
  66898. export class InstancesBlock extends NodeMaterialBlock {
  66899. /**
  66900. * Creates a new InstancesBlock
  66901. * @param name defines the block name
  66902. */
  66903. constructor(name: string);
  66904. /**
  66905. * Gets the current class name
  66906. * @returns the class name
  66907. */
  66908. getClassName(): string;
  66909. /**
  66910. * Gets the first world row input component
  66911. */
  66912. get world0(): NodeMaterialConnectionPoint;
  66913. /**
  66914. * Gets the second world row input component
  66915. */
  66916. get world1(): NodeMaterialConnectionPoint;
  66917. /**
  66918. * Gets the third world row input component
  66919. */
  66920. get world2(): NodeMaterialConnectionPoint;
  66921. /**
  66922. * Gets the forth world row input component
  66923. */
  66924. get world3(): NodeMaterialConnectionPoint;
  66925. /**
  66926. * Gets the world input component
  66927. */
  66928. get world(): NodeMaterialConnectionPoint;
  66929. /**
  66930. * Gets the output component
  66931. */
  66932. get output(): NodeMaterialConnectionPoint;
  66933. /**
  66934. * Gets the isntanceID component
  66935. */
  66936. get instanceID(): NodeMaterialConnectionPoint;
  66937. autoConfigure(material: NodeMaterial): void;
  66938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66939. protected _buildBlock(state: NodeMaterialBuildState): this;
  66940. }
  66941. }
  66942. declare module BABYLON {
  66943. /**
  66944. * Block used to add morph targets support to vertex shader
  66945. */
  66946. export class MorphTargetsBlock extends NodeMaterialBlock {
  66947. private _repeatableContentAnchor;
  66948. /**
  66949. * Create a new MorphTargetsBlock
  66950. * @param name defines the block name
  66951. */
  66952. constructor(name: string);
  66953. /**
  66954. * Gets the current class name
  66955. * @returns the class name
  66956. */
  66957. getClassName(): string;
  66958. /**
  66959. * Gets the position input component
  66960. */
  66961. get position(): NodeMaterialConnectionPoint;
  66962. /**
  66963. * Gets the normal input component
  66964. */
  66965. get normal(): NodeMaterialConnectionPoint;
  66966. /**
  66967. * Gets the tangent input component
  66968. */
  66969. get tangent(): NodeMaterialConnectionPoint;
  66970. /**
  66971. * Gets the tangent input component
  66972. */
  66973. get uv(): NodeMaterialConnectionPoint;
  66974. /**
  66975. * Gets the position output component
  66976. */
  66977. get positionOutput(): NodeMaterialConnectionPoint;
  66978. /**
  66979. * Gets the normal output component
  66980. */
  66981. get normalOutput(): NodeMaterialConnectionPoint;
  66982. /**
  66983. * Gets the tangent output component
  66984. */
  66985. get tangentOutput(): NodeMaterialConnectionPoint;
  66986. /**
  66987. * Gets the tangent output component
  66988. */
  66989. get uvOutput(): NodeMaterialConnectionPoint;
  66990. initialize(state: NodeMaterialBuildState): void;
  66991. autoConfigure(material: NodeMaterial): void;
  66992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66994. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66995. protected _buildBlock(state: NodeMaterialBuildState): this;
  66996. }
  66997. }
  66998. declare module BABYLON {
  66999. /**
  67000. * Block used to get data information from a light
  67001. */
  67002. export class LightInformationBlock extends NodeMaterialBlock {
  67003. private _lightDataUniformName;
  67004. private _lightColorUniformName;
  67005. private _lightTypeDefineName;
  67006. /**
  67007. * Gets or sets the light associated with this block
  67008. */
  67009. light: Nullable<Light>;
  67010. /**
  67011. * Creates a new LightInformationBlock
  67012. * @param name defines the block name
  67013. */
  67014. constructor(name: string);
  67015. /**
  67016. * Gets the current class name
  67017. * @returns the class name
  67018. */
  67019. getClassName(): string;
  67020. /**
  67021. * Gets the world position input component
  67022. */
  67023. get worldPosition(): NodeMaterialConnectionPoint;
  67024. /**
  67025. * Gets the direction output component
  67026. */
  67027. get direction(): NodeMaterialConnectionPoint;
  67028. /**
  67029. * Gets the direction output component
  67030. */
  67031. get color(): NodeMaterialConnectionPoint;
  67032. /**
  67033. * Gets the direction output component
  67034. */
  67035. get intensity(): NodeMaterialConnectionPoint;
  67036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67038. protected _buildBlock(state: NodeMaterialBuildState): this;
  67039. serialize(): any;
  67040. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67041. }
  67042. }
  67043. declare module BABYLON {
  67044. /**
  67045. * Block used to add image processing support to fragment shader
  67046. */
  67047. export class ImageProcessingBlock extends NodeMaterialBlock {
  67048. /**
  67049. * Create a new ImageProcessingBlock
  67050. * @param name defines the block name
  67051. */
  67052. constructor(name: string);
  67053. /**
  67054. * Gets the current class name
  67055. * @returns the class name
  67056. */
  67057. getClassName(): string;
  67058. /**
  67059. * Gets the color input component
  67060. */
  67061. get color(): NodeMaterialConnectionPoint;
  67062. /**
  67063. * Gets the output component
  67064. */
  67065. get output(): NodeMaterialConnectionPoint;
  67066. /**
  67067. * Initialize the block and prepare the context for build
  67068. * @param state defines the state that will be used for the build
  67069. */
  67070. initialize(state: NodeMaterialBuildState): void;
  67071. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67073. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67074. protected _buildBlock(state: NodeMaterialBuildState): this;
  67075. }
  67076. }
  67077. declare module BABYLON {
  67078. /**
  67079. * Block used to pertub normals based on a normal map
  67080. */
  67081. export class PerturbNormalBlock extends NodeMaterialBlock {
  67082. private _tangentSpaceParameterName;
  67083. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67084. invertX: boolean;
  67085. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67086. invertY: boolean;
  67087. /**
  67088. * Create a new PerturbNormalBlock
  67089. * @param name defines the block name
  67090. */
  67091. constructor(name: string);
  67092. /**
  67093. * Gets the current class name
  67094. * @returns the class name
  67095. */
  67096. getClassName(): string;
  67097. /**
  67098. * Gets the world position input component
  67099. */
  67100. get worldPosition(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the world normal input component
  67103. */
  67104. get worldNormal(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the world tangent input component
  67107. */
  67108. get worldTangent(): NodeMaterialConnectionPoint;
  67109. /**
  67110. * Gets the uv input component
  67111. */
  67112. get uv(): NodeMaterialConnectionPoint;
  67113. /**
  67114. * Gets the normal map color input component
  67115. */
  67116. get normalMapColor(): NodeMaterialConnectionPoint;
  67117. /**
  67118. * Gets the strength input component
  67119. */
  67120. get strength(): NodeMaterialConnectionPoint;
  67121. /**
  67122. * Gets the output component
  67123. */
  67124. get output(): NodeMaterialConnectionPoint;
  67125. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67126. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67127. autoConfigure(material: NodeMaterial): void;
  67128. protected _buildBlock(state: NodeMaterialBuildState): this;
  67129. protected _dumpPropertiesCode(): string;
  67130. serialize(): any;
  67131. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67132. }
  67133. }
  67134. declare module BABYLON {
  67135. /**
  67136. * Block used to discard a pixel if a value is smaller than a cutoff
  67137. */
  67138. export class DiscardBlock extends NodeMaterialBlock {
  67139. /**
  67140. * Create a new DiscardBlock
  67141. * @param name defines the block name
  67142. */
  67143. constructor(name: string);
  67144. /**
  67145. * Gets the current class name
  67146. * @returns the class name
  67147. */
  67148. getClassName(): string;
  67149. /**
  67150. * Gets the color input component
  67151. */
  67152. get value(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the cutoff input component
  67155. */
  67156. get cutoff(): NodeMaterialConnectionPoint;
  67157. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67158. }
  67159. }
  67160. declare module BABYLON {
  67161. /**
  67162. * Block used to test if the fragment shader is front facing
  67163. */
  67164. export class FrontFacingBlock extends NodeMaterialBlock {
  67165. /**
  67166. * Creates a new FrontFacingBlock
  67167. * @param name defines the block name
  67168. */
  67169. constructor(name: string);
  67170. /**
  67171. * Gets the current class name
  67172. * @returns the class name
  67173. */
  67174. getClassName(): string;
  67175. /**
  67176. * Gets the output component
  67177. */
  67178. get output(): NodeMaterialConnectionPoint;
  67179. protected _buildBlock(state: NodeMaterialBuildState): this;
  67180. }
  67181. }
  67182. declare module BABYLON {
  67183. /**
  67184. * Block used to get the derivative value on x and y of a given input
  67185. */
  67186. export class DerivativeBlock extends NodeMaterialBlock {
  67187. /**
  67188. * Create a new DerivativeBlock
  67189. * @param name defines the block name
  67190. */
  67191. constructor(name: string);
  67192. /**
  67193. * Gets the current class name
  67194. * @returns the class name
  67195. */
  67196. getClassName(): string;
  67197. /**
  67198. * Gets the input component
  67199. */
  67200. get input(): NodeMaterialConnectionPoint;
  67201. /**
  67202. * Gets the derivative output on x
  67203. */
  67204. get dx(): NodeMaterialConnectionPoint;
  67205. /**
  67206. * Gets the derivative output on y
  67207. */
  67208. get dy(): NodeMaterialConnectionPoint;
  67209. protected _buildBlock(state: NodeMaterialBuildState): this;
  67210. }
  67211. }
  67212. declare module BABYLON {
  67213. /**
  67214. * Block used to make gl_FragCoord available
  67215. */
  67216. export class FragCoordBlock extends NodeMaterialBlock {
  67217. /**
  67218. * Creates a new FragCoordBlock
  67219. * @param name defines the block name
  67220. */
  67221. constructor(name: string);
  67222. /**
  67223. * Gets the current class name
  67224. * @returns the class name
  67225. */
  67226. getClassName(): string;
  67227. /**
  67228. * Gets the xy component
  67229. */
  67230. get xy(): NodeMaterialConnectionPoint;
  67231. /**
  67232. * Gets the xyz component
  67233. */
  67234. get xyz(): NodeMaterialConnectionPoint;
  67235. /**
  67236. * Gets the xyzw component
  67237. */
  67238. get xyzw(): NodeMaterialConnectionPoint;
  67239. /**
  67240. * Gets the x component
  67241. */
  67242. get x(): NodeMaterialConnectionPoint;
  67243. /**
  67244. * Gets the y component
  67245. */
  67246. get y(): NodeMaterialConnectionPoint;
  67247. /**
  67248. * Gets the z component
  67249. */
  67250. get z(): NodeMaterialConnectionPoint;
  67251. /**
  67252. * Gets the w component
  67253. */
  67254. get output(): NodeMaterialConnectionPoint;
  67255. protected writeOutputs(state: NodeMaterialBuildState): string;
  67256. protected _buildBlock(state: NodeMaterialBuildState): this;
  67257. }
  67258. }
  67259. declare module BABYLON {
  67260. /**
  67261. * Block used to get the screen sizes
  67262. */
  67263. export class ScreenSizeBlock extends NodeMaterialBlock {
  67264. private _varName;
  67265. private _scene;
  67266. /**
  67267. * Creates a new ScreenSizeBlock
  67268. * @param name defines the block name
  67269. */
  67270. constructor(name: string);
  67271. /**
  67272. * Gets the current class name
  67273. * @returns the class name
  67274. */
  67275. getClassName(): string;
  67276. /**
  67277. * Gets the xy component
  67278. */
  67279. get xy(): NodeMaterialConnectionPoint;
  67280. /**
  67281. * Gets the x component
  67282. */
  67283. get x(): NodeMaterialConnectionPoint;
  67284. /**
  67285. * Gets the y component
  67286. */
  67287. get y(): NodeMaterialConnectionPoint;
  67288. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67289. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67290. protected _buildBlock(state: NodeMaterialBuildState): this;
  67291. }
  67292. }
  67293. declare module BABYLON {
  67294. /**
  67295. * Block used to add support for scene fog
  67296. */
  67297. export class FogBlock extends NodeMaterialBlock {
  67298. private _fogDistanceName;
  67299. private _fogParameters;
  67300. /**
  67301. * Create a new FogBlock
  67302. * @param name defines the block name
  67303. */
  67304. constructor(name: string);
  67305. /**
  67306. * Gets the current class name
  67307. * @returns the class name
  67308. */
  67309. getClassName(): string;
  67310. /**
  67311. * Gets the world position input component
  67312. */
  67313. get worldPosition(): NodeMaterialConnectionPoint;
  67314. /**
  67315. * Gets the view input component
  67316. */
  67317. get view(): NodeMaterialConnectionPoint;
  67318. /**
  67319. * Gets the color input component
  67320. */
  67321. get input(): NodeMaterialConnectionPoint;
  67322. /**
  67323. * Gets the fog color input component
  67324. */
  67325. get fogColor(): NodeMaterialConnectionPoint;
  67326. /**
  67327. * Gets the output component
  67328. */
  67329. get output(): NodeMaterialConnectionPoint;
  67330. autoConfigure(material: NodeMaterial): void;
  67331. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67332. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67333. protected _buildBlock(state: NodeMaterialBuildState): this;
  67334. }
  67335. }
  67336. declare module BABYLON {
  67337. /**
  67338. * Block used to add light in the fragment shader
  67339. */
  67340. export class LightBlock extends NodeMaterialBlock {
  67341. private _lightId;
  67342. /**
  67343. * Gets or sets the light associated with this block
  67344. */
  67345. light: Nullable<Light>;
  67346. /**
  67347. * Create a new LightBlock
  67348. * @param name defines the block name
  67349. */
  67350. constructor(name: string);
  67351. /**
  67352. * Gets the current class name
  67353. * @returns the class name
  67354. */
  67355. getClassName(): string;
  67356. /**
  67357. * Gets the world position input component
  67358. */
  67359. get worldPosition(): NodeMaterialConnectionPoint;
  67360. /**
  67361. * Gets the world normal input component
  67362. */
  67363. get worldNormal(): NodeMaterialConnectionPoint;
  67364. /**
  67365. * Gets the camera (or eye) position component
  67366. */
  67367. get cameraPosition(): NodeMaterialConnectionPoint;
  67368. /**
  67369. * Gets the glossiness component
  67370. */
  67371. get glossiness(): NodeMaterialConnectionPoint;
  67372. /**
  67373. * Gets the glossinness power component
  67374. */
  67375. get glossPower(): NodeMaterialConnectionPoint;
  67376. /**
  67377. * Gets the diffuse color component
  67378. */
  67379. get diffuseColor(): NodeMaterialConnectionPoint;
  67380. /**
  67381. * Gets the specular color component
  67382. */
  67383. get specularColor(): NodeMaterialConnectionPoint;
  67384. /**
  67385. * Gets the view matrix component
  67386. */
  67387. get view(): NodeMaterialConnectionPoint;
  67388. /**
  67389. * Gets the diffuse output component
  67390. */
  67391. get diffuseOutput(): NodeMaterialConnectionPoint;
  67392. /**
  67393. * Gets the specular output component
  67394. */
  67395. get specularOutput(): NodeMaterialConnectionPoint;
  67396. /**
  67397. * Gets the shadow output component
  67398. */
  67399. get shadow(): NodeMaterialConnectionPoint;
  67400. autoConfigure(material: NodeMaterial): void;
  67401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67402. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67403. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67404. private _injectVertexCode;
  67405. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67406. serialize(): any;
  67407. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67408. }
  67409. }
  67410. declare module BABYLON {
  67411. /**
  67412. * Block used to read a reflection texture from a sampler
  67413. */
  67414. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67415. /**
  67416. * Create a new ReflectionTextureBlock
  67417. * @param name defines the block name
  67418. */
  67419. constructor(name: string);
  67420. /**
  67421. * Gets the current class name
  67422. * @returns the class name
  67423. */
  67424. getClassName(): string;
  67425. /**
  67426. * Gets the world position input component
  67427. */
  67428. get position(): NodeMaterialConnectionPoint;
  67429. /**
  67430. * Gets the world position input component
  67431. */
  67432. get worldPosition(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the world normal input component
  67435. */
  67436. get worldNormal(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the world input component
  67439. */
  67440. get world(): NodeMaterialConnectionPoint;
  67441. /**
  67442. * Gets the camera (or eye) position component
  67443. */
  67444. get cameraPosition(): NodeMaterialConnectionPoint;
  67445. /**
  67446. * Gets the view input component
  67447. */
  67448. get view(): NodeMaterialConnectionPoint;
  67449. /**
  67450. * Gets the rgb output component
  67451. */
  67452. get rgb(): NodeMaterialConnectionPoint;
  67453. /**
  67454. * Gets the rgba output component
  67455. */
  67456. get rgba(): NodeMaterialConnectionPoint;
  67457. /**
  67458. * Gets the r output component
  67459. */
  67460. get r(): NodeMaterialConnectionPoint;
  67461. /**
  67462. * Gets the g output component
  67463. */
  67464. get g(): NodeMaterialConnectionPoint;
  67465. /**
  67466. * Gets the b output component
  67467. */
  67468. get b(): NodeMaterialConnectionPoint;
  67469. /**
  67470. * Gets the a output component
  67471. */
  67472. get a(): NodeMaterialConnectionPoint;
  67473. autoConfigure(material: NodeMaterial): void;
  67474. protected _buildBlock(state: NodeMaterialBuildState): this;
  67475. }
  67476. }
  67477. declare module BABYLON {
  67478. /**
  67479. * Block used to add 2 vectors
  67480. */
  67481. export class AddBlock extends NodeMaterialBlock {
  67482. /**
  67483. * Creates a new AddBlock
  67484. * @param name defines the block name
  67485. */
  67486. constructor(name: string);
  67487. /**
  67488. * Gets the current class name
  67489. * @returns the class name
  67490. */
  67491. getClassName(): string;
  67492. /**
  67493. * Gets the left operand input component
  67494. */
  67495. get left(): NodeMaterialConnectionPoint;
  67496. /**
  67497. * Gets the right operand input component
  67498. */
  67499. get right(): NodeMaterialConnectionPoint;
  67500. /**
  67501. * Gets the output component
  67502. */
  67503. get output(): NodeMaterialConnectionPoint;
  67504. protected _buildBlock(state: NodeMaterialBuildState): this;
  67505. }
  67506. }
  67507. declare module BABYLON {
  67508. /**
  67509. * Block used to scale a vector by a float
  67510. */
  67511. export class ScaleBlock extends NodeMaterialBlock {
  67512. /**
  67513. * Creates a new ScaleBlock
  67514. * @param name defines the block name
  67515. */
  67516. constructor(name: string);
  67517. /**
  67518. * Gets the current class name
  67519. * @returns the class name
  67520. */
  67521. getClassName(): string;
  67522. /**
  67523. * Gets the input component
  67524. */
  67525. get input(): NodeMaterialConnectionPoint;
  67526. /**
  67527. * Gets the factor input component
  67528. */
  67529. get factor(): NodeMaterialConnectionPoint;
  67530. /**
  67531. * Gets the output component
  67532. */
  67533. get output(): NodeMaterialConnectionPoint;
  67534. protected _buildBlock(state: NodeMaterialBuildState): this;
  67535. }
  67536. }
  67537. declare module BABYLON {
  67538. /**
  67539. * Block used to clamp a float
  67540. */
  67541. export class ClampBlock extends NodeMaterialBlock {
  67542. /** Gets or sets the minimum range */
  67543. minimum: number;
  67544. /** Gets or sets the maximum range */
  67545. maximum: number;
  67546. /**
  67547. * Creates a new ClampBlock
  67548. * @param name defines the block name
  67549. */
  67550. constructor(name: string);
  67551. /**
  67552. * Gets the current class name
  67553. * @returns the class name
  67554. */
  67555. getClassName(): string;
  67556. /**
  67557. * Gets the value input component
  67558. */
  67559. get value(): NodeMaterialConnectionPoint;
  67560. /**
  67561. * Gets the output component
  67562. */
  67563. get output(): NodeMaterialConnectionPoint;
  67564. protected _buildBlock(state: NodeMaterialBuildState): this;
  67565. protected _dumpPropertiesCode(): string;
  67566. serialize(): any;
  67567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67568. }
  67569. }
  67570. declare module BABYLON {
  67571. /**
  67572. * Block used to apply a cross product between 2 vectors
  67573. */
  67574. export class CrossBlock extends NodeMaterialBlock {
  67575. /**
  67576. * Creates a new CrossBlock
  67577. * @param name defines the block name
  67578. */
  67579. constructor(name: string);
  67580. /**
  67581. * Gets the current class name
  67582. * @returns the class name
  67583. */
  67584. getClassName(): string;
  67585. /**
  67586. * Gets the left operand input component
  67587. */
  67588. get left(): NodeMaterialConnectionPoint;
  67589. /**
  67590. * Gets the right operand input component
  67591. */
  67592. get right(): NodeMaterialConnectionPoint;
  67593. /**
  67594. * Gets the output component
  67595. */
  67596. get output(): NodeMaterialConnectionPoint;
  67597. protected _buildBlock(state: NodeMaterialBuildState): this;
  67598. }
  67599. }
  67600. declare module BABYLON {
  67601. /**
  67602. * Block used to apply a dot product between 2 vectors
  67603. */
  67604. export class DotBlock extends NodeMaterialBlock {
  67605. /**
  67606. * Creates a new DotBlock
  67607. * @param name defines the block name
  67608. */
  67609. constructor(name: string);
  67610. /**
  67611. * Gets the current class name
  67612. * @returns the class name
  67613. */
  67614. getClassName(): string;
  67615. /**
  67616. * Gets the left operand input component
  67617. */
  67618. get left(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the right operand input component
  67621. */
  67622. get right(): NodeMaterialConnectionPoint;
  67623. /**
  67624. * Gets the output component
  67625. */
  67626. get output(): NodeMaterialConnectionPoint;
  67627. protected _buildBlock(state: NodeMaterialBuildState): this;
  67628. }
  67629. }
  67630. declare module BABYLON {
  67631. /**
  67632. * Block used to normalize a vector
  67633. */
  67634. export class NormalizeBlock extends NodeMaterialBlock {
  67635. /**
  67636. * Creates a new NormalizeBlock
  67637. * @param name defines the block name
  67638. */
  67639. constructor(name: string);
  67640. /**
  67641. * Gets the current class name
  67642. * @returns the class name
  67643. */
  67644. getClassName(): string;
  67645. /**
  67646. * Gets the input component
  67647. */
  67648. get input(): NodeMaterialConnectionPoint;
  67649. /**
  67650. * Gets the output component
  67651. */
  67652. get output(): NodeMaterialConnectionPoint;
  67653. protected _buildBlock(state: NodeMaterialBuildState): this;
  67654. }
  67655. }
  67656. declare module BABYLON {
  67657. /**
  67658. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67659. */
  67660. export class ColorMergerBlock extends NodeMaterialBlock {
  67661. /**
  67662. * Create a new ColorMergerBlock
  67663. * @param name defines the block name
  67664. */
  67665. constructor(name: string);
  67666. /**
  67667. * Gets the current class name
  67668. * @returns the class name
  67669. */
  67670. getClassName(): string;
  67671. /**
  67672. * Gets the rgb component (input)
  67673. */
  67674. get rgbIn(): NodeMaterialConnectionPoint;
  67675. /**
  67676. * Gets the r component (input)
  67677. */
  67678. get r(): NodeMaterialConnectionPoint;
  67679. /**
  67680. * Gets the g component (input)
  67681. */
  67682. get g(): NodeMaterialConnectionPoint;
  67683. /**
  67684. * Gets the b component (input)
  67685. */
  67686. get b(): NodeMaterialConnectionPoint;
  67687. /**
  67688. * Gets the a component (input)
  67689. */
  67690. get a(): NodeMaterialConnectionPoint;
  67691. /**
  67692. * Gets the rgba component (output)
  67693. */
  67694. get rgba(): NodeMaterialConnectionPoint;
  67695. /**
  67696. * Gets the rgb component (output)
  67697. */
  67698. get rgbOut(): NodeMaterialConnectionPoint;
  67699. /**
  67700. * Gets the rgb component (output)
  67701. * @deprecated Please use rgbOut instead.
  67702. */
  67703. get rgb(): NodeMaterialConnectionPoint;
  67704. protected _buildBlock(state: NodeMaterialBuildState): this;
  67705. }
  67706. }
  67707. declare module BABYLON {
  67708. /**
  67709. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67710. */
  67711. export class VectorSplitterBlock extends NodeMaterialBlock {
  67712. /**
  67713. * Create a new VectorSplitterBlock
  67714. * @param name defines the block name
  67715. */
  67716. constructor(name: string);
  67717. /**
  67718. * Gets the current class name
  67719. * @returns the class name
  67720. */
  67721. getClassName(): string;
  67722. /**
  67723. * Gets the xyzw component (input)
  67724. */
  67725. get xyzw(): NodeMaterialConnectionPoint;
  67726. /**
  67727. * Gets the xyz component (input)
  67728. */
  67729. get xyzIn(): NodeMaterialConnectionPoint;
  67730. /**
  67731. * Gets the xy component (input)
  67732. */
  67733. get xyIn(): NodeMaterialConnectionPoint;
  67734. /**
  67735. * Gets the xyz component (output)
  67736. */
  67737. get xyzOut(): NodeMaterialConnectionPoint;
  67738. /**
  67739. * Gets the xy component (output)
  67740. */
  67741. get xyOut(): NodeMaterialConnectionPoint;
  67742. /**
  67743. * Gets the x component (output)
  67744. */
  67745. get x(): NodeMaterialConnectionPoint;
  67746. /**
  67747. * Gets the y component (output)
  67748. */
  67749. get y(): NodeMaterialConnectionPoint;
  67750. /**
  67751. * Gets the z component (output)
  67752. */
  67753. get z(): NodeMaterialConnectionPoint;
  67754. /**
  67755. * Gets the w component (output)
  67756. */
  67757. get w(): NodeMaterialConnectionPoint;
  67758. protected _inputRename(name: string): string;
  67759. protected _outputRename(name: string): string;
  67760. protected _buildBlock(state: NodeMaterialBuildState): this;
  67761. }
  67762. }
  67763. declare module BABYLON {
  67764. /**
  67765. * Block used to lerp between 2 values
  67766. */
  67767. export class LerpBlock extends NodeMaterialBlock {
  67768. /**
  67769. * Creates a new LerpBlock
  67770. * @param name defines the block name
  67771. */
  67772. constructor(name: string);
  67773. /**
  67774. * Gets the current class name
  67775. * @returns the class name
  67776. */
  67777. getClassName(): string;
  67778. /**
  67779. * Gets the left operand input component
  67780. */
  67781. get left(): NodeMaterialConnectionPoint;
  67782. /**
  67783. * Gets the right operand input component
  67784. */
  67785. get right(): NodeMaterialConnectionPoint;
  67786. /**
  67787. * Gets the gradient operand input component
  67788. */
  67789. get gradient(): NodeMaterialConnectionPoint;
  67790. /**
  67791. * Gets the output component
  67792. */
  67793. get output(): NodeMaterialConnectionPoint;
  67794. protected _buildBlock(state: NodeMaterialBuildState): this;
  67795. }
  67796. }
  67797. declare module BABYLON {
  67798. /**
  67799. * Block used to divide 2 vectors
  67800. */
  67801. export class DivideBlock extends NodeMaterialBlock {
  67802. /**
  67803. * Creates a new DivideBlock
  67804. * @param name defines the block name
  67805. */
  67806. constructor(name: string);
  67807. /**
  67808. * Gets the current class name
  67809. * @returns the class name
  67810. */
  67811. getClassName(): string;
  67812. /**
  67813. * Gets the left operand input component
  67814. */
  67815. get left(): NodeMaterialConnectionPoint;
  67816. /**
  67817. * Gets the right operand input component
  67818. */
  67819. get right(): NodeMaterialConnectionPoint;
  67820. /**
  67821. * Gets the output component
  67822. */
  67823. get output(): NodeMaterialConnectionPoint;
  67824. protected _buildBlock(state: NodeMaterialBuildState): this;
  67825. }
  67826. }
  67827. declare module BABYLON {
  67828. /**
  67829. * Block used to subtract 2 vectors
  67830. */
  67831. export class SubtractBlock extends NodeMaterialBlock {
  67832. /**
  67833. * Creates a new SubtractBlock
  67834. * @param name defines the block name
  67835. */
  67836. constructor(name: string);
  67837. /**
  67838. * Gets the current class name
  67839. * @returns the class name
  67840. */
  67841. getClassName(): string;
  67842. /**
  67843. * Gets the left operand input component
  67844. */
  67845. get left(): NodeMaterialConnectionPoint;
  67846. /**
  67847. * Gets the right operand input component
  67848. */
  67849. get right(): NodeMaterialConnectionPoint;
  67850. /**
  67851. * Gets the output component
  67852. */
  67853. get output(): NodeMaterialConnectionPoint;
  67854. protected _buildBlock(state: NodeMaterialBuildState): this;
  67855. }
  67856. }
  67857. declare module BABYLON {
  67858. /**
  67859. * Block used to step a value
  67860. */
  67861. export class StepBlock extends NodeMaterialBlock {
  67862. /**
  67863. * Creates a new StepBlock
  67864. * @param name defines the block name
  67865. */
  67866. constructor(name: string);
  67867. /**
  67868. * Gets the current class name
  67869. * @returns the class name
  67870. */
  67871. getClassName(): string;
  67872. /**
  67873. * Gets the value operand input component
  67874. */
  67875. get value(): NodeMaterialConnectionPoint;
  67876. /**
  67877. * Gets the edge operand input component
  67878. */
  67879. get edge(): NodeMaterialConnectionPoint;
  67880. /**
  67881. * Gets the output component
  67882. */
  67883. get output(): NodeMaterialConnectionPoint;
  67884. protected _buildBlock(state: NodeMaterialBuildState): this;
  67885. }
  67886. }
  67887. declare module BABYLON {
  67888. /**
  67889. * Block used to get the opposite (1 - x) of a value
  67890. */
  67891. export class OneMinusBlock extends NodeMaterialBlock {
  67892. /**
  67893. * Creates a new OneMinusBlock
  67894. * @param name defines the block name
  67895. */
  67896. constructor(name: string);
  67897. /**
  67898. * Gets the current class name
  67899. * @returns the class name
  67900. */
  67901. getClassName(): string;
  67902. /**
  67903. * Gets the input component
  67904. */
  67905. get input(): NodeMaterialConnectionPoint;
  67906. /**
  67907. * Gets the output component
  67908. */
  67909. get output(): NodeMaterialConnectionPoint;
  67910. protected _buildBlock(state: NodeMaterialBuildState): this;
  67911. }
  67912. }
  67913. declare module BABYLON {
  67914. /**
  67915. * Block used to get the view direction
  67916. */
  67917. export class ViewDirectionBlock extends NodeMaterialBlock {
  67918. /**
  67919. * Creates a new ViewDirectionBlock
  67920. * @param name defines the block name
  67921. */
  67922. constructor(name: string);
  67923. /**
  67924. * Gets the current class name
  67925. * @returns the class name
  67926. */
  67927. getClassName(): string;
  67928. /**
  67929. * Gets the world position component
  67930. */
  67931. get worldPosition(): NodeMaterialConnectionPoint;
  67932. /**
  67933. * Gets the camera position component
  67934. */
  67935. get cameraPosition(): NodeMaterialConnectionPoint;
  67936. /**
  67937. * Gets the output component
  67938. */
  67939. get output(): NodeMaterialConnectionPoint;
  67940. autoConfigure(material: NodeMaterial): void;
  67941. protected _buildBlock(state: NodeMaterialBuildState): this;
  67942. }
  67943. }
  67944. declare module BABYLON {
  67945. /**
  67946. * Block used to compute fresnel value
  67947. */
  67948. export class FresnelBlock extends NodeMaterialBlock {
  67949. /**
  67950. * Create a new FresnelBlock
  67951. * @param name defines the block name
  67952. */
  67953. constructor(name: string);
  67954. /**
  67955. * Gets the current class name
  67956. * @returns the class name
  67957. */
  67958. getClassName(): string;
  67959. /**
  67960. * Gets the world normal input component
  67961. */
  67962. get worldNormal(): NodeMaterialConnectionPoint;
  67963. /**
  67964. * Gets the view direction input component
  67965. */
  67966. get viewDirection(): NodeMaterialConnectionPoint;
  67967. /**
  67968. * Gets the bias input component
  67969. */
  67970. get bias(): NodeMaterialConnectionPoint;
  67971. /**
  67972. * Gets the camera (or eye) position component
  67973. */
  67974. get power(): NodeMaterialConnectionPoint;
  67975. /**
  67976. * Gets the fresnel output component
  67977. */
  67978. get fresnel(): NodeMaterialConnectionPoint;
  67979. autoConfigure(material: NodeMaterial): void;
  67980. protected _buildBlock(state: NodeMaterialBuildState): this;
  67981. }
  67982. }
  67983. declare module BABYLON {
  67984. /**
  67985. * Block used to get the max of 2 values
  67986. */
  67987. export class MaxBlock extends NodeMaterialBlock {
  67988. /**
  67989. * Creates a new MaxBlock
  67990. * @param name defines the block name
  67991. */
  67992. constructor(name: string);
  67993. /**
  67994. * Gets the current class name
  67995. * @returns the class name
  67996. */
  67997. getClassName(): string;
  67998. /**
  67999. * Gets the left operand input component
  68000. */
  68001. get left(): NodeMaterialConnectionPoint;
  68002. /**
  68003. * Gets the right operand input component
  68004. */
  68005. get right(): NodeMaterialConnectionPoint;
  68006. /**
  68007. * Gets the output component
  68008. */
  68009. get output(): NodeMaterialConnectionPoint;
  68010. protected _buildBlock(state: NodeMaterialBuildState): this;
  68011. }
  68012. }
  68013. declare module BABYLON {
  68014. /**
  68015. * Block used to get the min of 2 values
  68016. */
  68017. export class MinBlock extends NodeMaterialBlock {
  68018. /**
  68019. * Creates a new MinBlock
  68020. * @param name defines the block name
  68021. */
  68022. constructor(name: string);
  68023. /**
  68024. * Gets the current class name
  68025. * @returns the class name
  68026. */
  68027. getClassName(): string;
  68028. /**
  68029. * Gets the left operand input component
  68030. */
  68031. get left(): NodeMaterialConnectionPoint;
  68032. /**
  68033. * Gets the right operand input component
  68034. */
  68035. get right(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the output component
  68038. */
  68039. get output(): NodeMaterialConnectionPoint;
  68040. protected _buildBlock(state: NodeMaterialBuildState): this;
  68041. }
  68042. }
  68043. declare module BABYLON {
  68044. /**
  68045. * Block used to get the distance between 2 values
  68046. */
  68047. export class DistanceBlock extends NodeMaterialBlock {
  68048. /**
  68049. * Creates a new DistanceBlock
  68050. * @param name defines the block name
  68051. */
  68052. constructor(name: string);
  68053. /**
  68054. * Gets the current class name
  68055. * @returns the class name
  68056. */
  68057. getClassName(): string;
  68058. /**
  68059. * Gets the left operand input component
  68060. */
  68061. get left(): NodeMaterialConnectionPoint;
  68062. /**
  68063. * Gets the right operand input component
  68064. */
  68065. get right(): NodeMaterialConnectionPoint;
  68066. /**
  68067. * Gets the output component
  68068. */
  68069. get output(): NodeMaterialConnectionPoint;
  68070. protected _buildBlock(state: NodeMaterialBuildState): this;
  68071. }
  68072. }
  68073. declare module BABYLON {
  68074. /**
  68075. * Block used to get the length of a vector
  68076. */
  68077. export class LengthBlock extends NodeMaterialBlock {
  68078. /**
  68079. * Creates a new LengthBlock
  68080. * @param name defines the block name
  68081. */
  68082. constructor(name: string);
  68083. /**
  68084. * Gets the current class name
  68085. * @returns the class name
  68086. */
  68087. getClassName(): string;
  68088. /**
  68089. * Gets the value input component
  68090. */
  68091. get value(): NodeMaterialConnectionPoint;
  68092. /**
  68093. * Gets the output component
  68094. */
  68095. get output(): NodeMaterialConnectionPoint;
  68096. protected _buildBlock(state: NodeMaterialBuildState): this;
  68097. }
  68098. }
  68099. declare module BABYLON {
  68100. /**
  68101. * Block used to get negative version of a value (i.e. x * -1)
  68102. */
  68103. export class NegateBlock extends NodeMaterialBlock {
  68104. /**
  68105. * Creates a new NegateBlock
  68106. * @param name defines the block name
  68107. */
  68108. constructor(name: string);
  68109. /**
  68110. * Gets the current class name
  68111. * @returns the class name
  68112. */
  68113. getClassName(): string;
  68114. /**
  68115. * Gets the value input component
  68116. */
  68117. get value(): NodeMaterialConnectionPoint;
  68118. /**
  68119. * Gets the output component
  68120. */
  68121. get output(): NodeMaterialConnectionPoint;
  68122. protected _buildBlock(state: NodeMaterialBuildState): this;
  68123. }
  68124. }
  68125. declare module BABYLON {
  68126. /**
  68127. * Block used to get the value of the first parameter raised to the power of the second
  68128. */
  68129. export class PowBlock extends NodeMaterialBlock {
  68130. /**
  68131. * Creates a new PowBlock
  68132. * @param name defines the block name
  68133. */
  68134. constructor(name: string);
  68135. /**
  68136. * Gets the current class name
  68137. * @returns the class name
  68138. */
  68139. getClassName(): string;
  68140. /**
  68141. * Gets the value operand input component
  68142. */
  68143. get value(): NodeMaterialConnectionPoint;
  68144. /**
  68145. * Gets the power operand input component
  68146. */
  68147. get power(): NodeMaterialConnectionPoint;
  68148. /**
  68149. * Gets the output component
  68150. */
  68151. get output(): NodeMaterialConnectionPoint;
  68152. protected _buildBlock(state: NodeMaterialBuildState): this;
  68153. }
  68154. }
  68155. declare module BABYLON {
  68156. /**
  68157. * Block used to get a random number
  68158. */
  68159. export class RandomNumberBlock extends NodeMaterialBlock {
  68160. /**
  68161. * Creates a new RandomNumberBlock
  68162. * @param name defines the block name
  68163. */
  68164. constructor(name: string);
  68165. /**
  68166. * Gets the current class name
  68167. * @returns the class name
  68168. */
  68169. getClassName(): string;
  68170. /**
  68171. * Gets the seed input component
  68172. */
  68173. get seed(): NodeMaterialConnectionPoint;
  68174. /**
  68175. * Gets the output component
  68176. */
  68177. get output(): NodeMaterialConnectionPoint;
  68178. protected _buildBlock(state: NodeMaterialBuildState): this;
  68179. }
  68180. }
  68181. declare module BABYLON {
  68182. /**
  68183. * Block used to compute arc tangent of 2 values
  68184. */
  68185. export class ArcTan2Block extends NodeMaterialBlock {
  68186. /**
  68187. * Creates a new ArcTan2Block
  68188. * @param name defines the block name
  68189. */
  68190. constructor(name: string);
  68191. /**
  68192. * Gets the current class name
  68193. * @returns the class name
  68194. */
  68195. getClassName(): string;
  68196. /**
  68197. * Gets the x operand input component
  68198. */
  68199. get x(): NodeMaterialConnectionPoint;
  68200. /**
  68201. * Gets the y operand input component
  68202. */
  68203. get y(): NodeMaterialConnectionPoint;
  68204. /**
  68205. * Gets the output component
  68206. */
  68207. get output(): NodeMaterialConnectionPoint;
  68208. protected _buildBlock(state: NodeMaterialBuildState): this;
  68209. }
  68210. }
  68211. declare module BABYLON {
  68212. /**
  68213. * Block used to smooth step a value
  68214. */
  68215. export class SmoothStepBlock extends NodeMaterialBlock {
  68216. /**
  68217. * Creates a new SmoothStepBlock
  68218. * @param name defines the block name
  68219. */
  68220. constructor(name: string);
  68221. /**
  68222. * Gets the current class name
  68223. * @returns the class name
  68224. */
  68225. getClassName(): string;
  68226. /**
  68227. * Gets the value operand input component
  68228. */
  68229. get value(): NodeMaterialConnectionPoint;
  68230. /**
  68231. * Gets the first edge operand input component
  68232. */
  68233. get edge0(): NodeMaterialConnectionPoint;
  68234. /**
  68235. * Gets the second edge operand input component
  68236. */
  68237. get edge1(): NodeMaterialConnectionPoint;
  68238. /**
  68239. * Gets the output component
  68240. */
  68241. get output(): NodeMaterialConnectionPoint;
  68242. protected _buildBlock(state: NodeMaterialBuildState): this;
  68243. }
  68244. }
  68245. declare module BABYLON {
  68246. /**
  68247. * Block used to get the reciprocal (1 / x) of a value
  68248. */
  68249. export class ReciprocalBlock extends NodeMaterialBlock {
  68250. /**
  68251. * Creates a new ReciprocalBlock
  68252. * @param name defines the block name
  68253. */
  68254. constructor(name: string);
  68255. /**
  68256. * Gets the current class name
  68257. * @returns the class name
  68258. */
  68259. getClassName(): string;
  68260. /**
  68261. * Gets the input component
  68262. */
  68263. get input(): NodeMaterialConnectionPoint;
  68264. /**
  68265. * Gets the output component
  68266. */
  68267. get output(): NodeMaterialConnectionPoint;
  68268. protected _buildBlock(state: NodeMaterialBuildState): this;
  68269. }
  68270. }
  68271. declare module BABYLON {
  68272. /**
  68273. * Block used to replace a color by another one
  68274. */
  68275. export class ReplaceColorBlock extends NodeMaterialBlock {
  68276. /**
  68277. * Creates a new ReplaceColorBlock
  68278. * @param name defines the block name
  68279. */
  68280. constructor(name: string);
  68281. /**
  68282. * Gets the current class name
  68283. * @returns the class name
  68284. */
  68285. getClassName(): string;
  68286. /**
  68287. * Gets the value input component
  68288. */
  68289. get value(): NodeMaterialConnectionPoint;
  68290. /**
  68291. * Gets the reference input component
  68292. */
  68293. get reference(): NodeMaterialConnectionPoint;
  68294. /**
  68295. * Gets the distance input component
  68296. */
  68297. get distance(): NodeMaterialConnectionPoint;
  68298. /**
  68299. * Gets the replacement input component
  68300. */
  68301. get replacement(): NodeMaterialConnectionPoint;
  68302. /**
  68303. * Gets the output component
  68304. */
  68305. get output(): NodeMaterialConnectionPoint;
  68306. protected _buildBlock(state: NodeMaterialBuildState): this;
  68307. }
  68308. }
  68309. declare module BABYLON {
  68310. /**
  68311. * Block used to posterize a value
  68312. * @see https://en.wikipedia.org/wiki/Posterization
  68313. */
  68314. export class PosterizeBlock extends NodeMaterialBlock {
  68315. /**
  68316. * Creates a new PosterizeBlock
  68317. * @param name defines the block name
  68318. */
  68319. constructor(name: string);
  68320. /**
  68321. * Gets the current class name
  68322. * @returns the class name
  68323. */
  68324. getClassName(): string;
  68325. /**
  68326. * Gets the value input component
  68327. */
  68328. get value(): NodeMaterialConnectionPoint;
  68329. /**
  68330. * Gets the steps input component
  68331. */
  68332. get steps(): NodeMaterialConnectionPoint;
  68333. /**
  68334. * Gets the output component
  68335. */
  68336. get output(): NodeMaterialConnectionPoint;
  68337. protected _buildBlock(state: NodeMaterialBuildState): this;
  68338. }
  68339. }
  68340. declare module BABYLON {
  68341. /**
  68342. * Operations supported by the Wave block
  68343. */
  68344. export enum WaveBlockKind {
  68345. /** SawTooth */
  68346. SawTooth = 0,
  68347. /** Square */
  68348. Square = 1,
  68349. /** Triangle */
  68350. Triangle = 2
  68351. }
  68352. /**
  68353. * Block used to apply wave operation to floats
  68354. */
  68355. export class WaveBlock extends NodeMaterialBlock {
  68356. /**
  68357. * Gets or sets the kibnd of wave to be applied by the block
  68358. */
  68359. kind: WaveBlockKind;
  68360. /**
  68361. * Creates a new WaveBlock
  68362. * @param name defines the block name
  68363. */
  68364. constructor(name: string);
  68365. /**
  68366. * Gets the current class name
  68367. * @returns the class name
  68368. */
  68369. getClassName(): string;
  68370. /**
  68371. * Gets the input component
  68372. */
  68373. get input(): NodeMaterialConnectionPoint;
  68374. /**
  68375. * Gets the output component
  68376. */
  68377. get output(): NodeMaterialConnectionPoint;
  68378. protected _buildBlock(state: NodeMaterialBuildState): this;
  68379. serialize(): any;
  68380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68381. }
  68382. }
  68383. declare module BABYLON {
  68384. /**
  68385. * Class used to store a color step for the GradientBlock
  68386. */
  68387. export class GradientBlockColorStep {
  68388. private _step;
  68389. /**
  68390. * Gets value indicating which step this color is associated with (between 0 and 1)
  68391. */
  68392. get step(): number;
  68393. /**
  68394. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68395. */
  68396. set step(val: number);
  68397. private _color;
  68398. /**
  68399. * Gets the color associated with this step
  68400. */
  68401. get color(): Color3;
  68402. /**
  68403. * Sets the color associated with this step
  68404. */
  68405. set color(val: Color3);
  68406. /**
  68407. * Creates a new GradientBlockColorStep
  68408. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68409. * @param color defines the color associated with this step
  68410. */
  68411. constructor(step: number, color: Color3);
  68412. }
  68413. /**
  68414. * Block used to return a color from a gradient based on an input value between 0 and 1
  68415. */
  68416. export class GradientBlock extends NodeMaterialBlock {
  68417. /**
  68418. * Gets or sets the list of color steps
  68419. */
  68420. colorSteps: GradientBlockColorStep[];
  68421. /** Gets an observable raised when the value is changed */
  68422. onValueChangedObservable: Observable<GradientBlock>;
  68423. /** calls observable when the value is changed*/
  68424. colorStepsUpdated(): void;
  68425. /**
  68426. * Creates a new GradientBlock
  68427. * @param name defines the block name
  68428. */
  68429. constructor(name: string);
  68430. /**
  68431. * Gets the current class name
  68432. * @returns the class name
  68433. */
  68434. getClassName(): string;
  68435. /**
  68436. * Gets the gradient input component
  68437. */
  68438. get gradient(): NodeMaterialConnectionPoint;
  68439. /**
  68440. * Gets the output component
  68441. */
  68442. get output(): NodeMaterialConnectionPoint;
  68443. private _writeColorConstant;
  68444. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68445. serialize(): any;
  68446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68447. protected _dumpPropertiesCode(): string;
  68448. }
  68449. }
  68450. declare module BABYLON {
  68451. /**
  68452. * Block used to normalize lerp between 2 values
  68453. */
  68454. export class NLerpBlock extends NodeMaterialBlock {
  68455. /**
  68456. * Creates a new NLerpBlock
  68457. * @param name defines the block name
  68458. */
  68459. constructor(name: string);
  68460. /**
  68461. * Gets the current class name
  68462. * @returns the class name
  68463. */
  68464. getClassName(): string;
  68465. /**
  68466. * Gets the left operand input component
  68467. */
  68468. get left(): NodeMaterialConnectionPoint;
  68469. /**
  68470. * Gets the right operand input component
  68471. */
  68472. get right(): NodeMaterialConnectionPoint;
  68473. /**
  68474. * Gets the gradient operand input component
  68475. */
  68476. get gradient(): NodeMaterialConnectionPoint;
  68477. /**
  68478. * Gets the output component
  68479. */
  68480. get output(): NodeMaterialConnectionPoint;
  68481. protected _buildBlock(state: NodeMaterialBuildState): this;
  68482. }
  68483. }
  68484. declare module BABYLON {
  68485. /**
  68486. * block used to Generate a Worley Noise 3D Noise Pattern
  68487. */
  68488. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68489. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68490. manhattanDistance: boolean;
  68491. /**
  68492. * Creates a new WorleyNoise3DBlock
  68493. * @param name defines the block name
  68494. */
  68495. constructor(name: string);
  68496. /**
  68497. * Gets the current class name
  68498. * @returns the class name
  68499. */
  68500. getClassName(): string;
  68501. /**
  68502. * Gets the seed input component
  68503. */
  68504. get seed(): NodeMaterialConnectionPoint;
  68505. /**
  68506. * Gets the jitter input component
  68507. */
  68508. get jitter(): NodeMaterialConnectionPoint;
  68509. /**
  68510. * Gets the output component
  68511. */
  68512. get output(): NodeMaterialConnectionPoint;
  68513. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68514. /**
  68515. * Exposes the properties to the UI?
  68516. */
  68517. protected _dumpPropertiesCode(): string;
  68518. /**
  68519. * Exposes the properties to the Seralize?
  68520. */
  68521. serialize(): any;
  68522. /**
  68523. * Exposes the properties to the deseralize?
  68524. */
  68525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68526. }
  68527. }
  68528. declare module BABYLON {
  68529. /**
  68530. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68531. */
  68532. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68533. /**
  68534. * Creates a new SimplexPerlin3DBlock
  68535. * @param name defines the block name
  68536. */
  68537. constructor(name: string);
  68538. /**
  68539. * Gets the current class name
  68540. * @returns the class name
  68541. */
  68542. getClassName(): string;
  68543. /**
  68544. * Gets the seed operand input component
  68545. */
  68546. get seed(): NodeMaterialConnectionPoint;
  68547. /**
  68548. * Gets the output component
  68549. */
  68550. get output(): NodeMaterialConnectionPoint;
  68551. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68552. }
  68553. }
  68554. declare module BABYLON {
  68555. /**
  68556. * Block used to blend normals
  68557. */
  68558. export class NormalBlendBlock extends NodeMaterialBlock {
  68559. /**
  68560. * Creates a new NormalBlendBlock
  68561. * @param name defines the block name
  68562. */
  68563. constructor(name: string);
  68564. /**
  68565. * Gets the current class name
  68566. * @returns the class name
  68567. */
  68568. getClassName(): string;
  68569. /**
  68570. * Gets the first input component
  68571. */
  68572. get normalMap0(): NodeMaterialConnectionPoint;
  68573. /**
  68574. * Gets the second input component
  68575. */
  68576. get normalMap1(): NodeMaterialConnectionPoint;
  68577. /**
  68578. * Gets the output component
  68579. */
  68580. get output(): NodeMaterialConnectionPoint;
  68581. protected _buildBlock(state: NodeMaterialBuildState): this;
  68582. }
  68583. }
  68584. declare module BABYLON {
  68585. /**
  68586. * Block used to rotate a 2d vector by a given angle
  68587. */
  68588. export class Rotate2dBlock extends NodeMaterialBlock {
  68589. /**
  68590. * Creates a new Rotate2dBlock
  68591. * @param name defines the block name
  68592. */
  68593. constructor(name: string);
  68594. /**
  68595. * Gets the current class name
  68596. * @returns the class name
  68597. */
  68598. getClassName(): string;
  68599. /**
  68600. * Gets the input vector
  68601. */
  68602. get input(): NodeMaterialConnectionPoint;
  68603. /**
  68604. * Gets the input angle
  68605. */
  68606. get angle(): NodeMaterialConnectionPoint;
  68607. /**
  68608. * Gets the output component
  68609. */
  68610. get output(): NodeMaterialConnectionPoint;
  68611. autoConfigure(material: NodeMaterial): void;
  68612. protected _buildBlock(state: NodeMaterialBuildState): this;
  68613. }
  68614. }
  68615. declare module BABYLON {
  68616. /**
  68617. * Block used to get the reflected vector from a direction and a normal
  68618. */
  68619. export class ReflectBlock extends NodeMaterialBlock {
  68620. /**
  68621. * Creates a new ReflectBlock
  68622. * @param name defines the block name
  68623. */
  68624. constructor(name: string);
  68625. /**
  68626. * Gets the current class name
  68627. * @returns the class name
  68628. */
  68629. getClassName(): string;
  68630. /**
  68631. * Gets the incident component
  68632. */
  68633. get incident(): NodeMaterialConnectionPoint;
  68634. /**
  68635. * Gets the normal component
  68636. */
  68637. get normal(): NodeMaterialConnectionPoint;
  68638. /**
  68639. * Gets the output component
  68640. */
  68641. get output(): NodeMaterialConnectionPoint;
  68642. protected _buildBlock(state: NodeMaterialBuildState): this;
  68643. }
  68644. }
  68645. declare module BABYLON {
  68646. /**
  68647. * Block used to get the refracted vector from a direction and a normal
  68648. */
  68649. export class RefractBlock extends NodeMaterialBlock {
  68650. /**
  68651. * Creates a new RefractBlock
  68652. * @param name defines the block name
  68653. */
  68654. constructor(name: string);
  68655. /**
  68656. * Gets the current class name
  68657. * @returns the class name
  68658. */
  68659. getClassName(): string;
  68660. /**
  68661. * Gets the incident component
  68662. */
  68663. get incident(): NodeMaterialConnectionPoint;
  68664. /**
  68665. * Gets the normal component
  68666. */
  68667. get normal(): NodeMaterialConnectionPoint;
  68668. /**
  68669. * Gets the index of refraction component
  68670. */
  68671. get ior(): NodeMaterialConnectionPoint;
  68672. /**
  68673. * Gets the output component
  68674. */
  68675. get output(): NodeMaterialConnectionPoint;
  68676. protected _buildBlock(state: NodeMaterialBuildState): this;
  68677. }
  68678. }
  68679. declare module BABYLON {
  68680. /**
  68681. * Block used to desaturate a color
  68682. */
  68683. export class DesaturateBlock extends NodeMaterialBlock {
  68684. /**
  68685. * Creates a new DesaturateBlock
  68686. * @param name defines the block name
  68687. */
  68688. constructor(name: string);
  68689. /**
  68690. * Gets the current class name
  68691. * @returns the class name
  68692. */
  68693. getClassName(): string;
  68694. /**
  68695. * Gets the color operand input component
  68696. */
  68697. get color(): NodeMaterialConnectionPoint;
  68698. /**
  68699. * Gets the level operand input component
  68700. */
  68701. get level(): NodeMaterialConnectionPoint;
  68702. /**
  68703. * Gets the output component
  68704. */
  68705. get output(): NodeMaterialConnectionPoint;
  68706. protected _buildBlock(state: NodeMaterialBuildState): this;
  68707. }
  68708. }
  68709. declare module BABYLON {
  68710. /**
  68711. * Block used to implement the reflection module of the PBR material
  68712. */
  68713. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68714. /** @hidden */
  68715. _defineLODReflectionAlpha: string;
  68716. /** @hidden */
  68717. _defineLinearSpecularReflection: string;
  68718. private _vEnvironmentIrradianceName;
  68719. /** @hidden */
  68720. _vReflectionMicrosurfaceInfosName: string;
  68721. /** @hidden */
  68722. _vReflectionInfosName: string;
  68723. /** @hidden */
  68724. _vReflectionFilteringInfoName: string;
  68725. private _scene;
  68726. /**
  68727. * The properties below are set by the main PBR block prior to calling methods of this class.
  68728. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68729. * It's less burden on the user side in the editor part.
  68730. */
  68731. /** @hidden */
  68732. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68733. /** @hidden */
  68734. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68735. /** @hidden */
  68736. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68737. /** @hidden */
  68738. viewConnectionPoint: NodeMaterialConnectionPoint;
  68739. /**
  68740. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68741. * diffuse part of the IBL.
  68742. */
  68743. useSphericalHarmonics: boolean;
  68744. /**
  68745. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68746. */
  68747. forceIrradianceInFragment: boolean;
  68748. /**
  68749. * Create a new ReflectionBlock
  68750. * @param name defines the block name
  68751. */
  68752. constructor(name: string);
  68753. /**
  68754. * Gets the current class name
  68755. * @returns the class name
  68756. */
  68757. getClassName(): string;
  68758. /**
  68759. * Gets the position input component
  68760. */
  68761. get position(): NodeMaterialConnectionPoint;
  68762. /**
  68763. * Gets the world position input component
  68764. */
  68765. get worldPosition(): NodeMaterialConnectionPoint;
  68766. /**
  68767. * Gets the world normal input component
  68768. */
  68769. get worldNormal(): NodeMaterialConnectionPoint;
  68770. /**
  68771. * Gets the world input component
  68772. */
  68773. get world(): NodeMaterialConnectionPoint;
  68774. /**
  68775. * Gets the camera (or eye) position component
  68776. */
  68777. get cameraPosition(): NodeMaterialConnectionPoint;
  68778. /**
  68779. * Gets the view input component
  68780. */
  68781. get view(): NodeMaterialConnectionPoint;
  68782. /**
  68783. * Gets the color input component
  68784. */
  68785. get color(): NodeMaterialConnectionPoint;
  68786. /**
  68787. * Gets the reflection object output component
  68788. */
  68789. get reflection(): NodeMaterialConnectionPoint;
  68790. /**
  68791. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68792. */
  68793. get hasTexture(): boolean;
  68794. /**
  68795. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68796. */
  68797. get reflectionColor(): string;
  68798. protected _getTexture(): Nullable<BaseTexture>;
  68799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68800. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68801. /**
  68802. * Gets the code to inject in the vertex shader
  68803. * @param state current state of the node material building
  68804. * @returns the shader code
  68805. */
  68806. handleVertexSide(state: NodeMaterialBuildState): string;
  68807. /**
  68808. * Gets the main code of the block (fragment side)
  68809. * @param state current state of the node material building
  68810. * @param normalVarName name of the existing variable corresponding to the normal
  68811. * @returns the shader code
  68812. */
  68813. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68814. protected _buildBlock(state: NodeMaterialBuildState): this;
  68815. protected _dumpPropertiesCode(): string;
  68816. serialize(): any;
  68817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68818. }
  68819. }
  68820. declare module BABYLON {
  68821. /**
  68822. * Block used to implement the sheen module of the PBR material
  68823. */
  68824. export class SheenBlock extends NodeMaterialBlock {
  68825. /**
  68826. * Create a new SheenBlock
  68827. * @param name defines the block name
  68828. */
  68829. constructor(name: string);
  68830. /**
  68831. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68832. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68833. * making it easier to setup and tweak the effect
  68834. */
  68835. albedoScaling: boolean;
  68836. /**
  68837. * Defines if the sheen is linked to the sheen color.
  68838. */
  68839. linkSheenWithAlbedo: boolean;
  68840. /**
  68841. * Initialize the block and prepare the context for build
  68842. * @param state defines the state that will be used for the build
  68843. */
  68844. initialize(state: NodeMaterialBuildState): void;
  68845. /**
  68846. * Gets the current class name
  68847. * @returns the class name
  68848. */
  68849. getClassName(): string;
  68850. /**
  68851. * Gets the intensity input component
  68852. */
  68853. get intensity(): NodeMaterialConnectionPoint;
  68854. /**
  68855. * Gets the color input component
  68856. */
  68857. get color(): NodeMaterialConnectionPoint;
  68858. /**
  68859. * Gets the roughness input component
  68860. */
  68861. get roughness(): NodeMaterialConnectionPoint;
  68862. /**
  68863. * Gets the sheen object output component
  68864. */
  68865. get sheen(): NodeMaterialConnectionPoint;
  68866. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68867. /**
  68868. * Gets the main code of the block (fragment side)
  68869. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68870. * @returns the shader code
  68871. */
  68872. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68873. protected _buildBlock(state: NodeMaterialBuildState): this;
  68874. protected _dumpPropertiesCode(): string;
  68875. serialize(): any;
  68876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68877. }
  68878. }
  68879. declare module BABYLON {
  68880. /**
  68881. * Block used to implement the anisotropy module of the PBR material
  68882. */
  68883. export class AnisotropyBlock extends NodeMaterialBlock {
  68884. /**
  68885. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68886. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68887. * It's less burden on the user side in the editor part.
  68888. */
  68889. /** @hidden */
  68890. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68891. /** @hidden */
  68892. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68893. /**
  68894. * Create a new AnisotropyBlock
  68895. * @param name defines the block name
  68896. */
  68897. constructor(name: string);
  68898. /**
  68899. * Initialize the block and prepare the context for build
  68900. * @param state defines the state that will be used for the build
  68901. */
  68902. initialize(state: NodeMaterialBuildState): void;
  68903. /**
  68904. * Gets the current class name
  68905. * @returns the class name
  68906. */
  68907. getClassName(): string;
  68908. /**
  68909. * Gets the intensity input component
  68910. */
  68911. get intensity(): NodeMaterialConnectionPoint;
  68912. /**
  68913. * Gets the direction input component
  68914. */
  68915. get direction(): NodeMaterialConnectionPoint;
  68916. /**
  68917. * Gets the uv input component
  68918. */
  68919. get uv(): NodeMaterialConnectionPoint;
  68920. /**
  68921. * Gets the worldTangent input component
  68922. */
  68923. get worldTangent(): NodeMaterialConnectionPoint;
  68924. /**
  68925. * Gets the anisotropy object output component
  68926. */
  68927. get anisotropy(): NodeMaterialConnectionPoint;
  68928. private _generateTBNSpace;
  68929. /**
  68930. * Gets the main code of the block (fragment side)
  68931. * @param state current state of the node material building
  68932. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68933. * @returns the shader code
  68934. */
  68935. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68937. protected _buildBlock(state: NodeMaterialBuildState): this;
  68938. }
  68939. }
  68940. declare module BABYLON {
  68941. /**
  68942. * Block used to implement the clear coat module of the PBR material
  68943. */
  68944. export class ClearCoatBlock extends NodeMaterialBlock {
  68945. private _scene;
  68946. /**
  68947. * Create a new ClearCoatBlock
  68948. * @param name defines the block name
  68949. */
  68950. constructor(name: string);
  68951. /**
  68952. * Defines if the F0 value should be remapped to account for the interface change in the material.
  68953. */
  68954. remapF0OnInterfaceChange: boolean;
  68955. /**
  68956. * Initialize the block and prepare the context for build
  68957. * @param state defines the state that will be used for the build
  68958. */
  68959. initialize(state: NodeMaterialBuildState): void;
  68960. /**
  68961. * Gets the current class name
  68962. * @returns the class name
  68963. */
  68964. getClassName(): string;
  68965. /**
  68966. * Gets the intensity input component
  68967. */
  68968. get intensity(): NodeMaterialConnectionPoint;
  68969. /**
  68970. * Gets the roughness input component
  68971. */
  68972. get roughness(): NodeMaterialConnectionPoint;
  68973. /**
  68974. * Gets the ior input component
  68975. */
  68976. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68977. /**
  68978. * Gets the bump texture input component
  68979. */
  68980. get normalMapColor(): NodeMaterialConnectionPoint;
  68981. /**
  68982. * Gets the uv input component
  68983. */
  68984. get uv(): NodeMaterialConnectionPoint;
  68985. /**
  68986. * Gets the tint color input component
  68987. */
  68988. get tintColor(): NodeMaterialConnectionPoint;
  68989. /**
  68990. * Gets the tint "at distance" input component
  68991. */
  68992. get tintAtDistance(): NodeMaterialConnectionPoint;
  68993. /**
  68994. * Gets the tint thickness input component
  68995. */
  68996. get tintThickness(): NodeMaterialConnectionPoint;
  68997. /**
  68998. * Gets the world tangent input component
  68999. */
  69000. get worldTangent(): NodeMaterialConnectionPoint;
  69001. /**
  69002. * Gets the clear coat object output component
  69003. */
  69004. get clearcoat(): NodeMaterialConnectionPoint;
  69005. autoConfigure(material: NodeMaterial): void;
  69006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69007. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69008. private _generateTBNSpace;
  69009. /**
  69010. * Gets the main code of the block (fragment side)
  69011. * @param state current state of the node material building
  69012. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69013. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69014. * @param worldPosVarName name of the variable holding the world position
  69015. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69016. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69017. * @param worldNormalVarName name of the variable holding the world normal
  69018. * @returns the shader code
  69019. */
  69020. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69021. protected _buildBlock(state: NodeMaterialBuildState): this;
  69022. protected _dumpPropertiesCode(): string;
  69023. serialize(): any;
  69024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69025. }
  69026. }
  69027. declare module BABYLON {
  69028. /**
  69029. * Block used to implement the sub surface module of the PBR material
  69030. */
  69031. export class SubSurfaceBlock extends NodeMaterialBlock {
  69032. /**
  69033. * Create a new SubSurfaceBlock
  69034. * @param name defines the block name
  69035. */
  69036. constructor(name: string);
  69037. /**
  69038. * Initialize the block and prepare the context for build
  69039. * @param state defines the state that will be used for the build
  69040. */
  69041. initialize(state: NodeMaterialBuildState): void;
  69042. /**
  69043. * Gets the current class name
  69044. * @returns the class name
  69045. */
  69046. getClassName(): string;
  69047. /**
  69048. * Gets the thickness component
  69049. */
  69050. get thickness(): NodeMaterialConnectionPoint;
  69051. /**
  69052. * Gets the tint color input component
  69053. */
  69054. get tintColor(): NodeMaterialConnectionPoint;
  69055. /**
  69056. * Gets the translucency intensity input component
  69057. */
  69058. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69059. /**
  69060. * Gets the translucency diffusion distance input component
  69061. */
  69062. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69063. /**
  69064. * Gets the refraction object parameters
  69065. */
  69066. get refraction(): NodeMaterialConnectionPoint;
  69067. /**
  69068. * Gets the sub surface object output component
  69069. */
  69070. get subsurface(): NodeMaterialConnectionPoint;
  69071. autoConfigure(material: NodeMaterial): void;
  69072. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69073. /**
  69074. * Gets the main code of the block (fragment side)
  69075. * @param state current state of the node material building
  69076. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69077. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69078. * @param worldPosVarName name of the variable holding the world position
  69079. * @returns the shader code
  69080. */
  69081. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69082. protected _buildBlock(state: NodeMaterialBuildState): this;
  69083. }
  69084. }
  69085. declare module BABYLON {
  69086. /**
  69087. * Block used to implement the PBR metallic/roughness model
  69088. */
  69089. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69090. /**
  69091. * Gets or sets the light associated with this block
  69092. */
  69093. light: Nullable<Light>;
  69094. private _lightId;
  69095. private _scene;
  69096. private _environmentBRDFTexture;
  69097. private _environmentBrdfSamplerName;
  69098. private _vNormalWName;
  69099. private _invertNormalName;
  69100. private _metallicReflectanceColor;
  69101. private _metallicF0Factor;
  69102. private _vMetallicReflectanceFactorsName;
  69103. /**
  69104. * Create a new ReflectionBlock
  69105. * @param name defines the block name
  69106. */
  69107. constructor(name: string);
  69108. /**
  69109. * Intensity of the direct lights e.g. the four lights available in your scene.
  69110. * This impacts both the direct diffuse and specular highlights.
  69111. */
  69112. directIntensity: number;
  69113. /**
  69114. * Intensity of the environment e.g. how much the environment will light the object
  69115. * either through harmonics for rough material or through the refelction for shiny ones.
  69116. */
  69117. environmentIntensity: number;
  69118. /**
  69119. * This is a special control allowing the reduction of the specular highlights coming from the
  69120. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69121. */
  69122. specularIntensity: number;
  69123. /**
  69124. * Defines the falloff type used in this material.
  69125. * It by default is Physical.
  69126. */
  69127. lightFalloff: number;
  69128. /**
  69129. * Specifies that alpha test should be used
  69130. */
  69131. useAlphaTest: boolean;
  69132. /**
  69133. * Defines the alpha limits in alpha test mode.
  69134. */
  69135. alphaTestCutoff: number;
  69136. /**
  69137. * Specifies that alpha blending should be used
  69138. */
  69139. useAlphaBlending: boolean;
  69140. /**
  69141. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69142. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69143. */
  69144. useRadianceOverAlpha: boolean;
  69145. /**
  69146. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69147. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69148. */
  69149. useSpecularOverAlpha: boolean;
  69150. /**
  69151. * Enables specular anti aliasing in the PBR shader.
  69152. * It will both interacts on the Geometry for analytical and IBL lighting.
  69153. * It also prefilter the roughness map based on the bump values.
  69154. */
  69155. enableSpecularAntiAliasing: boolean;
  69156. /**
  69157. * Enables realtime filtering on the texture.
  69158. */
  69159. realTimeFiltering: boolean;
  69160. /**
  69161. * Quality switch for realtime filtering
  69162. */
  69163. realTimeFilteringQuality: number;
  69164. /**
  69165. * Defines if the material uses energy conservation.
  69166. */
  69167. useEnergyConservation: boolean;
  69168. /**
  69169. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69170. * too much the area relying on ambient texture to define their ambient occlusion.
  69171. */
  69172. useRadianceOcclusion: boolean;
  69173. /**
  69174. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69175. * makes the reflect vector face the model (under horizon).
  69176. */
  69177. useHorizonOcclusion: boolean;
  69178. /**
  69179. * If set to true, no lighting calculations will be applied.
  69180. */
  69181. unlit: boolean;
  69182. /**
  69183. * Force normal to face away from face.
  69184. */
  69185. forceNormalForward: boolean;
  69186. /**
  69187. * Defines the material debug mode.
  69188. * It helps seeing only some components of the material while troubleshooting.
  69189. */
  69190. debugMode: number;
  69191. /**
  69192. * Specify from where on screen the debug mode should start.
  69193. * The value goes from -1 (full screen) to 1 (not visible)
  69194. * It helps with side by side comparison against the final render
  69195. * This defaults to 0
  69196. */
  69197. debugLimit: number;
  69198. /**
  69199. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69200. * You can use the factor to better multiply the final value.
  69201. */
  69202. debugFactor: number;
  69203. /**
  69204. * Initialize the block and prepare the context for build
  69205. * @param state defines the state that will be used for the build
  69206. */
  69207. initialize(state: NodeMaterialBuildState): void;
  69208. /**
  69209. * Gets the current class name
  69210. * @returns the class name
  69211. */
  69212. getClassName(): string;
  69213. /**
  69214. * Gets the world position input component
  69215. */
  69216. get worldPosition(): NodeMaterialConnectionPoint;
  69217. /**
  69218. * Gets the world normal input component
  69219. */
  69220. get worldNormal(): NodeMaterialConnectionPoint;
  69221. /**
  69222. * Gets the view matrix parameter
  69223. */
  69224. get view(): NodeMaterialConnectionPoint;
  69225. /**
  69226. * Gets the camera position input component
  69227. */
  69228. get cameraPosition(): NodeMaterialConnectionPoint;
  69229. /**
  69230. * Gets the perturbed normal input component
  69231. */
  69232. get perturbedNormal(): NodeMaterialConnectionPoint;
  69233. /**
  69234. * Gets the base color input component
  69235. */
  69236. get baseColor(): NodeMaterialConnectionPoint;
  69237. /**
  69238. * Gets the metallic input component
  69239. */
  69240. get metallic(): NodeMaterialConnectionPoint;
  69241. /**
  69242. * Gets the roughness input component
  69243. */
  69244. get roughness(): NodeMaterialConnectionPoint;
  69245. /**
  69246. * Gets the ambient occlusion input component
  69247. */
  69248. get ambientOcc(): NodeMaterialConnectionPoint;
  69249. /**
  69250. * Gets the opacity input component
  69251. */
  69252. get opacity(): NodeMaterialConnectionPoint;
  69253. /**
  69254. * Gets the index of refraction input component
  69255. */
  69256. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69257. /**
  69258. * Gets the ambient color input component
  69259. */
  69260. get ambientColor(): NodeMaterialConnectionPoint;
  69261. /**
  69262. * Gets the reflection object parameters
  69263. */
  69264. get reflection(): NodeMaterialConnectionPoint;
  69265. /**
  69266. * Gets the clear coat object parameters
  69267. */
  69268. get clearcoat(): NodeMaterialConnectionPoint;
  69269. /**
  69270. * Gets the sheen object parameters
  69271. */
  69272. get sheen(): NodeMaterialConnectionPoint;
  69273. /**
  69274. * Gets the sub surface object parameters
  69275. */
  69276. get subsurface(): NodeMaterialConnectionPoint;
  69277. /**
  69278. * Gets the anisotropy object parameters
  69279. */
  69280. get anisotropy(): NodeMaterialConnectionPoint;
  69281. /**
  69282. * Gets the ambient output component
  69283. */
  69284. get ambientClr(): NodeMaterialConnectionPoint;
  69285. /**
  69286. * Gets the diffuse output component
  69287. */
  69288. get diffuseDir(): NodeMaterialConnectionPoint;
  69289. /**
  69290. * Gets the specular output component
  69291. */
  69292. get specularDir(): NodeMaterialConnectionPoint;
  69293. /**
  69294. * Gets the clear coat output component
  69295. */
  69296. get clearcoatDir(): NodeMaterialConnectionPoint;
  69297. /**
  69298. * Gets the sheen output component
  69299. */
  69300. get sheenDir(): NodeMaterialConnectionPoint;
  69301. /**
  69302. * Gets the indirect diffuse output component
  69303. */
  69304. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69305. /**
  69306. * Gets the indirect specular output component
  69307. */
  69308. get specularIndirect(): NodeMaterialConnectionPoint;
  69309. /**
  69310. * Gets the indirect clear coat output component
  69311. */
  69312. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69313. /**
  69314. * Gets the indirect sheen output component
  69315. */
  69316. get sheenIndirect(): NodeMaterialConnectionPoint;
  69317. /**
  69318. * Gets the refraction output component
  69319. */
  69320. get refraction(): NodeMaterialConnectionPoint;
  69321. /**
  69322. * Gets the global lighting output component
  69323. */
  69324. get lighting(): NodeMaterialConnectionPoint;
  69325. /**
  69326. * Gets the shadow output component
  69327. */
  69328. get shadow(): NodeMaterialConnectionPoint;
  69329. /**
  69330. * Gets the alpha output component
  69331. */
  69332. get alpha(): NodeMaterialConnectionPoint;
  69333. autoConfigure(material: NodeMaterial): void;
  69334. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69335. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69336. isReady(): boolean;
  69337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69338. private _injectVertexCode;
  69339. private _getAlbedoOpacityCode;
  69340. private _getAmbientOcclusionCode;
  69341. private _getReflectivityCode;
  69342. protected _buildBlock(state: NodeMaterialBuildState): this;
  69343. protected _dumpPropertiesCode(): string;
  69344. serialize(): any;
  69345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69346. }
  69347. }
  69348. declare module BABYLON {
  69349. /**
  69350. * Block used to compute value of one parameter modulo another
  69351. */
  69352. export class ModBlock extends NodeMaterialBlock {
  69353. /**
  69354. * Creates a new ModBlock
  69355. * @param name defines the block name
  69356. */
  69357. constructor(name: string);
  69358. /**
  69359. * Gets the current class name
  69360. * @returns the class name
  69361. */
  69362. getClassName(): string;
  69363. /**
  69364. * Gets the left operand input component
  69365. */
  69366. get left(): NodeMaterialConnectionPoint;
  69367. /**
  69368. * Gets the right operand input component
  69369. */
  69370. get right(): NodeMaterialConnectionPoint;
  69371. /**
  69372. * Gets the output component
  69373. */
  69374. get output(): NodeMaterialConnectionPoint;
  69375. protected _buildBlock(state: NodeMaterialBuildState): this;
  69376. }
  69377. }
  69378. declare module BABYLON {
  69379. /**
  69380. * Configuration for Draco compression
  69381. */
  69382. export interface IDracoCompressionConfiguration {
  69383. /**
  69384. * Configuration for the decoder.
  69385. */
  69386. decoder: {
  69387. /**
  69388. * The url to the WebAssembly module.
  69389. */
  69390. wasmUrl?: string;
  69391. /**
  69392. * The url to the WebAssembly binary.
  69393. */
  69394. wasmBinaryUrl?: string;
  69395. /**
  69396. * The url to the fallback JavaScript module.
  69397. */
  69398. fallbackUrl?: string;
  69399. };
  69400. }
  69401. /**
  69402. * Draco compression (https://google.github.io/draco/)
  69403. *
  69404. * This class wraps the Draco module.
  69405. *
  69406. * **Encoder**
  69407. *
  69408. * The encoder is not currently implemented.
  69409. *
  69410. * **Decoder**
  69411. *
  69412. * 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.
  69413. *
  69414. * To update the configuration, use the following code:
  69415. * ```javascript
  69416. * DracoCompression.Configuration = {
  69417. * decoder: {
  69418. * wasmUrl: "<url to the WebAssembly library>",
  69419. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69420. * fallbackUrl: "<url to the fallback JavaScript library>",
  69421. * }
  69422. * };
  69423. * ```
  69424. *
  69425. * 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.
  69426. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69427. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69428. *
  69429. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69430. * ```javascript
  69431. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69432. * ```
  69433. *
  69434. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69435. */
  69436. export class DracoCompression implements IDisposable {
  69437. private _workerPoolPromise?;
  69438. private _decoderModulePromise?;
  69439. /**
  69440. * The configuration. Defaults to the following urls:
  69441. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69442. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69443. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69444. */
  69445. static Configuration: IDracoCompressionConfiguration;
  69446. /**
  69447. * Returns true if the decoder configuration is available.
  69448. */
  69449. static get DecoderAvailable(): boolean;
  69450. /**
  69451. * Default number of workers to create when creating the draco compression object.
  69452. */
  69453. static DefaultNumWorkers: number;
  69454. private static GetDefaultNumWorkers;
  69455. private static _Default;
  69456. /**
  69457. * Default instance for the draco compression object.
  69458. */
  69459. static get Default(): DracoCompression;
  69460. /**
  69461. * Constructor
  69462. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69463. */
  69464. constructor(numWorkers?: number);
  69465. /**
  69466. * Stop all async operations and release resources.
  69467. */
  69468. dispose(): void;
  69469. /**
  69470. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69471. * @returns a promise that resolves when ready
  69472. */
  69473. whenReadyAsync(): Promise<void>;
  69474. /**
  69475. * Decode Draco compressed mesh data to vertex data.
  69476. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69477. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69478. * @returns A promise that resolves with the decoded vertex data
  69479. */
  69480. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69481. [kind: string]: number;
  69482. }): Promise<VertexData>;
  69483. }
  69484. }
  69485. declare module BABYLON {
  69486. /**
  69487. * Class for building Constructive Solid Geometry
  69488. */
  69489. export class CSG {
  69490. private polygons;
  69491. /**
  69492. * The world matrix
  69493. */
  69494. matrix: Matrix;
  69495. /**
  69496. * Stores the position
  69497. */
  69498. position: Vector3;
  69499. /**
  69500. * Stores the rotation
  69501. */
  69502. rotation: Vector3;
  69503. /**
  69504. * Stores the rotation quaternion
  69505. */
  69506. rotationQuaternion: Nullable<Quaternion>;
  69507. /**
  69508. * Stores the scaling vector
  69509. */
  69510. scaling: Vector3;
  69511. /**
  69512. * Convert the Mesh to CSG
  69513. * @param mesh The Mesh to convert to CSG
  69514. * @returns A new CSG from the Mesh
  69515. */
  69516. static FromMesh(mesh: Mesh): CSG;
  69517. /**
  69518. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69519. * @param polygons Polygons used to construct a CSG solid
  69520. */
  69521. private static FromPolygons;
  69522. /**
  69523. * Clones, or makes a deep copy, of the CSG
  69524. * @returns A new CSG
  69525. */
  69526. clone(): CSG;
  69527. /**
  69528. * Unions this CSG with another CSG
  69529. * @param csg The CSG to union against this CSG
  69530. * @returns The unioned CSG
  69531. */
  69532. union(csg: CSG): CSG;
  69533. /**
  69534. * Unions this CSG with another CSG in place
  69535. * @param csg The CSG to union against this CSG
  69536. */
  69537. unionInPlace(csg: CSG): void;
  69538. /**
  69539. * Subtracts this CSG with another CSG
  69540. * @param csg The CSG to subtract against this CSG
  69541. * @returns A new CSG
  69542. */
  69543. subtract(csg: CSG): CSG;
  69544. /**
  69545. * Subtracts this CSG with another CSG in place
  69546. * @param csg The CSG to subtact against this CSG
  69547. */
  69548. subtractInPlace(csg: CSG): void;
  69549. /**
  69550. * Intersect this CSG with another CSG
  69551. * @param csg The CSG to intersect against this CSG
  69552. * @returns A new CSG
  69553. */
  69554. intersect(csg: CSG): CSG;
  69555. /**
  69556. * Intersects this CSG with another CSG in place
  69557. * @param csg The CSG to intersect against this CSG
  69558. */
  69559. intersectInPlace(csg: CSG): void;
  69560. /**
  69561. * Return a new CSG solid with solid and empty space switched. This solid is
  69562. * not modified.
  69563. * @returns A new CSG solid with solid and empty space switched
  69564. */
  69565. inverse(): CSG;
  69566. /**
  69567. * Inverses the CSG in place
  69568. */
  69569. inverseInPlace(): void;
  69570. /**
  69571. * This is used to keep meshes transformations so they can be restored
  69572. * when we build back a Babylon Mesh
  69573. * NB : All CSG operations are performed in world coordinates
  69574. * @param csg The CSG to copy the transform attributes from
  69575. * @returns This CSG
  69576. */
  69577. copyTransformAttributes(csg: CSG): CSG;
  69578. /**
  69579. * Build Raw mesh from CSG
  69580. * Coordinates here are in world space
  69581. * @param name The name of the mesh geometry
  69582. * @param scene The Scene
  69583. * @param keepSubMeshes Specifies if the submeshes should be kept
  69584. * @returns A new Mesh
  69585. */
  69586. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69587. /**
  69588. * Build Mesh from CSG taking material and transforms into account
  69589. * @param name The name of the Mesh
  69590. * @param material The material of the Mesh
  69591. * @param scene The Scene
  69592. * @param keepSubMeshes Specifies if submeshes should be kept
  69593. * @returns The new Mesh
  69594. */
  69595. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69596. }
  69597. }
  69598. declare module BABYLON {
  69599. /**
  69600. * Class used to create a trail following a mesh
  69601. */
  69602. export class TrailMesh extends Mesh {
  69603. private _generator;
  69604. private _autoStart;
  69605. private _running;
  69606. private _diameter;
  69607. private _length;
  69608. private _sectionPolygonPointsCount;
  69609. private _sectionVectors;
  69610. private _sectionNormalVectors;
  69611. private _beforeRenderObserver;
  69612. /**
  69613. * @constructor
  69614. * @param name The value used by scene.getMeshByName() to do a lookup.
  69615. * @param generator The mesh or transform node to generate a trail.
  69616. * @param scene The scene to add this mesh to.
  69617. * @param diameter Diameter of trailing mesh. Default is 1.
  69618. * @param length Length of trailing mesh. Default is 60.
  69619. * @param autoStart Automatically start trailing mesh. Default true.
  69620. */
  69621. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69622. /**
  69623. * "TrailMesh"
  69624. * @returns "TrailMesh"
  69625. */
  69626. getClassName(): string;
  69627. private _createMesh;
  69628. /**
  69629. * Start trailing mesh.
  69630. */
  69631. start(): void;
  69632. /**
  69633. * Stop trailing mesh.
  69634. */
  69635. stop(): void;
  69636. /**
  69637. * Update trailing mesh geometry.
  69638. */
  69639. update(): void;
  69640. /**
  69641. * Returns a new TrailMesh object.
  69642. * @param name is a string, the name given to the new mesh
  69643. * @param newGenerator use new generator object for cloned trail mesh
  69644. * @returns a new mesh
  69645. */
  69646. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69647. /**
  69648. * Serializes this trail mesh
  69649. * @param serializationObject object to write serialization to
  69650. */
  69651. serialize(serializationObject: any): void;
  69652. /**
  69653. * Parses a serialized trail mesh
  69654. * @param parsedMesh the serialized mesh
  69655. * @param scene the scene to create the trail mesh in
  69656. * @returns the created trail mesh
  69657. */
  69658. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69659. }
  69660. }
  69661. declare module BABYLON {
  69662. /**
  69663. * Class containing static functions to help procedurally build meshes
  69664. */
  69665. export class TiledBoxBuilder {
  69666. /**
  69667. * Creates a box mesh
  69668. * 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)
  69669. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69671. * * 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
  69672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69673. * @param name defines the name of the mesh
  69674. * @param options defines the options used to create the mesh
  69675. * @param scene defines the hosting scene
  69676. * @returns the box mesh
  69677. */
  69678. static CreateTiledBox(name: string, options: {
  69679. pattern?: number;
  69680. width?: number;
  69681. height?: number;
  69682. depth?: number;
  69683. tileSize?: number;
  69684. tileWidth?: number;
  69685. tileHeight?: number;
  69686. alignHorizontal?: number;
  69687. alignVertical?: number;
  69688. faceUV?: Vector4[];
  69689. faceColors?: Color4[];
  69690. sideOrientation?: number;
  69691. updatable?: boolean;
  69692. }, scene?: Nullable<Scene>): Mesh;
  69693. }
  69694. }
  69695. declare module BABYLON {
  69696. /**
  69697. * Class containing static functions to help procedurally build meshes
  69698. */
  69699. export class TorusKnotBuilder {
  69700. /**
  69701. * Creates a torus knot mesh
  69702. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69703. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69704. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69705. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69707. * * 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
  69708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69709. * @param name defines the name of the mesh
  69710. * @param options defines the options used to create the mesh
  69711. * @param scene defines the hosting scene
  69712. * @returns the torus knot mesh
  69713. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69714. */
  69715. static CreateTorusKnot(name: string, options: {
  69716. radius?: number;
  69717. tube?: number;
  69718. radialSegments?: number;
  69719. tubularSegments?: number;
  69720. p?: number;
  69721. q?: number;
  69722. updatable?: boolean;
  69723. sideOrientation?: number;
  69724. frontUVs?: Vector4;
  69725. backUVs?: Vector4;
  69726. }, scene: any): Mesh;
  69727. }
  69728. }
  69729. declare module BABYLON {
  69730. /**
  69731. * Polygon
  69732. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69733. */
  69734. export class Polygon {
  69735. /**
  69736. * Creates a rectangle
  69737. * @param xmin bottom X coord
  69738. * @param ymin bottom Y coord
  69739. * @param xmax top X coord
  69740. * @param ymax top Y coord
  69741. * @returns points that make the resulting rectation
  69742. */
  69743. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69744. /**
  69745. * Creates a circle
  69746. * @param radius radius of circle
  69747. * @param cx scale in x
  69748. * @param cy scale in y
  69749. * @param numberOfSides number of sides that make up the circle
  69750. * @returns points that make the resulting circle
  69751. */
  69752. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69753. /**
  69754. * Creates a polygon from input string
  69755. * @param input Input polygon data
  69756. * @returns the parsed points
  69757. */
  69758. static Parse(input: string): Vector2[];
  69759. /**
  69760. * Starts building a polygon from x and y coordinates
  69761. * @param x x coordinate
  69762. * @param y y coordinate
  69763. * @returns the started path2
  69764. */
  69765. static StartingAt(x: number, y: number): Path2;
  69766. }
  69767. /**
  69768. * Builds a polygon
  69769. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69770. */
  69771. export class PolygonMeshBuilder {
  69772. private _points;
  69773. private _outlinepoints;
  69774. private _holes;
  69775. private _name;
  69776. private _scene;
  69777. private _epoints;
  69778. private _eholes;
  69779. private _addToepoint;
  69780. /**
  69781. * Babylon reference to the earcut plugin.
  69782. */
  69783. bjsEarcut: any;
  69784. /**
  69785. * Creates a PolygonMeshBuilder
  69786. * @param name name of the builder
  69787. * @param contours Path of the polygon
  69788. * @param scene scene to add to when creating the mesh
  69789. * @param earcutInjection can be used to inject your own earcut reference
  69790. */
  69791. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69792. /**
  69793. * Adds a hole within the polygon
  69794. * @param hole Array of points defining the hole
  69795. * @returns this
  69796. */
  69797. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69798. /**
  69799. * Creates the polygon
  69800. * @param updatable If the mesh should be updatable
  69801. * @param depth The depth of the mesh created
  69802. * @param smoothingThreshold Dot product threshold for smoothed normals
  69803. * @returns the created mesh
  69804. */
  69805. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  69806. /**
  69807. * Creates the polygon
  69808. * @param depth The depth of the mesh created
  69809. * @param smoothingThreshold Dot product threshold for smoothed normals
  69810. * @returns the created VertexData
  69811. */
  69812. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  69813. /**
  69814. * Adds a side to the polygon
  69815. * @param positions points that make the polygon
  69816. * @param normals normals of the polygon
  69817. * @param uvs uvs of the polygon
  69818. * @param indices indices of the polygon
  69819. * @param bounds bounds of the polygon
  69820. * @param points points of the polygon
  69821. * @param depth depth of the polygon
  69822. * @param flip flip of the polygon
  69823. */
  69824. private addSide;
  69825. }
  69826. }
  69827. declare module BABYLON {
  69828. /**
  69829. * Class containing static functions to help procedurally build meshes
  69830. */
  69831. export class PolygonBuilder {
  69832. /**
  69833. * Creates a polygon mesh
  69834. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69835. * * 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
  69836. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69838. * * 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)
  69839. * * Remember you can only change the shape positions, not their number when updating a polygon
  69840. * @param name defines the name of the mesh
  69841. * @param options defines the options used to create the mesh
  69842. * @param scene defines the hosting scene
  69843. * @param earcutInjection can be used to inject your own earcut reference
  69844. * @returns the polygon mesh
  69845. */
  69846. static CreatePolygon(name: string, options: {
  69847. shape: Vector3[];
  69848. holes?: Vector3[][];
  69849. depth?: number;
  69850. smoothingThreshold?: number;
  69851. faceUV?: Vector4[];
  69852. faceColors?: Color4[];
  69853. updatable?: boolean;
  69854. sideOrientation?: number;
  69855. frontUVs?: Vector4;
  69856. backUVs?: Vector4;
  69857. wrap?: boolean;
  69858. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69859. /**
  69860. * Creates an extruded polygon mesh, with depth in the Y direction.
  69861. * * 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)
  69862. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69863. * @param name defines the name of the mesh
  69864. * @param options defines the options used to create the mesh
  69865. * @param scene defines the hosting scene
  69866. * @param earcutInjection can be used to inject your own earcut reference
  69867. * @returns the polygon mesh
  69868. */
  69869. static ExtrudePolygon(name: string, options: {
  69870. shape: Vector3[];
  69871. holes?: Vector3[][];
  69872. depth?: number;
  69873. faceUV?: Vector4[];
  69874. faceColors?: Color4[];
  69875. updatable?: boolean;
  69876. sideOrientation?: number;
  69877. frontUVs?: Vector4;
  69878. backUVs?: Vector4;
  69879. wrap?: boolean;
  69880. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69881. }
  69882. }
  69883. declare module BABYLON {
  69884. /**
  69885. * Class containing static functions to help procedurally build meshes
  69886. */
  69887. export class LatheBuilder {
  69888. /**
  69889. * Creates lathe mesh.
  69890. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69891. * * 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
  69892. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69893. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69894. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69895. * * 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
  69896. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69897. * * 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
  69898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69899. * * 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
  69900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69902. * @param name defines the name of the mesh
  69903. * @param options defines the options used to create the mesh
  69904. * @param scene defines the hosting scene
  69905. * @returns the lathe mesh
  69906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69907. */
  69908. static CreateLathe(name: string, options: {
  69909. shape: Vector3[];
  69910. radius?: number;
  69911. tessellation?: number;
  69912. clip?: number;
  69913. arc?: number;
  69914. closed?: boolean;
  69915. updatable?: boolean;
  69916. sideOrientation?: number;
  69917. frontUVs?: Vector4;
  69918. backUVs?: Vector4;
  69919. cap?: number;
  69920. invertUV?: boolean;
  69921. }, scene?: Nullable<Scene>): Mesh;
  69922. }
  69923. }
  69924. declare module BABYLON {
  69925. /**
  69926. * Class containing static functions to help procedurally build meshes
  69927. */
  69928. export class TiledPlaneBuilder {
  69929. /**
  69930. * Creates a tiled plane mesh
  69931. * * The parameter `pattern` will, depending on value, do nothing or
  69932. * * * flip (reflect about central vertical) alternate tiles across and up
  69933. * * * flip every tile on alternate rows
  69934. * * * rotate (180 degs) alternate tiles across and up
  69935. * * * rotate every tile on alternate rows
  69936. * * * flip and rotate alternate tiles across and up
  69937. * * * flip and rotate every tile on alternate rows
  69938. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69939. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69940. * * 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
  69941. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69942. * * 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)
  69943. * * 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)
  69944. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69945. * @param name defines the name of the mesh
  69946. * @param options defines the options used to create the mesh
  69947. * @param scene defines the hosting scene
  69948. * @returns the box mesh
  69949. */
  69950. static CreateTiledPlane(name: string, options: {
  69951. pattern?: number;
  69952. tileSize?: number;
  69953. tileWidth?: number;
  69954. tileHeight?: number;
  69955. size?: number;
  69956. width?: number;
  69957. height?: number;
  69958. alignHorizontal?: number;
  69959. alignVertical?: number;
  69960. sideOrientation?: number;
  69961. frontUVs?: Vector4;
  69962. backUVs?: Vector4;
  69963. updatable?: boolean;
  69964. }, scene?: Nullable<Scene>): Mesh;
  69965. }
  69966. }
  69967. declare module BABYLON {
  69968. /**
  69969. * Class containing static functions to help procedurally build meshes
  69970. */
  69971. export class TubeBuilder {
  69972. /**
  69973. * Creates a tube mesh.
  69974. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69975. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69976. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69977. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69978. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69979. * * 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)
  69980. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69981. * * 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
  69982. * * 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
  69983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69984. * * 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
  69985. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69987. * @param name defines the name of the mesh
  69988. * @param options defines the options used to create the mesh
  69989. * @param scene defines the hosting scene
  69990. * @returns the tube mesh
  69991. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69992. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69993. */
  69994. static CreateTube(name: string, options: {
  69995. path: Vector3[];
  69996. radius?: number;
  69997. tessellation?: number;
  69998. radiusFunction?: {
  69999. (i: number, distance: number): number;
  70000. };
  70001. cap?: number;
  70002. arc?: number;
  70003. updatable?: boolean;
  70004. sideOrientation?: number;
  70005. frontUVs?: Vector4;
  70006. backUVs?: Vector4;
  70007. instance?: Mesh;
  70008. invertUV?: boolean;
  70009. }, scene?: Nullable<Scene>): Mesh;
  70010. }
  70011. }
  70012. declare module BABYLON {
  70013. /**
  70014. * Class containing static functions to help procedurally build meshes
  70015. */
  70016. export class IcoSphereBuilder {
  70017. /**
  70018. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70019. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70020. * * 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`)
  70021. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70022. * * 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
  70023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70024. * * 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
  70025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70026. * @param name defines the name of the mesh
  70027. * @param options defines the options used to create the mesh
  70028. * @param scene defines the hosting scene
  70029. * @returns the icosahedron mesh
  70030. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70031. */
  70032. static CreateIcoSphere(name: string, options: {
  70033. radius?: number;
  70034. radiusX?: number;
  70035. radiusY?: number;
  70036. radiusZ?: number;
  70037. flat?: boolean;
  70038. subdivisions?: number;
  70039. sideOrientation?: number;
  70040. frontUVs?: Vector4;
  70041. backUVs?: Vector4;
  70042. updatable?: boolean;
  70043. }, scene?: Nullable<Scene>): Mesh;
  70044. }
  70045. }
  70046. declare module BABYLON {
  70047. /**
  70048. * Class containing static functions to help procedurally build meshes
  70049. */
  70050. export class DecalBuilder {
  70051. /**
  70052. * Creates a decal mesh.
  70053. * 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
  70054. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70055. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70056. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70057. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70058. * @param name defines the name of the mesh
  70059. * @param sourceMesh defines the mesh where the decal must be applied
  70060. * @param options defines the options used to create the mesh
  70061. * @param scene defines the hosting scene
  70062. * @returns the decal mesh
  70063. * @see https://doc.babylonjs.com/how_to/decals
  70064. */
  70065. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70066. position?: Vector3;
  70067. normal?: Vector3;
  70068. size?: Vector3;
  70069. angle?: number;
  70070. }): Mesh;
  70071. }
  70072. }
  70073. declare module BABYLON {
  70074. /**
  70075. * Class containing static functions to help procedurally build meshes
  70076. */
  70077. export class MeshBuilder {
  70078. /**
  70079. * Creates a box mesh
  70080. * * The parameter `size` sets the size (float) of each box side (default 1)
  70081. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70082. * * 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)
  70083. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70085. * * 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
  70086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70087. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70088. * @param name defines the name of the mesh
  70089. * @param options defines the options used to create the mesh
  70090. * @param scene defines the hosting scene
  70091. * @returns the box mesh
  70092. */
  70093. static CreateBox(name: string, options: {
  70094. size?: number;
  70095. width?: number;
  70096. height?: number;
  70097. depth?: number;
  70098. faceUV?: Vector4[];
  70099. faceColors?: Color4[];
  70100. sideOrientation?: number;
  70101. frontUVs?: Vector4;
  70102. backUVs?: Vector4;
  70103. wrap?: boolean;
  70104. topBaseAt?: number;
  70105. bottomBaseAt?: number;
  70106. updatable?: boolean;
  70107. }, scene?: Nullable<Scene>): Mesh;
  70108. /**
  70109. * Creates a tiled box mesh
  70110. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70112. * @param name defines the name of the mesh
  70113. * @param options defines the options used to create the mesh
  70114. * @param scene defines the hosting scene
  70115. * @returns the tiled box mesh
  70116. */
  70117. static CreateTiledBox(name: string, options: {
  70118. pattern?: number;
  70119. size?: number;
  70120. width?: number;
  70121. height?: number;
  70122. depth: number;
  70123. tileSize?: number;
  70124. tileWidth?: number;
  70125. tileHeight?: number;
  70126. faceUV?: Vector4[];
  70127. faceColors?: Color4[];
  70128. alignHorizontal?: number;
  70129. alignVertical?: number;
  70130. sideOrientation?: number;
  70131. updatable?: boolean;
  70132. }, scene?: Nullable<Scene>): Mesh;
  70133. /**
  70134. * Creates a sphere mesh
  70135. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70136. * * 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`)
  70137. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70138. * * 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
  70139. * * 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)
  70140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70141. * * 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
  70142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70143. * @param name defines the name of the mesh
  70144. * @param options defines the options used to create the mesh
  70145. * @param scene defines the hosting scene
  70146. * @returns the sphere mesh
  70147. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70148. */
  70149. static CreateSphere(name: string, options: {
  70150. segments?: number;
  70151. diameter?: number;
  70152. diameterX?: number;
  70153. diameterY?: number;
  70154. diameterZ?: number;
  70155. arc?: number;
  70156. slice?: number;
  70157. sideOrientation?: number;
  70158. frontUVs?: Vector4;
  70159. backUVs?: Vector4;
  70160. updatable?: boolean;
  70161. }, scene?: Nullable<Scene>): Mesh;
  70162. /**
  70163. * Creates a plane polygonal mesh. By default, this is a disc
  70164. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70165. * * 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
  70166. * * 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
  70167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70168. * * 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
  70169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70170. * @param name defines the name of the mesh
  70171. * @param options defines the options used to create the mesh
  70172. * @param scene defines the hosting scene
  70173. * @returns the plane polygonal mesh
  70174. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70175. */
  70176. static CreateDisc(name: string, options: {
  70177. radius?: number;
  70178. tessellation?: number;
  70179. arc?: number;
  70180. updatable?: boolean;
  70181. sideOrientation?: number;
  70182. frontUVs?: Vector4;
  70183. backUVs?: Vector4;
  70184. }, scene?: Nullable<Scene>): Mesh;
  70185. /**
  70186. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70187. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70188. * * 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`)
  70189. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70190. * * 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
  70191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70192. * * 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
  70193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70194. * @param name defines the name of the mesh
  70195. * @param options defines the options used to create the mesh
  70196. * @param scene defines the hosting scene
  70197. * @returns the icosahedron mesh
  70198. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70199. */
  70200. static CreateIcoSphere(name: string, options: {
  70201. radius?: number;
  70202. radiusX?: number;
  70203. radiusY?: number;
  70204. radiusZ?: number;
  70205. flat?: boolean;
  70206. subdivisions?: number;
  70207. sideOrientation?: number;
  70208. frontUVs?: Vector4;
  70209. backUVs?: Vector4;
  70210. updatable?: boolean;
  70211. }, scene?: Nullable<Scene>): Mesh;
  70212. /**
  70213. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70214. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70215. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70216. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70217. * * 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
  70218. * * 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
  70219. * * 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
  70220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70221. * * 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
  70222. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70223. * * 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
  70224. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70225. * * 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
  70226. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70228. * @param name defines the name of the mesh
  70229. * @param options defines the options used to create the mesh
  70230. * @param scene defines the hosting scene
  70231. * @returns the ribbon mesh
  70232. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70233. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70234. */
  70235. static CreateRibbon(name: string, options: {
  70236. pathArray: Vector3[][];
  70237. closeArray?: boolean;
  70238. closePath?: boolean;
  70239. offset?: number;
  70240. updatable?: boolean;
  70241. sideOrientation?: number;
  70242. frontUVs?: Vector4;
  70243. backUVs?: Vector4;
  70244. instance?: Mesh;
  70245. invertUV?: boolean;
  70246. uvs?: Vector2[];
  70247. colors?: Color4[];
  70248. }, scene?: Nullable<Scene>): Mesh;
  70249. /**
  70250. * Creates a cylinder or a cone mesh
  70251. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70252. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70253. * * 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.
  70254. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70255. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70256. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70257. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70258. * * 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).
  70259. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70260. * * 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).
  70261. * * 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
  70262. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70263. * * 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
  70264. * * 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.
  70265. * * If `enclose` is false, a ring surface is one element.
  70266. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70267. * * 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
  70268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70269. * * 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
  70270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70271. * @param name defines the name of the mesh
  70272. * @param options defines the options used to create the mesh
  70273. * @param scene defines the hosting scene
  70274. * @returns the cylinder mesh
  70275. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70276. */
  70277. static CreateCylinder(name: string, options: {
  70278. height?: number;
  70279. diameterTop?: number;
  70280. diameterBottom?: number;
  70281. diameter?: number;
  70282. tessellation?: number;
  70283. subdivisions?: number;
  70284. arc?: number;
  70285. faceColors?: Color4[];
  70286. faceUV?: Vector4[];
  70287. updatable?: boolean;
  70288. hasRings?: boolean;
  70289. enclose?: boolean;
  70290. cap?: number;
  70291. sideOrientation?: number;
  70292. frontUVs?: Vector4;
  70293. backUVs?: Vector4;
  70294. }, scene?: Nullable<Scene>): Mesh;
  70295. /**
  70296. * Creates a torus mesh
  70297. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70298. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70299. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70301. * * 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
  70302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70303. * @param name defines the name of the mesh
  70304. * @param options defines the options used to create the mesh
  70305. * @param scene defines the hosting scene
  70306. * @returns the torus mesh
  70307. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70308. */
  70309. static CreateTorus(name: string, options: {
  70310. diameter?: number;
  70311. thickness?: number;
  70312. tessellation?: number;
  70313. updatable?: boolean;
  70314. sideOrientation?: number;
  70315. frontUVs?: Vector4;
  70316. backUVs?: Vector4;
  70317. }, scene?: Nullable<Scene>): Mesh;
  70318. /**
  70319. * Creates a torus knot mesh
  70320. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70321. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70322. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70323. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70325. * * 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
  70326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70327. * @param name defines the name of the mesh
  70328. * @param options defines the options used to create the mesh
  70329. * @param scene defines the hosting scene
  70330. * @returns the torus knot mesh
  70331. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70332. */
  70333. static CreateTorusKnot(name: string, options: {
  70334. radius?: number;
  70335. tube?: number;
  70336. radialSegments?: number;
  70337. tubularSegments?: number;
  70338. p?: number;
  70339. q?: number;
  70340. updatable?: boolean;
  70341. sideOrientation?: number;
  70342. frontUVs?: Vector4;
  70343. backUVs?: Vector4;
  70344. }, scene?: Nullable<Scene>): Mesh;
  70345. /**
  70346. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70347. * * 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
  70348. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70349. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70350. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70351. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70352. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70353. * * 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
  70354. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70356. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70357. * @param name defines the name of the new line system
  70358. * @param options defines the options used to create the line system
  70359. * @param scene defines the hosting scene
  70360. * @returns a new line system mesh
  70361. */
  70362. static CreateLineSystem(name: string, options: {
  70363. lines: Vector3[][];
  70364. updatable?: boolean;
  70365. instance?: Nullable<LinesMesh>;
  70366. colors?: Nullable<Color4[][]>;
  70367. useVertexAlpha?: boolean;
  70368. }, scene: Nullable<Scene>): LinesMesh;
  70369. /**
  70370. * Creates a line mesh
  70371. * 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
  70372. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70373. * * The parameter `points` is an array successive Vector3
  70374. * * 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
  70375. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70376. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70377. * * When updating an instance, remember that only point positions can change, not the number of points
  70378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70380. * @param name defines the name of the new line system
  70381. * @param options defines the options used to create the line system
  70382. * @param scene defines the hosting scene
  70383. * @returns a new line mesh
  70384. */
  70385. static CreateLines(name: string, options: {
  70386. points: Vector3[];
  70387. updatable?: boolean;
  70388. instance?: Nullable<LinesMesh>;
  70389. colors?: Color4[];
  70390. useVertexAlpha?: boolean;
  70391. }, scene?: Nullable<Scene>): LinesMesh;
  70392. /**
  70393. * Creates a dashed line mesh
  70394. * * 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
  70395. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70396. * * The parameter `points` is an array successive Vector3
  70397. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70398. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70399. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70400. * * 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
  70401. * * When updating an instance, remember that only point positions can change, not the number of points
  70402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70403. * @param name defines the name of the mesh
  70404. * @param options defines the options used to create the mesh
  70405. * @param scene defines the hosting scene
  70406. * @returns the dashed line mesh
  70407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70408. */
  70409. static CreateDashedLines(name: string, options: {
  70410. points: Vector3[];
  70411. dashSize?: number;
  70412. gapSize?: number;
  70413. dashNb?: number;
  70414. updatable?: boolean;
  70415. instance?: LinesMesh;
  70416. }, scene?: Nullable<Scene>): LinesMesh;
  70417. /**
  70418. * 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.
  70419. * * 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.
  70420. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70421. * * 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.
  70422. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70423. * * 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
  70424. * * 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
  70425. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70427. * * 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
  70428. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70430. * @param name defines the name of the mesh
  70431. * @param options defines the options used to create the mesh
  70432. * @param scene defines the hosting scene
  70433. * @returns the extruded shape mesh
  70434. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70436. */
  70437. static ExtrudeShape(name: string, options: {
  70438. shape: Vector3[];
  70439. path: Vector3[];
  70440. scale?: number;
  70441. rotation?: number;
  70442. cap?: number;
  70443. updatable?: boolean;
  70444. sideOrientation?: number;
  70445. frontUVs?: Vector4;
  70446. backUVs?: Vector4;
  70447. instance?: Mesh;
  70448. invertUV?: boolean;
  70449. }, scene?: Nullable<Scene>): Mesh;
  70450. /**
  70451. * Creates an custom extruded shape mesh.
  70452. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70453. * * 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.
  70454. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70455. * * 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
  70456. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70457. * * 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
  70458. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70459. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70460. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70461. * * 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
  70462. * * 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
  70463. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70465. * * 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
  70466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70468. * @param name defines the name of the mesh
  70469. * @param options defines the options used to create the mesh
  70470. * @param scene defines the hosting scene
  70471. * @returns the custom extruded shape mesh
  70472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70473. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70475. */
  70476. static ExtrudeShapeCustom(name: string, options: {
  70477. shape: Vector3[];
  70478. path: Vector3[];
  70479. scaleFunction?: any;
  70480. rotationFunction?: any;
  70481. ribbonCloseArray?: boolean;
  70482. ribbonClosePath?: boolean;
  70483. cap?: number;
  70484. updatable?: boolean;
  70485. sideOrientation?: number;
  70486. frontUVs?: Vector4;
  70487. backUVs?: Vector4;
  70488. instance?: Mesh;
  70489. invertUV?: boolean;
  70490. }, scene?: Nullable<Scene>): Mesh;
  70491. /**
  70492. * Creates lathe mesh.
  70493. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70494. * * 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
  70495. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70496. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70497. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70498. * * 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
  70499. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70500. * * 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
  70501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70502. * * 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
  70503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70505. * @param name defines the name of the mesh
  70506. * @param options defines the options used to create the mesh
  70507. * @param scene defines the hosting scene
  70508. * @returns the lathe mesh
  70509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70510. */
  70511. static CreateLathe(name: string, options: {
  70512. shape: Vector3[];
  70513. radius?: number;
  70514. tessellation?: number;
  70515. clip?: number;
  70516. arc?: number;
  70517. closed?: boolean;
  70518. updatable?: boolean;
  70519. sideOrientation?: number;
  70520. frontUVs?: Vector4;
  70521. backUVs?: Vector4;
  70522. cap?: number;
  70523. invertUV?: boolean;
  70524. }, scene?: Nullable<Scene>): Mesh;
  70525. /**
  70526. * Creates a tiled plane mesh
  70527. * * You can set a limited pattern arrangement with the tiles
  70528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70529. * * 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
  70530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70531. * @param name defines the name of the mesh
  70532. * @param options defines the options used to create the mesh
  70533. * @param scene defines the hosting scene
  70534. * @returns the plane mesh
  70535. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70536. */
  70537. static CreateTiledPlane(name: string, options: {
  70538. pattern?: number;
  70539. tileSize?: number;
  70540. tileWidth?: number;
  70541. tileHeight?: number;
  70542. size?: number;
  70543. width?: number;
  70544. height?: number;
  70545. alignHorizontal?: number;
  70546. alignVertical?: number;
  70547. sideOrientation?: number;
  70548. frontUVs?: Vector4;
  70549. backUVs?: Vector4;
  70550. updatable?: boolean;
  70551. }, scene?: Nullable<Scene>): Mesh;
  70552. /**
  70553. * Creates a plane mesh
  70554. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70555. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70556. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70558. * * 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
  70559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70560. * @param name defines the name of the mesh
  70561. * @param options defines the options used to create the mesh
  70562. * @param scene defines the hosting scene
  70563. * @returns the plane mesh
  70564. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70565. */
  70566. static CreatePlane(name: string, options: {
  70567. size?: number;
  70568. width?: number;
  70569. height?: number;
  70570. sideOrientation?: number;
  70571. frontUVs?: Vector4;
  70572. backUVs?: Vector4;
  70573. updatable?: boolean;
  70574. sourcePlane?: Plane;
  70575. }, scene?: Nullable<Scene>): Mesh;
  70576. /**
  70577. * Creates a ground mesh
  70578. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70579. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70581. * @param name defines the name of the mesh
  70582. * @param options defines the options used to create the mesh
  70583. * @param scene defines the hosting scene
  70584. * @returns the ground mesh
  70585. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70586. */
  70587. static CreateGround(name: string, options: {
  70588. width?: number;
  70589. height?: number;
  70590. subdivisions?: number;
  70591. subdivisionsX?: number;
  70592. subdivisionsY?: number;
  70593. updatable?: boolean;
  70594. }, scene?: Nullable<Scene>): Mesh;
  70595. /**
  70596. * Creates a tiled ground mesh
  70597. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70598. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70599. * * 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
  70600. * * 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
  70601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70602. * @param name defines the name of the mesh
  70603. * @param options defines the options used to create the mesh
  70604. * @param scene defines the hosting scene
  70605. * @returns the tiled ground mesh
  70606. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70607. */
  70608. static CreateTiledGround(name: string, options: {
  70609. xmin: number;
  70610. zmin: number;
  70611. xmax: number;
  70612. zmax: number;
  70613. subdivisions?: {
  70614. w: number;
  70615. h: number;
  70616. };
  70617. precision?: {
  70618. w: number;
  70619. h: number;
  70620. };
  70621. updatable?: boolean;
  70622. }, scene?: Nullable<Scene>): Mesh;
  70623. /**
  70624. * Creates a ground mesh from a height map
  70625. * * The parameter `url` sets the URL of the height map image resource.
  70626. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70627. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70628. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70629. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70630. * * 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.
  70631. * * 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).
  70632. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70634. * @param name defines the name of the mesh
  70635. * @param url defines the url to the height map
  70636. * @param options defines the options used to create the mesh
  70637. * @param scene defines the hosting scene
  70638. * @returns the ground mesh
  70639. * @see https://doc.babylonjs.com/babylon101/height_map
  70640. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70641. */
  70642. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70643. width?: number;
  70644. height?: number;
  70645. subdivisions?: number;
  70646. minHeight?: number;
  70647. maxHeight?: number;
  70648. colorFilter?: Color3;
  70649. alphaFilter?: number;
  70650. updatable?: boolean;
  70651. onReady?: (mesh: GroundMesh) => void;
  70652. }, scene?: Nullable<Scene>): GroundMesh;
  70653. /**
  70654. * Creates a polygon mesh
  70655. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70656. * * 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
  70657. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70659. * * 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)
  70660. * * Remember you can only change the shape positions, not their number when updating a polygon
  70661. * @param name defines the name of the mesh
  70662. * @param options defines the options used to create the mesh
  70663. * @param scene defines the hosting scene
  70664. * @param earcutInjection can be used to inject your own earcut reference
  70665. * @returns the polygon mesh
  70666. */
  70667. static CreatePolygon(name: string, options: {
  70668. shape: Vector3[];
  70669. holes?: Vector3[][];
  70670. depth?: number;
  70671. faceUV?: Vector4[];
  70672. faceColors?: Color4[];
  70673. updatable?: boolean;
  70674. sideOrientation?: number;
  70675. frontUVs?: Vector4;
  70676. backUVs?: Vector4;
  70677. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70678. /**
  70679. * Creates an extruded polygon mesh, with depth in the Y direction.
  70680. * * 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)
  70681. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70682. * @param name defines the name of the mesh
  70683. * @param options defines the options used to create the mesh
  70684. * @param scene defines the hosting scene
  70685. * @param earcutInjection can be used to inject your own earcut reference
  70686. * @returns the polygon mesh
  70687. */
  70688. static ExtrudePolygon(name: string, options: {
  70689. shape: Vector3[];
  70690. holes?: Vector3[][];
  70691. depth?: number;
  70692. faceUV?: Vector4[];
  70693. faceColors?: Color4[];
  70694. updatable?: boolean;
  70695. sideOrientation?: number;
  70696. frontUVs?: Vector4;
  70697. backUVs?: Vector4;
  70698. wrap?: boolean;
  70699. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70700. /**
  70701. * Creates a tube mesh.
  70702. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70703. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70704. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70705. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70706. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70707. * * 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)
  70708. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70709. * * 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
  70710. * * 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
  70711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70712. * * 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
  70713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70715. * @param name defines the name of the mesh
  70716. * @param options defines the options used to create the mesh
  70717. * @param scene defines the hosting scene
  70718. * @returns the tube mesh
  70719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70720. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70721. */
  70722. static CreateTube(name: string, options: {
  70723. path: Vector3[];
  70724. radius?: number;
  70725. tessellation?: number;
  70726. radiusFunction?: {
  70727. (i: number, distance: number): number;
  70728. };
  70729. cap?: number;
  70730. arc?: number;
  70731. updatable?: boolean;
  70732. sideOrientation?: number;
  70733. frontUVs?: Vector4;
  70734. backUVs?: Vector4;
  70735. instance?: Mesh;
  70736. invertUV?: boolean;
  70737. }, scene?: Nullable<Scene>): Mesh;
  70738. /**
  70739. * Creates a polyhedron mesh
  70740. * * 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
  70741. * * The parameter `size` (positive float, default 1) sets the polygon size
  70742. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70743. * * 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`
  70744. * * 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
  70745. * * 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)`)
  70746. * * 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
  70747. * * 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
  70748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70749. * * 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
  70750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70751. * @param name defines the name of the mesh
  70752. * @param options defines the options used to create the mesh
  70753. * @param scene defines the hosting scene
  70754. * @returns the polyhedron mesh
  70755. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70756. */
  70757. static CreatePolyhedron(name: string, options: {
  70758. type?: number;
  70759. size?: number;
  70760. sizeX?: number;
  70761. sizeY?: number;
  70762. sizeZ?: number;
  70763. custom?: any;
  70764. faceUV?: Vector4[];
  70765. faceColors?: Color4[];
  70766. flat?: boolean;
  70767. updatable?: boolean;
  70768. sideOrientation?: number;
  70769. frontUVs?: Vector4;
  70770. backUVs?: Vector4;
  70771. }, scene?: Nullable<Scene>): Mesh;
  70772. /**
  70773. * Creates a decal mesh.
  70774. * 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
  70775. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70776. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70777. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70778. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70779. * @param name defines the name of the mesh
  70780. * @param sourceMesh defines the mesh where the decal must be applied
  70781. * @param options defines the options used to create the mesh
  70782. * @param scene defines the hosting scene
  70783. * @returns the decal mesh
  70784. * @see https://doc.babylonjs.com/how_to/decals
  70785. */
  70786. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70787. position?: Vector3;
  70788. normal?: Vector3;
  70789. size?: Vector3;
  70790. angle?: number;
  70791. }): Mesh;
  70792. /**
  70793. * Creates a Capsule Mesh
  70794. * @param name defines the name of the mesh.
  70795. * @param options the constructors options used to shape the mesh.
  70796. * @param scene defines the scene the mesh is scoped to.
  70797. * @returns the capsule mesh
  70798. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70799. */
  70800. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70801. }
  70802. }
  70803. declare module BABYLON {
  70804. /**
  70805. * A simplifier interface for future simplification implementations
  70806. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70807. */
  70808. export interface ISimplifier {
  70809. /**
  70810. * Simplification of a given mesh according to the given settings.
  70811. * Since this requires computation, it is assumed that the function runs async.
  70812. * @param settings The settings of the simplification, including quality and distance
  70813. * @param successCallback A callback that will be called after the mesh was simplified.
  70814. * @param errorCallback in case of an error, this callback will be called. optional.
  70815. */
  70816. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70817. }
  70818. /**
  70819. * Expected simplification settings.
  70820. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70821. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70822. */
  70823. export interface ISimplificationSettings {
  70824. /**
  70825. * Gets or sets the expected quality
  70826. */
  70827. quality: number;
  70828. /**
  70829. * Gets or sets the distance when this optimized version should be used
  70830. */
  70831. distance: number;
  70832. /**
  70833. * Gets an already optimized mesh
  70834. */
  70835. optimizeMesh?: boolean;
  70836. }
  70837. /**
  70838. * Class used to specify simplification options
  70839. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70840. */
  70841. export class SimplificationSettings implements ISimplificationSettings {
  70842. /** expected quality */
  70843. quality: number;
  70844. /** distance when this optimized version should be used */
  70845. distance: number;
  70846. /** already optimized mesh */
  70847. optimizeMesh?: boolean | undefined;
  70848. /**
  70849. * Creates a SimplificationSettings
  70850. * @param quality expected quality
  70851. * @param distance distance when this optimized version should be used
  70852. * @param optimizeMesh already optimized mesh
  70853. */
  70854. constructor(
  70855. /** expected quality */
  70856. quality: number,
  70857. /** distance when this optimized version should be used */
  70858. distance: number,
  70859. /** already optimized mesh */
  70860. optimizeMesh?: boolean | undefined);
  70861. }
  70862. /**
  70863. * Interface used to define a simplification task
  70864. */
  70865. export interface ISimplificationTask {
  70866. /**
  70867. * Array of settings
  70868. */
  70869. settings: Array<ISimplificationSettings>;
  70870. /**
  70871. * Simplification type
  70872. */
  70873. simplificationType: SimplificationType;
  70874. /**
  70875. * Mesh to simplify
  70876. */
  70877. mesh: Mesh;
  70878. /**
  70879. * Callback called on success
  70880. */
  70881. successCallback?: () => void;
  70882. /**
  70883. * Defines if parallel processing can be used
  70884. */
  70885. parallelProcessing: boolean;
  70886. }
  70887. /**
  70888. * Queue used to order the simplification tasks
  70889. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70890. */
  70891. export class SimplificationQueue {
  70892. private _simplificationArray;
  70893. /**
  70894. * Gets a boolean indicating that the process is still running
  70895. */
  70896. running: boolean;
  70897. /**
  70898. * Creates a new queue
  70899. */
  70900. constructor();
  70901. /**
  70902. * Adds a new simplification task
  70903. * @param task defines a task to add
  70904. */
  70905. addTask(task: ISimplificationTask): void;
  70906. /**
  70907. * Execute next task
  70908. */
  70909. executeNext(): void;
  70910. /**
  70911. * Execute a simplification task
  70912. * @param task defines the task to run
  70913. */
  70914. runSimplification(task: ISimplificationTask): void;
  70915. private getSimplifier;
  70916. }
  70917. /**
  70918. * The implemented types of simplification
  70919. * At the moment only Quadratic Error Decimation is implemented
  70920. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70921. */
  70922. export enum SimplificationType {
  70923. /** Quadratic error decimation */
  70924. QUADRATIC = 0
  70925. }
  70926. /**
  70927. * An implementation of the Quadratic Error simplification algorithm.
  70928. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70929. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70930. * @author RaananW
  70931. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70932. */
  70933. export class QuadraticErrorSimplification implements ISimplifier {
  70934. private _mesh;
  70935. private triangles;
  70936. private vertices;
  70937. private references;
  70938. private _reconstructedMesh;
  70939. /** Gets or sets the number pf sync interations */
  70940. syncIterations: number;
  70941. /** Gets or sets the aggressiveness of the simplifier */
  70942. aggressiveness: number;
  70943. /** Gets or sets the number of allowed iterations for decimation */
  70944. decimationIterations: number;
  70945. /** Gets or sets the espilon to use for bounding box computation */
  70946. boundingBoxEpsilon: number;
  70947. /**
  70948. * Creates a new QuadraticErrorSimplification
  70949. * @param _mesh defines the target mesh
  70950. */
  70951. constructor(_mesh: Mesh);
  70952. /**
  70953. * Simplification of a given mesh according to the given settings.
  70954. * Since this requires computation, it is assumed that the function runs async.
  70955. * @param settings The settings of the simplification, including quality and distance
  70956. * @param successCallback A callback that will be called after the mesh was simplified.
  70957. */
  70958. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70959. private runDecimation;
  70960. private initWithMesh;
  70961. private init;
  70962. private reconstructMesh;
  70963. private initDecimatedMesh;
  70964. private isFlipped;
  70965. private updateTriangles;
  70966. private identifyBorder;
  70967. private updateMesh;
  70968. private vertexError;
  70969. private calculateError;
  70970. }
  70971. }
  70972. declare module BABYLON {
  70973. interface Scene {
  70974. /** @hidden (Backing field) */
  70975. _simplificationQueue: SimplificationQueue;
  70976. /**
  70977. * Gets or sets the simplification queue attached to the scene
  70978. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70979. */
  70980. simplificationQueue: SimplificationQueue;
  70981. }
  70982. interface Mesh {
  70983. /**
  70984. * Simplify the mesh according to the given array of settings.
  70985. * Function will return immediately and will simplify async
  70986. * @param settings a collection of simplification settings
  70987. * @param parallelProcessing should all levels calculate parallel or one after the other
  70988. * @param simplificationType the type of simplification to run
  70989. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70990. * @returns the current mesh
  70991. */
  70992. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70993. }
  70994. /**
  70995. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70996. * created in a scene
  70997. */
  70998. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70999. /**
  71000. * The component name helpfull to identify the component in the list of scene components.
  71001. */
  71002. readonly name: string;
  71003. /**
  71004. * The scene the component belongs to.
  71005. */
  71006. scene: Scene;
  71007. /**
  71008. * Creates a new instance of the component for the given scene
  71009. * @param scene Defines the scene to register the component in
  71010. */
  71011. constructor(scene: Scene);
  71012. /**
  71013. * Registers the component in a given scene
  71014. */
  71015. register(): void;
  71016. /**
  71017. * Rebuilds the elements related to this component in case of
  71018. * context lost for instance.
  71019. */
  71020. rebuild(): void;
  71021. /**
  71022. * Disposes the component and the associated ressources
  71023. */
  71024. dispose(): void;
  71025. private _beforeCameraUpdate;
  71026. }
  71027. }
  71028. declare module BABYLON {
  71029. interface Mesh {
  71030. /**
  71031. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71032. */
  71033. thinInstanceEnablePicking: boolean;
  71034. /**
  71035. * Creates a new thin instance
  71036. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71037. * @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
  71038. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71039. */
  71040. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71041. /**
  71042. * Adds the transformation (matrix) of the current mesh as a thin instance
  71043. * @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
  71044. * @returns the thin instance index number
  71045. */
  71046. thinInstanceAddSelf(refresh: boolean): number;
  71047. /**
  71048. * Registers a custom attribute to be used with thin instances
  71049. * @param kind name of the attribute
  71050. * @param stride size in floats of the attribute
  71051. */
  71052. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71053. /**
  71054. * Sets the matrix of a thin instance
  71055. * @param index index of the thin instance
  71056. * @param matrix matrix to set
  71057. * @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
  71058. */
  71059. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71060. /**
  71061. * Sets the value of a custom attribute for a thin instance
  71062. * @param kind name of the attribute
  71063. * @param index index of the thin instance
  71064. * @param value value to set
  71065. * @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
  71066. */
  71067. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71068. /**
  71069. * 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.
  71070. */
  71071. thinInstanceCount: number;
  71072. /**
  71073. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71074. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71075. * @param buffer buffer to set
  71076. * @param stride size in floats of each value of the buffer
  71077. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71078. */
  71079. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71080. /**
  71081. * Gets the list of world matrices
  71082. * @return an array containing all the world matrices from the thin instances
  71083. */
  71084. thinInstanceGetWorldMatrices(): Matrix[];
  71085. /**
  71086. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71087. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71088. */
  71089. thinInstanceBufferUpdated(kind: string): void;
  71090. /**
  71091. * Applies a partial update to a buffer directly on the GPU
  71092. * 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
  71093. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71094. * @param data the data to set in the GPU buffer
  71095. * @param offset the offset in the GPU buffer where to update the data
  71096. */
  71097. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71098. /**
  71099. * Refreshes the bounding info, taking into account all the thin instances defined
  71100. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71101. */
  71102. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71103. /** @hidden */
  71104. _thinInstanceInitializeUserStorage(): void;
  71105. /** @hidden */
  71106. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71107. /** @hidden */
  71108. _userThinInstanceBuffersStorage: {
  71109. data: {
  71110. [key: string]: Float32Array;
  71111. };
  71112. sizes: {
  71113. [key: string]: number;
  71114. };
  71115. vertexBuffers: {
  71116. [key: string]: Nullable<VertexBuffer>;
  71117. };
  71118. strides: {
  71119. [key: string]: number;
  71120. };
  71121. };
  71122. }
  71123. }
  71124. declare module BABYLON {
  71125. /**
  71126. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71127. */
  71128. export interface INavigationEnginePlugin {
  71129. /**
  71130. * plugin name
  71131. */
  71132. name: string;
  71133. /**
  71134. * Creates a navigation mesh
  71135. * @param meshes array of all the geometry used to compute the navigatio mesh
  71136. * @param parameters bunch of parameters used to filter geometry
  71137. */
  71138. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71139. /**
  71140. * Create a navigation mesh debug mesh
  71141. * @param scene is where the mesh will be added
  71142. * @returns debug display mesh
  71143. */
  71144. createDebugNavMesh(scene: Scene): Mesh;
  71145. /**
  71146. * Get a navigation mesh constrained position, closest to the parameter position
  71147. * @param position world position
  71148. * @returns the closest point to position constrained by the navigation mesh
  71149. */
  71150. getClosestPoint(position: Vector3): Vector3;
  71151. /**
  71152. * Get a navigation mesh constrained position, closest to the parameter position
  71153. * @param position world position
  71154. * @param result output the closest point to position constrained by the navigation mesh
  71155. */
  71156. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71157. /**
  71158. * Get a navigation mesh constrained position, within a particular radius
  71159. * @param position world position
  71160. * @param maxRadius the maximum distance to the constrained world position
  71161. * @returns the closest point to position constrained by the navigation mesh
  71162. */
  71163. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71164. /**
  71165. * Get a navigation mesh constrained position, within a particular radius
  71166. * @param position world position
  71167. * @param maxRadius the maximum distance to the constrained world position
  71168. * @param result output the closest point to position constrained by the navigation mesh
  71169. */
  71170. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71171. /**
  71172. * Compute the final position from a segment made of destination-position
  71173. * @param position world position
  71174. * @param destination world position
  71175. * @returns the resulting point along the navmesh
  71176. */
  71177. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71178. /**
  71179. * Compute the final position from a segment made of destination-position
  71180. * @param position world position
  71181. * @param destination world position
  71182. * @param result output the resulting point along the navmesh
  71183. */
  71184. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71185. /**
  71186. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71187. * @param start world position
  71188. * @param end world position
  71189. * @returns array containing world position composing the path
  71190. */
  71191. computePath(start: Vector3, end: Vector3): Vector3[];
  71192. /**
  71193. * If this plugin is supported
  71194. * @returns true if plugin is supported
  71195. */
  71196. isSupported(): boolean;
  71197. /**
  71198. * Create a new Crowd so you can add agents
  71199. * @param maxAgents the maximum agent count in the crowd
  71200. * @param maxAgentRadius the maximum radius an agent can have
  71201. * @param scene to attach the crowd to
  71202. * @returns the crowd you can add agents to
  71203. */
  71204. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71205. /**
  71206. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71207. * The queries will try to find a solution within those bounds
  71208. * default is (1,1,1)
  71209. * @param extent x,y,z value that define the extent around the queries point of reference
  71210. */
  71211. setDefaultQueryExtent(extent: Vector3): void;
  71212. /**
  71213. * Get the Bounding box extent specified by setDefaultQueryExtent
  71214. * @returns the box extent values
  71215. */
  71216. getDefaultQueryExtent(): Vector3;
  71217. /**
  71218. * build the navmesh from a previously saved state using getNavmeshData
  71219. * @param data the Uint8Array returned by getNavmeshData
  71220. */
  71221. buildFromNavmeshData(data: Uint8Array): void;
  71222. /**
  71223. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71224. * @returns data the Uint8Array that can be saved and reused
  71225. */
  71226. getNavmeshData(): Uint8Array;
  71227. /**
  71228. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71229. * @param result output the box extent values
  71230. */
  71231. getDefaultQueryExtentToRef(result: Vector3): void;
  71232. /**
  71233. * Set the time step of the navigation tick update.
  71234. * Default is 1/60.
  71235. * A value of 0 will disable fixed time update
  71236. * @param newTimeStep the new timestep to apply to this world.
  71237. */
  71238. setTimeStep(newTimeStep: number): void;
  71239. /**
  71240. * Get the time step of the navigation tick update.
  71241. * @returns the current time step
  71242. */
  71243. getTimeStep(): number;
  71244. /**
  71245. * If delta time in navigation tick update is greater than the time step
  71246. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71247. * they will be discarded.
  71248. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71249. * @param newStepCount the maximum number of iterations
  71250. */
  71251. setMaximumSubStepCount(newStepCount: number): void;
  71252. /**
  71253. * Get the maximum number of iterations per navigation tick update
  71254. * @returns the maximum number of iterations
  71255. */
  71256. getMaximumSubStepCount(): number;
  71257. /**
  71258. * Release all resources
  71259. */
  71260. dispose(): void;
  71261. }
  71262. /**
  71263. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71264. */
  71265. export interface ICrowd {
  71266. /**
  71267. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71268. * You can attach anything to that node. The node position is updated in the scene update tick.
  71269. * @param pos world position that will be constrained by the navigation mesh
  71270. * @param parameters agent parameters
  71271. * @param transform hooked to the agent that will be update by the scene
  71272. * @returns agent index
  71273. */
  71274. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71275. /**
  71276. * Returns the agent position in world space
  71277. * @param index agent index returned by addAgent
  71278. * @returns world space position
  71279. */
  71280. getAgentPosition(index: number): Vector3;
  71281. /**
  71282. * Gets the agent position result in world space
  71283. * @param index agent index returned by addAgent
  71284. * @param result output world space position
  71285. */
  71286. getAgentPositionToRef(index: number, result: Vector3): void;
  71287. /**
  71288. * Gets the agent velocity in world space
  71289. * @param index agent index returned by addAgent
  71290. * @returns world space velocity
  71291. */
  71292. getAgentVelocity(index: number): Vector3;
  71293. /**
  71294. * Gets the agent velocity result in world space
  71295. * @param index agent index returned by addAgent
  71296. * @param result output world space velocity
  71297. */
  71298. getAgentVelocityToRef(index: number, result: Vector3): void;
  71299. /**
  71300. * Gets the agent next target point on the path
  71301. * @param index agent index returned by addAgent
  71302. * @returns world space position
  71303. */
  71304. getAgentNextTargetPath(index: number): Vector3;
  71305. /**
  71306. * Gets the agent state
  71307. * @param index agent index returned by addAgent
  71308. * @returns agent state
  71309. */
  71310. getAgentState(index: number): number;
  71311. /**
  71312. * returns true if the agent in over an off mesh link connection
  71313. * @param index agent index returned by addAgent
  71314. * @returns true if over an off mesh link connection
  71315. */
  71316. overOffmeshConnection(index: number): boolean;
  71317. /**
  71318. * Gets the agent next target point on the path
  71319. * @param index agent index returned by addAgent
  71320. * @param result output world space position
  71321. */
  71322. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71323. /**
  71324. * remove a particular agent previously created
  71325. * @param index agent index returned by addAgent
  71326. */
  71327. removeAgent(index: number): void;
  71328. /**
  71329. * get the list of all agents attached to this crowd
  71330. * @returns list of agent indices
  71331. */
  71332. getAgents(): number[];
  71333. /**
  71334. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71335. * @param deltaTime in seconds
  71336. */
  71337. update(deltaTime: number): void;
  71338. /**
  71339. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71340. * @param index agent index returned by addAgent
  71341. * @param destination targeted world position
  71342. */
  71343. agentGoto(index: number, destination: Vector3): void;
  71344. /**
  71345. * Teleport the agent to a new position
  71346. * @param index agent index returned by addAgent
  71347. * @param destination targeted world position
  71348. */
  71349. agentTeleport(index: number, destination: Vector3): void;
  71350. /**
  71351. * Update agent parameters
  71352. * @param index agent index returned by addAgent
  71353. * @param parameters agent parameters
  71354. */
  71355. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71356. /**
  71357. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71358. * The queries will try to find a solution within those bounds
  71359. * default is (1,1,1)
  71360. * @param extent x,y,z value that define the extent around the queries point of reference
  71361. */
  71362. setDefaultQueryExtent(extent: Vector3): void;
  71363. /**
  71364. * Get the Bounding box extent specified by setDefaultQueryExtent
  71365. * @returns the box extent values
  71366. */
  71367. getDefaultQueryExtent(): Vector3;
  71368. /**
  71369. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71370. * @param result output the box extent values
  71371. */
  71372. getDefaultQueryExtentToRef(result: Vector3): void;
  71373. /**
  71374. * Release all resources
  71375. */
  71376. dispose(): void;
  71377. }
  71378. /**
  71379. * Configures an agent
  71380. */
  71381. export interface IAgentParameters {
  71382. /**
  71383. * Agent radius. [Limit: >= 0]
  71384. */
  71385. radius: number;
  71386. /**
  71387. * Agent height. [Limit: > 0]
  71388. */
  71389. height: number;
  71390. /**
  71391. * Maximum allowed acceleration. [Limit: >= 0]
  71392. */
  71393. maxAcceleration: number;
  71394. /**
  71395. * Maximum allowed speed. [Limit: >= 0]
  71396. */
  71397. maxSpeed: number;
  71398. /**
  71399. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71400. */
  71401. collisionQueryRange: number;
  71402. /**
  71403. * The path visibility optimization range. [Limit: > 0]
  71404. */
  71405. pathOptimizationRange: number;
  71406. /**
  71407. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71408. */
  71409. separationWeight: number;
  71410. }
  71411. /**
  71412. * Configures the navigation mesh creation
  71413. */
  71414. export interface INavMeshParameters {
  71415. /**
  71416. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71417. */
  71418. cs: number;
  71419. /**
  71420. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71421. */
  71422. ch: number;
  71423. /**
  71424. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71425. */
  71426. walkableSlopeAngle: number;
  71427. /**
  71428. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71429. * be considered walkable. [Limit: >= 3] [Units: vx]
  71430. */
  71431. walkableHeight: number;
  71432. /**
  71433. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71434. */
  71435. walkableClimb: number;
  71436. /**
  71437. * The distance to erode/shrink the walkable area of the heightfield away from
  71438. * obstructions. [Limit: >=0] [Units: vx]
  71439. */
  71440. walkableRadius: number;
  71441. /**
  71442. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71443. */
  71444. maxEdgeLen: number;
  71445. /**
  71446. * The maximum distance a simplfied contour's border edges should deviate
  71447. * the original raw contour. [Limit: >=0] [Units: vx]
  71448. */
  71449. maxSimplificationError: number;
  71450. /**
  71451. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71452. */
  71453. minRegionArea: number;
  71454. /**
  71455. * Any regions with a span count smaller than this value will, if possible,
  71456. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71457. */
  71458. mergeRegionArea: number;
  71459. /**
  71460. * The maximum number of vertices allowed for polygons generated during the
  71461. * contour to polygon conversion process. [Limit: >= 3]
  71462. */
  71463. maxVertsPerPoly: number;
  71464. /**
  71465. * Sets the sampling distance to use when generating the detail mesh.
  71466. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71467. */
  71468. detailSampleDist: number;
  71469. /**
  71470. * The maximum distance the detail mesh surface should deviate from heightfield
  71471. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71472. */
  71473. detailSampleMaxError: number;
  71474. }
  71475. }
  71476. declare module BABYLON {
  71477. /**
  71478. * RecastJS navigation plugin
  71479. */
  71480. export class RecastJSPlugin implements INavigationEnginePlugin {
  71481. /**
  71482. * Reference to the Recast library
  71483. */
  71484. bjsRECAST: any;
  71485. /**
  71486. * plugin name
  71487. */
  71488. name: string;
  71489. /**
  71490. * the first navmesh created. We might extend this to support multiple navmeshes
  71491. */
  71492. navMesh: any;
  71493. private _maximumSubStepCount;
  71494. private _timeStep;
  71495. /**
  71496. * Initializes the recastJS plugin
  71497. * @param recastInjection can be used to inject your own recast reference
  71498. */
  71499. constructor(recastInjection?: any);
  71500. /**
  71501. * Set the time step of the navigation tick update.
  71502. * Default is 1/60.
  71503. * A value of 0 will disable fixed time update
  71504. * @param newTimeStep the new timestep to apply to this world.
  71505. */
  71506. setTimeStep(newTimeStep?: number): void;
  71507. /**
  71508. * Get the time step of the navigation tick update.
  71509. * @returns the current time step
  71510. */
  71511. getTimeStep(): number;
  71512. /**
  71513. * If delta time in navigation tick update is greater than the time step
  71514. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71515. * they will be discarded.
  71516. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71517. * @param newStepCount the maximum number of iterations
  71518. */
  71519. setMaximumSubStepCount(newStepCount?: number): void;
  71520. /**
  71521. * Get the maximum number of iterations per navigation tick update
  71522. * @returns the maximum number of iterations
  71523. */
  71524. getMaximumSubStepCount(): number;
  71525. /**
  71526. * Creates a navigation mesh
  71527. * @param meshes array of all the geometry used to compute the navigatio mesh
  71528. * @param parameters bunch of parameters used to filter geometry
  71529. */
  71530. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71531. /**
  71532. * Create a navigation mesh debug mesh
  71533. * @param scene is where the mesh will be added
  71534. * @returns debug display mesh
  71535. */
  71536. createDebugNavMesh(scene: Scene): Mesh;
  71537. /**
  71538. * Get a navigation mesh constrained position, closest to the parameter position
  71539. * @param position world position
  71540. * @returns the closest point to position constrained by the navigation mesh
  71541. */
  71542. getClosestPoint(position: Vector3): Vector3;
  71543. /**
  71544. * Get a navigation mesh constrained position, closest to the parameter position
  71545. * @param position world position
  71546. * @param result output the closest point to position constrained by the navigation mesh
  71547. */
  71548. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71549. /**
  71550. * Get a navigation mesh constrained position, within a particular radius
  71551. * @param position world position
  71552. * @param maxRadius the maximum distance to the constrained world position
  71553. * @returns the closest point to position constrained by the navigation mesh
  71554. */
  71555. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71556. /**
  71557. * Get a navigation mesh constrained position, within a particular radius
  71558. * @param position world position
  71559. * @param maxRadius the maximum distance to the constrained world position
  71560. * @param result output the closest point to position constrained by the navigation mesh
  71561. */
  71562. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71563. /**
  71564. * Compute the final position from a segment made of destination-position
  71565. * @param position world position
  71566. * @param destination world position
  71567. * @returns the resulting point along the navmesh
  71568. */
  71569. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71570. /**
  71571. * Compute the final position from a segment made of destination-position
  71572. * @param position world position
  71573. * @param destination world position
  71574. * @param result output the resulting point along the navmesh
  71575. */
  71576. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71577. /**
  71578. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71579. * @param start world position
  71580. * @param end world position
  71581. * @returns array containing world position composing the path
  71582. */
  71583. computePath(start: Vector3, end: Vector3): Vector3[];
  71584. /**
  71585. * Create a new Crowd so you can add agents
  71586. * @param maxAgents the maximum agent count in the crowd
  71587. * @param maxAgentRadius the maximum radius an agent can have
  71588. * @param scene to attach the crowd to
  71589. * @returns the crowd you can add agents to
  71590. */
  71591. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71592. /**
  71593. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71594. * The queries will try to find a solution within those bounds
  71595. * default is (1,1,1)
  71596. * @param extent x,y,z value that define the extent around the queries point of reference
  71597. */
  71598. setDefaultQueryExtent(extent: Vector3): void;
  71599. /**
  71600. * Get the Bounding box extent specified by setDefaultQueryExtent
  71601. * @returns the box extent values
  71602. */
  71603. getDefaultQueryExtent(): Vector3;
  71604. /**
  71605. * build the navmesh from a previously saved state using getNavmeshData
  71606. * @param data the Uint8Array returned by getNavmeshData
  71607. */
  71608. buildFromNavmeshData(data: Uint8Array): void;
  71609. /**
  71610. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71611. * @returns data the Uint8Array that can be saved and reused
  71612. */
  71613. getNavmeshData(): Uint8Array;
  71614. /**
  71615. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71616. * @param result output the box extent values
  71617. */
  71618. getDefaultQueryExtentToRef(result: Vector3): void;
  71619. /**
  71620. * Disposes
  71621. */
  71622. dispose(): void;
  71623. /**
  71624. * If this plugin is supported
  71625. * @returns true if plugin is supported
  71626. */
  71627. isSupported(): boolean;
  71628. }
  71629. /**
  71630. * Recast detour crowd implementation
  71631. */
  71632. export class RecastJSCrowd implements ICrowd {
  71633. /**
  71634. * Recast/detour plugin
  71635. */
  71636. bjsRECASTPlugin: RecastJSPlugin;
  71637. /**
  71638. * Link to the detour crowd
  71639. */
  71640. recastCrowd: any;
  71641. /**
  71642. * One transform per agent
  71643. */
  71644. transforms: TransformNode[];
  71645. /**
  71646. * All agents created
  71647. */
  71648. agents: number[];
  71649. /**
  71650. * Link to the scene is kept to unregister the crowd from the scene
  71651. */
  71652. private _scene;
  71653. /**
  71654. * Observer for crowd updates
  71655. */
  71656. private _onBeforeAnimationsObserver;
  71657. /**
  71658. * Constructor
  71659. * @param plugin recastJS plugin
  71660. * @param maxAgents the maximum agent count in the crowd
  71661. * @param maxAgentRadius the maximum radius an agent can have
  71662. * @param scene to attach the crowd to
  71663. * @returns the crowd you can add agents to
  71664. */
  71665. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71666. /**
  71667. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71668. * You can attach anything to that node. The node position is updated in the scene update tick.
  71669. * @param pos world position that will be constrained by the navigation mesh
  71670. * @param parameters agent parameters
  71671. * @param transform hooked to the agent that will be update by the scene
  71672. * @returns agent index
  71673. */
  71674. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71675. /**
  71676. * Returns the agent position in world space
  71677. * @param index agent index returned by addAgent
  71678. * @returns world space position
  71679. */
  71680. getAgentPosition(index: number): Vector3;
  71681. /**
  71682. * Returns the agent position result in world space
  71683. * @param index agent index returned by addAgent
  71684. * @param result output world space position
  71685. */
  71686. getAgentPositionToRef(index: number, result: Vector3): void;
  71687. /**
  71688. * Returns the agent velocity in world space
  71689. * @param index agent index returned by addAgent
  71690. * @returns world space velocity
  71691. */
  71692. getAgentVelocity(index: number): Vector3;
  71693. /**
  71694. * Returns the agent velocity result in world space
  71695. * @param index agent index returned by addAgent
  71696. * @param result output world space velocity
  71697. */
  71698. getAgentVelocityToRef(index: number, result: Vector3): void;
  71699. /**
  71700. * Returns the agent next target point on the path
  71701. * @param index agent index returned by addAgent
  71702. * @returns world space position
  71703. */
  71704. getAgentNextTargetPath(index: number): Vector3;
  71705. /**
  71706. * Returns the agent next target point on the path
  71707. * @param index agent index returned by addAgent
  71708. * @param result output world space position
  71709. */
  71710. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71711. /**
  71712. * Gets the agent state
  71713. * @param index agent index returned by addAgent
  71714. * @returns agent state
  71715. */
  71716. getAgentState(index: number): number;
  71717. /**
  71718. * returns true if the agent in over an off mesh link connection
  71719. * @param index agent index returned by addAgent
  71720. * @returns true if over an off mesh link connection
  71721. */
  71722. overOffmeshConnection(index: number): boolean;
  71723. /**
  71724. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71725. * @param index agent index returned by addAgent
  71726. * @param destination targeted world position
  71727. */
  71728. agentGoto(index: number, destination: Vector3): void;
  71729. /**
  71730. * Teleport the agent to a new position
  71731. * @param index agent index returned by addAgent
  71732. * @param destination targeted world position
  71733. */
  71734. agentTeleport(index: number, destination: Vector3): void;
  71735. /**
  71736. * Update agent parameters
  71737. * @param index agent index returned by addAgent
  71738. * @param parameters agent parameters
  71739. */
  71740. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71741. /**
  71742. * remove a particular agent previously created
  71743. * @param index agent index returned by addAgent
  71744. */
  71745. removeAgent(index: number): void;
  71746. /**
  71747. * get the list of all agents attached to this crowd
  71748. * @returns list of agent indices
  71749. */
  71750. getAgents(): number[];
  71751. /**
  71752. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71753. * @param deltaTime in seconds
  71754. */
  71755. update(deltaTime: number): void;
  71756. /**
  71757. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71758. * The queries will try to find a solution within those bounds
  71759. * default is (1,1,1)
  71760. * @param extent x,y,z value that define the extent around the queries point of reference
  71761. */
  71762. setDefaultQueryExtent(extent: Vector3): void;
  71763. /**
  71764. * Get the Bounding box extent specified by setDefaultQueryExtent
  71765. * @returns the box extent values
  71766. */
  71767. getDefaultQueryExtent(): Vector3;
  71768. /**
  71769. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71770. * @param result output the box extent values
  71771. */
  71772. getDefaultQueryExtentToRef(result: Vector3): void;
  71773. /**
  71774. * Release all resources
  71775. */
  71776. dispose(): void;
  71777. }
  71778. }
  71779. declare module BABYLON {
  71780. /**
  71781. * Class used to enable access to IndexedDB
  71782. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71783. */
  71784. export class Database implements IOfflineProvider {
  71785. private _callbackManifestChecked;
  71786. private _currentSceneUrl;
  71787. private _db;
  71788. private _enableSceneOffline;
  71789. private _enableTexturesOffline;
  71790. private _manifestVersionFound;
  71791. private _mustUpdateRessources;
  71792. private _hasReachedQuota;
  71793. private _isSupported;
  71794. private _idbFactory;
  71795. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71796. private static IsUASupportingBlobStorage;
  71797. /**
  71798. * Gets a boolean indicating if Database storate is enabled (off by default)
  71799. */
  71800. static IDBStorageEnabled: boolean;
  71801. /**
  71802. * Gets a boolean indicating if scene must be saved in the database
  71803. */
  71804. get enableSceneOffline(): boolean;
  71805. /**
  71806. * Gets a boolean indicating if textures must be saved in the database
  71807. */
  71808. get enableTexturesOffline(): boolean;
  71809. /**
  71810. * Creates a new Database
  71811. * @param urlToScene defines the url to load the scene
  71812. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71813. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71814. */
  71815. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71816. private static _ParseURL;
  71817. private static _ReturnFullUrlLocation;
  71818. private _checkManifestFile;
  71819. /**
  71820. * Open the database and make it available
  71821. * @param successCallback defines the callback to call on success
  71822. * @param errorCallback defines the callback to call on error
  71823. */
  71824. open(successCallback: () => void, errorCallback: () => void): void;
  71825. /**
  71826. * Loads an image from the database
  71827. * @param url defines the url to load from
  71828. * @param image defines the target DOM image
  71829. */
  71830. loadImage(url: string, image: HTMLImageElement): void;
  71831. private _loadImageFromDBAsync;
  71832. private _saveImageIntoDBAsync;
  71833. private _checkVersionFromDB;
  71834. private _loadVersionFromDBAsync;
  71835. private _saveVersionIntoDBAsync;
  71836. /**
  71837. * Loads a file from database
  71838. * @param url defines the URL to load from
  71839. * @param sceneLoaded defines a callback to call on success
  71840. * @param progressCallBack defines a callback to call when progress changed
  71841. * @param errorCallback defines a callback to call on error
  71842. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71843. */
  71844. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71845. private _loadFileAsync;
  71846. private _saveFileAsync;
  71847. /**
  71848. * Validates if xhr data is correct
  71849. * @param xhr defines the request to validate
  71850. * @param dataType defines the expected data type
  71851. * @returns true if data is correct
  71852. */
  71853. private static _ValidateXHRData;
  71854. }
  71855. }
  71856. declare module BABYLON {
  71857. /** @hidden */
  71858. export var gpuUpdateParticlesPixelShader: {
  71859. name: string;
  71860. shader: string;
  71861. };
  71862. }
  71863. declare module BABYLON {
  71864. /** @hidden */
  71865. export var gpuUpdateParticlesVertexShader: {
  71866. name: string;
  71867. shader: string;
  71868. };
  71869. }
  71870. declare module BABYLON {
  71871. /** @hidden */
  71872. export var clipPlaneFragmentDeclaration2: {
  71873. name: string;
  71874. shader: string;
  71875. };
  71876. }
  71877. declare module BABYLON {
  71878. /** @hidden */
  71879. export var gpuRenderParticlesPixelShader: {
  71880. name: string;
  71881. shader: string;
  71882. };
  71883. }
  71884. declare module BABYLON {
  71885. /** @hidden */
  71886. export var clipPlaneVertexDeclaration2: {
  71887. name: string;
  71888. shader: string;
  71889. };
  71890. }
  71891. declare module BABYLON {
  71892. /** @hidden */
  71893. export var gpuRenderParticlesVertexShader: {
  71894. name: string;
  71895. shader: string;
  71896. };
  71897. }
  71898. declare module BABYLON {
  71899. /**
  71900. * This represents a GPU particle system in Babylon
  71901. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71902. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71903. */
  71904. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71905. /**
  71906. * The layer mask we are rendering the particles through.
  71907. */
  71908. layerMask: number;
  71909. private _capacity;
  71910. private _activeCount;
  71911. private _currentActiveCount;
  71912. private _accumulatedCount;
  71913. private _renderEffect;
  71914. private _updateEffect;
  71915. private _buffer0;
  71916. private _buffer1;
  71917. private _spriteBuffer;
  71918. private _updateVAO;
  71919. private _renderVAO;
  71920. private _targetIndex;
  71921. private _sourceBuffer;
  71922. private _targetBuffer;
  71923. private _currentRenderId;
  71924. private _started;
  71925. private _stopped;
  71926. private _timeDelta;
  71927. private _randomTexture;
  71928. private _randomTexture2;
  71929. private _attributesStrideSize;
  71930. private _updateEffectOptions;
  71931. private _randomTextureSize;
  71932. private _actualFrame;
  71933. private _customEffect;
  71934. private readonly _rawTextureWidth;
  71935. /**
  71936. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71937. */
  71938. static get IsSupported(): boolean;
  71939. /**
  71940. * An event triggered when the system is disposed.
  71941. */
  71942. onDisposeObservable: Observable<IParticleSystem>;
  71943. /**
  71944. * An event triggered when the system is stopped
  71945. */
  71946. onStoppedObservable: Observable<IParticleSystem>;
  71947. /**
  71948. * Gets the maximum number of particles active at the same time.
  71949. * @returns The max number of active particles.
  71950. */
  71951. getCapacity(): number;
  71952. /**
  71953. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71954. * to override the particles.
  71955. */
  71956. forceDepthWrite: boolean;
  71957. /**
  71958. * Gets or set the number of active particles
  71959. */
  71960. get activeParticleCount(): number;
  71961. set activeParticleCount(value: number);
  71962. private _preWarmDone;
  71963. /**
  71964. * Specifies if the particles are updated in emitter local space or world space.
  71965. */
  71966. isLocal: boolean;
  71967. /** Gets or sets a matrix to use to compute projection */
  71968. defaultProjectionMatrix: Matrix;
  71969. /**
  71970. * Is this system ready to be used/rendered
  71971. * @return true if the system is ready
  71972. */
  71973. isReady(): boolean;
  71974. /**
  71975. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71976. * @returns True if it has been started, otherwise false.
  71977. */
  71978. isStarted(): boolean;
  71979. /**
  71980. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71981. * @returns True if it has been stopped, otherwise false.
  71982. */
  71983. isStopped(): boolean;
  71984. /**
  71985. * Gets a boolean indicating that the system is stopping
  71986. * @returns true if the system is currently stopping
  71987. */
  71988. isStopping(): boolean;
  71989. /**
  71990. * Gets the number of particles active at the same time.
  71991. * @returns The number of active particles.
  71992. */
  71993. getActiveCount(): number;
  71994. /**
  71995. * Starts the particle system and begins to emit
  71996. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71997. */
  71998. start(delay?: number): void;
  71999. /**
  72000. * Stops the particle system.
  72001. */
  72002. stop(): void;
  72003. /**
  72004. * Remove all active particles
  72005. */
  72006. reset(): void;
  72007. /**
  72008. * Returns the string "GPUParticleSystem"
  72009. * @returns a string containing the class name
  72010. */
  72011. getClassName(): string;
  72012. /**
  72013. * Gets the custom effect used to render the particles
  72014. * @param blendMode Blend mode for which the effect should be retrieved
  72015. * @returns The effect
  72016. */
  72017. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72018. /**
  72019. * Sets the custom effect used to render the particles
  72020. * @param effect The effect to set
  72021. * @param blendMode Blend mode for which the effect should be set
  72022. */
  72023. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72024. /** @hidden */
  72025. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72026. /**
  72027. * Observable that will be called just before the particles are drawn
  72028. */
  72029. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72030. /**
  72031. * Gets the name of the particle vertex shader
  72032. */
  72033. get vertexShaderName(): string;
  72034. private _colorGradientsTexture;
  72035. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72036. /**
  72037. * Adds a new color gradient
  72038. * @param gradient defines the gradient to use (between 0 and 1)
  72039. * @param color1 defines the color to affect to the specified gradient
  72040. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72041. * @returns the current particle system
  72042. */
  72043. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72044. private _refreshColorGradient;
  72045. /** Force the system to rebuild all gradients that need to be resync */
  72046. forceRefreshGradients(): void;
  72047. /**
  72048. * Remove a specific color gradient
  72049. * @param gradient defines the gradient to remove
  72050. * @returns the current particle system
  72051. */
  72052. removeColorGradient(gradient: number): GPUParticleSystem;
  72053. private _angularSpeedGradientsTexture;
  72054. private _sizeGradientsTexture;
  72055. private _velocityGradientsTexture;
  72056. private _limitVelocityGradientsTexture;
  72057. private _dragGradientsTexture;
  72058. private _addFactorGradient;
  72059. /**
  72060. * Adds a new size gradient
  72061. * @param gradient defines the gradient to use (between 0 and 1)
  72062. * @param factor defines the size factor to affect to the specified gradient
  72063. * @returns the current particle system
  72064. */
  72065. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72066. /**
  72067. * Remove a specific size gradient
  72068. * @param gradient defines the gradient to remove
  72069. * @returns the current particle system
  72070. */
  72071. removeSizeGradient(gradient: number): GPUParticleSystem;
  72072. private _refreshFactorGradient;
  72073. /**
  72074. * Adds a new angular speed gradient
  72075. * @param gradient defines the gradient to use (between 0 and 1)
  72076. * @param factor defines the angular speed to affect to the specified gradient
  72077. * @returns the current particle system
  72078. */
  72079. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72080. /**
  72081. * Remove a specific angular speed gradient
  72082. * @param gradient defines the gradient to remove
  72083. * @returns the current particle system
  72084. */
  72085. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72086. /**
  72087. * Adds a new velocity gradient
  72088. * @param gradient defines the gradient to use (between 0 and 1)
  72089. * @param factor defines the velocity to affect to the specified gradient
  72090. * @returns the current particle system
  72091. */
  72092. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72093. /**
  72094. * Remove a specific velocity gradient
  72095. * @param gradient defines the gradient to remove
  72096. * @returns the current particle system
  72097. */
  72098. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72099. /**
  72100. * Adds a new limit velocity gradient
  72101. * @param gradient defines the gradient to use (between 0 and 1)
  72102. * @param factor defines the limit velocity value to affect to the specified gradient
  72103. * @returns the current particle system
  72104. */
  72105. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72106. /**
  72107. * Remove a specific limit velocity gradient
  72108. * @param gradient defines the gradient to remove
  72109. * @returns the current particle system
  72110. */
  72111. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72112. /**
  72113. * Adds a new drag gradient
  72114. * @param gradient defines the gradient to use (between 0 and 1)
  72115. * @param factor defines the drag value to affect to the specified gradient
  72116. * @returns the current particle system
  72117. */
  72118. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72119. /**
  72120. * Remove a specific drag gradient
  72121. * @param gradient defines the gradient to remove
  72122. * @returns the current particle system
  72123. */
  72124. removeDragGradient(gradient: number): GPUParticleSystem;
  72125. /**
  72126. * Not supported by GPUParticleSystem
  72127. * @param gradient defines the gradient to use (between 0 and 1)
  72128. * @param factor defines the emit rate value to affect to the specified gradient
  72129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72130. * @returns the current particle system
  72131. */
  72132. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72133. /**
  72134. * Not supported by GPUParticleSystem
  72135. * @param gradient defines the gradient to remove
  72136. * @returns the current particle system
  72137. */
  72138. removeEmitRateGradient(gradient: number): IParticleSystem;
  72139. /**
  72140. * Not supported by GPUParticleSystem
  72141. * @param gradient defines the gradient to use (between 0 and 1)
  72142. * @param factor defines the start size value to affect to the specified gradient
  72143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72144. * @returns the current particle system
  72145. */
  72146. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72147. /**
  72148. * Not supported by GPUParticleSystem
  72149. * @param gradient defines the gradient to remove
  72150. * @returns the current particle system
  72151. */
  72152. removeStartSizeGradient(gradient: number): IParticleSystem;
  72153. /**
  72154. * Not supported by GPUParticleSystem
  72155. * @param gradient defines the gradient to use (between 0 and 1)
  72156. * @param min defines the color remap minimal range
  72157. * @param max defines the color remap maximal range
  72158. * @returns the current particle system
  72159. */
  72160. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72161. /**
  72162. * Not supported by GPUParticleSystem
  72163. * @param gradient defines the gradient to remove
  72164. * @returns the current particle system
  72165. */
  72166. removeColorRemapGradient(): IParticleSystem;
  72167. /**
  72168. * Not supported by GPUParticleSystem
  72169. * @param gradient defines the gradient to use (between 0 and 1)
  72170. * @param min defines the alpha remap minimal range
  72171. * @param max defines the alpha remap maximal range
  72172. * @returns the current particle system
  72173. */
  72174. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72175. /**
  72176. * Not supported by GPUParticleSystem
  72177. * @param gradient defines the gradient to remove
  72178. * @returns the current particle system
  72179. */
  72180. removeAlphaRemapGradient(): IParticleSystem;
  72181. /**
  72182. * Not supported by GPUParticleSystem
  72183. * @param gradient defines the gradient to use (between 0 and 1)
  72184. * @param color defines the color to affect to the specified gradient
  72185. * @returns the current particle system
  72186. */
  72187. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72188. /**
  72189. * Not supported by GPUParticleSystem
  72190. * @param gradient defines the gradient to remove
  72191. * @returns the current particle system
  72192. */
  72193. removeRampGradient(): IParticleSystem;
  72194. /**
  72195. * Not supported by GPUParticleSystem
  72196. * @returns the list of ramp gradients
  72197. */
  72198. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72199. /**
  72200. * Not supported by GPUParticleSystem
  72201. * Gets or sets a boolean indicating that ramp gradients must be used
  72202. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72203. */
  72204. get useRampGradients(): boolean;
  72205. set useRampGradients(value: boolean);
  72206. /**
  72207. * Not supported by GPUParticleSystem
  72208. * @param gradient defines the gradient to use (between 0 and 1)
  72209. * @param factor defines the life time factor to affect to the specified gradient
  72210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72211. * @returns the current particle system
  72212. */
  72213. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72214. /**
  72215. * Not supported by GPUParticleSystem
  72216. * @param gradient defines the gradient to remove
  72217. * @returns the current particle system
  72218. */
  72219. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72220. /**
  72221. * Instantiates a GPU particle system.
  72222. * 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.
  72223. * @param name The name of the particle system
  72224. * @param options The options used to create the system
  72225. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72226. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72227. * @param customEffect a custom effect used to change the way particles are rendered by default
  72228. */
  72229. constructor(name: string, options: Partial<{
  72230. capacity: number;
  72231. randomTextureSize: number;
  72232. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72233. protected _reset(): void;
  72234. private _createUpdateVAO;
  72235. private _createRenderVAO;
  72236. private _initialize;
  72237. /** @hidden */
  72238. _recreateUpdateEffect(): void;
  72239. private _getEffect;
  72240. /**
  72241. * Fill the defines array according to the current settings of the particle system
  72242. * @param defines Array to be updated
  72243. * @param blendMode blend mode to take into account when updating the array
  72244. */
  72245. fillDefines(defines: Array<string>, blendMode?: number): void;
  72246. /**
  72247. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72248. * @param uniforms Uniforms array to fill
  72249. * @param attributes Attributes array to fill
  72250. * @param samplers Samplers array to fill
  72251. */
  72252. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72253. /** @hidden */
  72254. _recreateRenderEffect(): Effect;
  72255. /**
  72256. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72257. * @param preWarm defines if we are in the pre-warmimg phase
  72258. */
  72259. animate(preWarm?: boolean): void;
  72260. private _createFactorGradientTexture;
  72261. private _createSizeGradientTexture;
  72262. private _createAngularSpeedGradientTexture;
  72263. private _createVelocityGradientTexture;
  72264. private _createLimitVelocityGradientTexture;
  72265. private _createDragGradientTexture;
  72266. private _createColorGradientTexture;
  72267. /**
  72268. * Renders the particle system in its current state
  72269. * @param preWarm defines if the system should only update the particles but not render them
  72270. * @returns the current number of particles
  72271. */
  72272. render(preWarm?: boolean): number;
  72273. /**
  72274. * Rebuilds the particle system
  72275. */
  72276. rebuild(): void;
  72277. private _releaseBuffers;
  72278. private _releaseVAOs;
  72279. /**
  72280. * Disposes the particle system and free the associated resources
  72281. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72282. */
  72283. dispose(disposeTexture?: boolean): void;
  72284. /**
  72285. * Clones the particle system.
  72286. * @param name The name of the cloned object
  72287. * @param newEmitter The new emitter to use
  72288. * @returns the cloned particle system
  72289. */
  72290. clone(name: string, newEmitter: any): GPUParticleSystem;
  72291. /**
  72292. * Serializes the particle system to a JSON object
  72293. * @param serializeTexture defines if the texture must be serialized as well
  72294. * @returns the JSON object
  72295. */
  72296. serialize(serializeTexture?: boolean): any;
  72297. /**
  72298. * Parses a JSON object to create a GPU particle system.
  72299. * @param parsedParticleSystem The JSON object to parse
  72300. * @param sceneOrEngine The scene or the engine to create the particle system in
  72301. * @param rootUrl The root url to use to load external dependencies like texture
  72302. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72303. * @returns the parsed GPU particle system
  72304. */
  72305. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72306. }
  72307. }
  72308. declare module BABYLON {
  72309. /**
  72310. * Represents a set of particle systems working together to create a specific effect
  72311. */
  72312. export class ParticleSystemSet implements IDisposable {
  72313. /**
  72314. * Gets or sets base Assets URL
  72315. */
  72316. static BaseAssetsUrl: string;
  72317. private _emitterCreationOptions;
  72318. private _emitterNode;
  72319. /**
  72320. * Gets the particle system list
  72321. */
  72322. systems: IParticleSystem[];
  72323. /**
  72324. * Gets the emitter node used with this set
  72325. */
  72326. get emitterNode(): Nullable<TransformNode>;
  72327. /**
  72328. * Creates a new emitter mesh as a sphere
  72329. * @param options defines the options used to create the sphere
  72330. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72331. * @param scene defines the hosting scene
  72332. */
  72333. setEmitterAsSphere(options: {
  72334. diameter: number;
  72335. segments: number;
  72336. color: Color3;
  72337. }, renderingGroupId: number, scene: Scene): void;
  72338. /**
  72339. * Starts all particle systems of the set
  72340. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72341. */
  72342. start(emitter?: AbstractMesh): void;
  72343. /**
  72344. * Release all associated resources
  72345. */
  72346. dispose(): void;
  72347. /**
  72348. * Serialize the set into a JSON compatible object
  72349. * @param serializeTexture defines if the texture must be serialized as well
  72350. * @returns a JSON compatible representation of the set
  72351. */
  72352. serialize(serializeTexture?: boolean): any;
  72353. /**
  72354. * Parse a new ParticleSystemSet from a serialized source
  72355. * @param data defines a JSON compatible representation of the set
  72356. * @param scene defines the hosting scene
  72357. * @param gpu defines if we want GPU particles or CPU particles
  72358. * @returns a new ParticleSystemSet
  72359. */
  72360. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72361. }
  72362. }
  72363. declare module BABYLON {
  72364. /**
  72365. * This class is made for on one-liner static method to help creating particle system set.
  72366. */
  72367. export class ParticleHelper {
  72368. /**
  72369. * Gets or sets base Assets URL
  72370. */
  72371. static BaseAssetsUrl: string;
  72372. /** Define the Url to load snippets */
  72373. static SnippetUrl: string;
  72374. /**
  72375. * Create a default particle system that you can tweak
  72376. * @param emitter defines the emitter to use
  72377. * @param capacity defines the system capacity (default is 500 particles)
  72378. * @param scene defines the hosting scene
  72379. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72380. * @returns the new Particle system
  72381. */
  72382. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72383. /**
  72384. * This is the main static method (one-liner) of this helper to create different particle systems
  72385. * @param type This string represents the type to the particle system to create
  72386. * @param scene The scene where the particle system should live
  72387. * @param gpu If the system will use gpu
  72388. * @returns the ParticleSystemSet created
  72389. */
  72390. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72391. /**
  72392. * Static function used to export a particle system to a ParticleSystemSet variable.
  72393. * Please note that the emitter shape is not exported
  72394. * @param systems defines the particle systems to export
  72395. * @returns the created particle system set
  72396. */
  72397. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72398. /**
  72399. * Creates a particle system from a snippet saved in a remote file
  72400. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72401. * @param url defines the url to load from
  72402. * @param scene defines the hosting scene
  72403. * @param gpu If the system will use gpu
  72404. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72405. * @returns a promise that will resolve to the new particle system
  72406. */
  72407. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72408. /**
  72409. * Creates a particle system from a snippet saved by the particle system editor
  72410. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72411. * @param scene defines the hosting scene
  72412. * @param gpu If the system will use gpu
  72413. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72414. * @returns a promise that will resolve to the new particle system
  72415. */
  72416. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72417. }
  72418. }
  72419. declare module BABYLON {
  72420. interface Engine {
  72421. /**
  72422. * Create an effect to use with particle systems.
  72423. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72424. * the particle system for which you want to create a custom effect in the last parameter
  72425. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72426. * @param uniformsNames defines a list of attribute names
  72427. * @param samplers defines an array of string used to represent textures
  72428. * @param defines defines the string containing the defines to use to compile the shaders
  72429. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72430. * @param onCompiled defines a function to call when the effect creation is successful
  72431. * @param onError defines a function to call when the effect creation has failed
  72432. * @param particleSystem the particle system you want to create the effect for
  72433. * @returns the new Effect
  72434. */
  72435. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72436. }
  72437. interface Mesh {
  72438. /**
  72439. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72440. * @returns an array of IParticleSystem
  72441. */
  72442. getEmittedParticleSystems(): IParticleSystem[];
  72443. /**
  72444. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72445. * @returns an array of IParticleSystem
  72446. */
  72447. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72448. }
  72449. }
  72450. declare module BABYLON {
  72451. /** Defines the 4 color options */
  72452. export enum PointColor {
  72453. /** color value */
  72454. Color = 2,
  72455. /** uv value */
  72456. UV = 1,
  72457. /** random value */
  72458. Random = 0,
  72459. /** stated value */
  72460. Stated = 3
  72461. }
  72462. /**
  72463. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72464. * 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.
  72465. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72466. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72467. *
  72468. * Full documentation here : TO BE ENTERED
  72469. */
  72470. export class PointsCloudSystem implements IDisposable {
  72471. /**
  72472. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72473. * Example : var p = SPS.particles[i];
  72474. */
  72475. particles: CloudPoint[];
  72476. /**
  72477. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72478. */
  72479. nbParticles: number;
  72480. /**
  72481. * This a counter for your own usage. It's not set by any SPS functions.
  72482. */
  72483. counter: number;
  72484. /**
  72485. * The PCS name. This name is also given to the underlying mesh.
  72486. */
  72487. name: string;
  72488. /**
  72489. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72490. */
  72491. mesh: Mesh;
  72492. /**
  72493. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72494. * Please read :
  72495. */
  72496. vars: any;
  72497. /**
  72498. * @hidden
  72499. */
  72500. _size: number;
  72501. private _scene;
  72502. private _promises;
  72503. private _positions;
  72504. private _indices;
  72505. private _normals;
  72506. private _colors;
  72507. private _uvs;
  72508. private _indices32;
  72509. private _positions32;
  72510. private _colors32;
  72511. private _uvs32;
  72512. private _updatable;
  72513. private _isVisibilityBoxLocked;
  72514. private _alwaysVisible;
  72515. private _groups;
  72516. private _groupCounter;
  72517. private _computeParticleColor;
  72518. private _computeParticleTexture;
  72519. private _computeParticleRotation;
  72520. private _computeBoundingBox;
  72521. private _isReady;
  72522. /**
  72523. * Creates a PCS (Points Cloud System) object
  72524. * @param name (String) is the PCS name, this will be the underlying mesh name
  72525. * @param pointSize (number) is the size for each point
  72526. * @param scene (Scene) is the scene in which the PCS is added
  72527. * @param options defines the options of the PCS e.g.
  72528. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72529. */
  72530. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72531. updatable?: boolean;
  72532. });
  72533. /**
  72534. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72535. * If no points were added to the PCS, the returned mesh is just a single point.
  72536. * @returns a promise for the created mesh
  72537. */
  72538. buildMeshAsync(): Promise<Mesh>;
  72539. /**
  72540. * @hidden
  72541. */
  72542. private _buildMesh;
  72543. private _addParticle;
  72544. private _randomUnitVector;
  72545. private _getColorIndicesForCoord;
  72546. private _setPointsColorOrUV;
  72547. private _colorFromTexture;
  72548. private _calculateDensity;
  72549. /**
  72550. * Adds points to the PCS in random positions within a unit sphere
  72551. * @param nb (positive integer) the number of particles to be created from this model
  72552. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72553. * @returns the number of groups in the system
  72554. */
  72555. addPoints(nb: number, pointFunction?: any): number;
  72556. /**
  72557. * Adds points to the PCS from the surface of the model shape
  72558. * @param mesh is any Mesh object that will be used as a surface model for the points
  72559. * @param nb (positive integer) the number of particles to be created from this model
  72560. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72561. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72562. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72563. * @returns the number of groups in the system
  72564. */
  72565. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72566. /**
  72567. * Adds points to the PCS inside the model shape
  72568. * @param mesh is any Mesh object that will be used as a surface model for the points
  72569. * @param nb (positive integer) the number of particles to be created from this model
  72570. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72571. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72572. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72573. * @returns the number of groups in the system
  72574. */
  72575. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72576. /**
  72577. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72578. * This method calls `updateParticle()` for each particle of the SPS.
  72579. * For an animated SPS, it is usually called within the render loop.
  72580. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72581. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72582. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72583. * @returns the PCS.
  72584. */
  72585. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72586. /**
  72587. * Disposes the PCS.
  72588. */
  72589. dispose(): void;
  72590. /**
  72591. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72592. * doc :
  72593. * @returns the PCS.
  72594. */
  72595. refreshVisibleSize(): PointsCloudSystem;
  72596. /**
  72597. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72598. * @param size the size (float) of the visibility box
  72599. * note : this doesn't lock the PCS mesh bounding box.
  72600. * doc :
  72601. */
  72602. setVisibilityBox(size: number): void;
  72603. /**
  72604. * Gets whether the PCS is always visible or not
  72605. * doc :
  72606. */
  72607. get isAlwaysVisible(): boolean;
  72608. /**
  72609. * Sets the PCS as always visible or not
  72610. * doc :
  72611. */
  72612. set isAlwaysVisible(val: boolean);
  72613. /**
  72614. * Tells to `setParticles()` to compute the particle rotations or not
  72615. * Default value : false. The PCS is faster when it's set to false
  72616. * Note : particle rotations are only applied to parent particles
  72617. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72618. */
  72619. set computeParticleRotation(val: boolean);
  72620. /**
  72621. * Tells to `setParticles()` to compute the particle colors or not.
  72622. * Default value : true. The PCS is faster when it's set to false.
  72623. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72624. */
  72625. set computeParticleColor(val: boolean);
  72626. set computeParticleTexture(val: boolean);
  72627. /**
  72628. * Gets if `setParticles()` computes the particle colors or not.
  72629. * Default value : false. The PCS is faster when it's set to false.
  72630. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72631. */
  72632. get computeParticleColor(): boolean;
  72633. /**
  72634. * Gets if `setParticles()` computes the particle textures or not.
  72635. * Default value : false. The PCS is faster when it's set to false.
  72636. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72637. */
  72638. get computeParticleTexture(): boolean;
  72639. /**
  72640. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72641. */
  72642. set computeBoundingBox(val: boolean);
  72643. /**
  72644. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72645. */
  72646. get computeBoundingBox(): boolean;
  72647. /**
  72648. * This function does nothing. It may be overwritten to set all the particle first values.
  72649. * The PCS doesn't call this function, you may have to call it by your own.
  72650. * doc :
  72651. */
  72652. initParticles(): void;
  72653. /**
  72654. * This function does nothing. It may be overwritten to recycle a particle
  72655. * The PCS doesn't call this function, you can to call it
  72656. * doc :
  72657. * @param particle The particle to recycle
  72658. * @returns the recycled particle
  72659. */
  72660. recycleParticle(particle: CloudPoint): CloudPoint;
  72661. /**
  72662. * Updates a particle : this function should be overwritten by the user.
  72663. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72664. * doc :
  72665. * @example : just set a particle position or velocity and recycle conditions
  72666. * @param particle The particle to update
  72667. * @returns the updated particle
  72668. */
  72669. updateParticle(particle: CloudPoint): CloudPoint;
  72670. /**
  72671. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72672. * This does nothing and may be overwritten by the user.
  72673. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72674. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72675. * @param update the boolean update value actually passed to setParticles()
  72676. */
  72677. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72678. /**
  72679. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72680. * This will be passed three parameters.
  72681. * This does nothing and may be overwritten by the user.
  72682. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72683. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72684. * @param update the boolean update value actually passed to setParticles()
  72685. */
  72686. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72687. }
  72688. }
  72689. declare module BABYLON {
  72690. /**
  72691. * Represents one particle of a points cloud system.
  72692. */
  72693. export class CloudPoint {
  72694. /**
  72695. * particle global index
  72696. */
  72697. idx: number;
  72698. /**
  72699. * The color of the particle
  72700. */
  72701. color: Nullable<Color4>;
  72702. /**
  72703. * The world space position of the particle.
  72704. */
  72705. position: Vector3;
  72706. /**
  72707. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72708. */
  72709. rotation: Vector3;
  72710. /**
  72711. * The world space rotation quaternion of the particle.
  72712. */
  72713. rotationQuaternion: Nullable<Quaternion>;
  72714. /**
  72715. * The uv of the particle.
  72716. */
  72717. uv: Nullable<Vector2>;
  72718. /**
  72719. * The current speed of the particle.
  72720. */
  72721. velocity: Vector3;
  72722. /**
  72723. * The pivot point in the particle local space.
  72724. */
  72725. pivot: Vector3;
  72726. /**
  72727. * Must the particle be translated from its pivot point in its local space ?
  72728. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72729. * Default : false
  72730. */
  72731. translateFromPivot: boolean;
  72732. /**
  72733. * Index of this particle in the global "positions" array (Internal use)
  72734. * @hidden
  72735. */
  72736. _pos: number;
  72737. /**
  72738. * @hidden Index of this particle in the global "indices" array (Internal use)
  72739. */
  72740. _ind: number;
  72741. /**
  72742. * Group this particle belongs to
  72743. */
  72744. _group: PointsGroup;
  72745. /**
  72746. * Group id of this particle
  72747. */
  72748. groupId: number;
  72749. /**
  72750. * Index of the particle in its group id (Internal use)
  72751. */
  72752. idxInGroup: number;
  72753. /**
  72754. * @hidden Particle BoundingInfo object (Internal use)
  72755. */
  72756. _boundingInfo: BoundingInfo;
  72757. /**
  72758. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72759. */
  72760. _pcs: PointsCloudSystem;
  72761. /**
  72762. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72763. */
  72764. _stillInvisible: boolean;
  72765. /**
  72766. * @hidden Last computed particle rotation matrix
  72767. */
  72768. _rotationMatrix: number[];
  72769. /**
  72770. * Parent particle Id, if any.
  72771. * Default null.
  72772. */
  72773. parentId: Nullable<number>;
  72774. /**
  72775. * @hidden Internal global position in the PCS.
  72776. */
  72777. _globalPosition: Vector3;
  72778. /**
  72779. * Creates a Point Cloud object.
  72780. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72781. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72782. * @param group (PointsGroup) is the group the particle belongs to
  72783. * @param groupId (integer) is the group identifier in the PCS.
  72784. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72785. * @param pcs defines the PCS it is associated to
  72786. */
  72787. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72788. /**
  72789. * get point size
  72790. */
  72791. get size(): Vector3;
  72792. /**
  72793. * Set point size
  72794. */
  72795. set size(scale: Vector3);
  72796. /**
  72797. * Legacy support, changed quaternion to rotationQuaternion
  72798. */
  72799. get quaternion(): Nullable<Quaternion>;
  72800. /**
  72801. * Legacy support, changed quaternion to rotationQuaternion
  72802. */
  72803. set quaternion(q: Nullable<Quaternion>);
  72804. /**
  72805. * Returns a boolean. True if the particle intersects a mesh, else false
  72806. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72807. * @param target is the object (point or mesh) what the intersection is computed against
  72808. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72809. * @returns true if it intersects
  72810. */
  72811. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72812. /**
  72813. * get the rotation matrix of the particle
  72814. * @hidden
  72815. */
  72816. getRotationMatrix(m: Matrix): void;
  72817. }
  72818. /**
  72819. * Represents a group of points in a points cloud system
  72820. * * PCS internal tool, don't use it manually.
  72821. */
  72822. export class PointsGroup {
  72823. /**
  72824. * The group id
  72825. * @hidden
  72826. */
  72827. groupID: number;
  72828. /**
  72829. * image data for group (internal use)
  72830. * @hidden
  72831. */
  72832. _groupImageData: Nullable<ArrayBufferView>;
  72833. /**
  72834. * Image Width (internal use)
  72835. * @hidden
  72836. */
  72837. _groupImgWidth: number;
  72838. /**
  72839. * Image Height (internal use)
  72840. * @hidden
  72841. */
  72842. _groupImgHeight: number;
  72843. /**
  72844. * Custom position function (internal use)
  72845. * @hidden
  72846. */
  72847. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72848. /**
  72849. * density per facet for surface points
  72850. * @hidden
  72851. */
  72852. _groupDensity: number[];
  72853. /**
  72854. * Only when points are colored by texture carries pointer to texture list array
  72855. * @hidden
  72856. */
  72857. _textureNb: number;
  72858. /**
  72859. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72860. * PCS internal tool, don't use it manually.
  72861. * @hidden
  72862. */
  72863. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72864. }
  72865. }
  72866. declare module BABYLON {
  72867. interface Scene {
  72868. /** @hidden (Backing field) */
  72869. _physicsEngine: Nullable<IPhysicsEngine>;
  72870. /** @hidden */
  72871. _physicsTimeAccumulator: number;
  72872. /**
  72873. * Gets the current physics engine
  72874. * @returns a IPhysicsEngine or null if none attached
  72875. */
  72876. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72877. /**
  72878. * Enables physics to the current scene
  72879. * @param gravity defines the scene's gravity for the physics engine
  72880. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72881. * @return a boolean indicating if the physics engine was initialized
  72882. */
  72883. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72884. /**
  72885. * Disables and disposes the physics engine associated with the scene
  72886. */
  72887. disablePhysicsEngine(): void;
  72888. /**
  72889. * Gets a boolean indicating if there is an active physics engine
  72890. * @returns a boolean indicating if there is an active physics engine
  72891. */
  72892. isPhysicsEnabled(): boolean;
  72893. /**
  72894. * Deletes a physics compound impostor
  72895. * @param compound defines the compound to delete
  72896. */
  72897. deleteCompoundImpostor(compound: any): void;
  72898. /**
  72899. * An event triggered when physic simulation is about to be run
  72900. */
  72901. onBeforePhysicsObservable: Observable<Scene>;
  72902. /**
  72903. * An event triggered when physic simulation has been done
  72904. */
  72905. onAfterPhysicsObservable: Observable<Scene>;
  72906. }
  72907. interface AbstractMesh {
  72908. /** @hidden */
  72909. _physicsImpostor: Nullable<PhysicsImpostor>;
  72910. /**
  72911. * Gets or sets impostor used for physic simulation
  72912. * @see https://doc.babylonjs.com/features/physics_engine
  72913. */
  72914. physicsImpostor: Nullable<PhysicsImpostor>;
  72915. /**
  72916. * Gets the current physics impostor
  72917. * @see https://doc.babylonjs.com/features/physics_engine
  72918. * @returns a physics impostor or null
  72919. */
  72920. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72921. /** Apply a physic impulse to the mesh
  72922. * @param force defines the force to apply
  72923. * @param contactPoint defines where to apply the force
  72924. * @returns the current mesh
  72925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72926. */
  72927. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72928. /**
  72929. * Creates a physic joint between two meshes
  72930. * @param otherMesh defines the other mesh to use
  72931. * @param pivot1 defines the pivot to use on this mesh
  72932. * @param pivot2 defines the pivot to use on the other mesh
  72933. * @param options defines additional options (can be plugin dependent)
  72934. * @returns the current mesh
  72935. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72936. */
  72937. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72938. /** @hidden */
  72939. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72940. }
  72941. /**
  72942. * Defines the physics engine scene component responsible to manage a physics engine
  72943. */
  72944. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72945. /**
  72946. * The component name helpful to identify the component in the list of scene components.
  72947. */
  72948. readonly name: string;
  72949. /**
  72950. * The scene the component belongs to.
  72951. */
  72952. scene: Scene;
  72953. /**
  72954. * Creates a new instance of the component for the given scene
  72955. * @param scene Defines the scene to register the component in
  72956. */
  72957. constructor(scene: Scene);
  72958. /**
  72959. * Registers the component in a given scene
  72960. */
  72961. register(): void;
  72962. /**
  72963. * Rebuilds the elements related to this component in case of
  72964. * context lost for instance.
  72965. */
  72966. rebuild(): void;
  72967. /**
  72968. * Disposes the component and the associated ressources
  72969. */
  72970. dispose(): void;
  72971. }
  72972. }
  72973. declare module BABYLON {
  72974. /**
  72975. * A helper for physics simulations
  72976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72977. */
  72978. export class PhysicsHelper {
  72979. private _scene;
  72980. private _physicsEngine;
  72981. /**
  72982. * Initializes the Physics helper
  72983. * @param scene Babylon.js scene
  72984. */
  72985. constructor(scene: Scene);
  72986. /**
  72987. * Applies a radial explosion impulse
  72988. * @param origin the origin of the explosion
  72989. * @param radiusOrEventOptions the radius or the options of radial explosion
  72990. * @param strength the explosion strength
  72991. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72992. * @returns A physics radial explosion event, or null
  72993. */
  72994. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72995. /**
  72996. * Applies a radial explosion force
  72997. * @param origin the origin of the explosion
  72998. * @param radiusOrEventOptions the radius or the options of radial explosion
  72999. * @param strength the explosion strength
  73000. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73001. * @returns A physics radial explosion event, or null
  73002. */
  73003. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73004. /**
  73005. * Creates a gravitational field
  73006. * @param origin the origin of the explosion
  73007. * @param radiusOrEventOptions the radius or the options of radial explosion
  73008. * @param strength the explosion strength
  73009. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73010. * @returns A physics gravitational field event, or null
  73011. */
  73012. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73013. /**
  73014. * Creates a physics updraft event
  73015. * @param origin the origin of the updraft
  73016. * @param radiusOrEventOptions the radius or the options of the updraft
  73017. * @param strength the strength of the updraft
  73018. * @param height the height of the updraft
  73019. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73020. * @returns A physics updraft event, or null
  73021. */
  73022. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73023. /**
  73024. * Creates a physics vortex event
  73025. * @param origin the of the vortex
  73026. * @param radiusOrEventOptions the radius or the options of the vortex
  73027. * @param strength the strength of the vortex
  73028. * @param height the height of the vortex
  73029. * @returns a Physics vortex event, or null
  73030. * A physics vortex event or null
  73031. */
  73032. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73033. }
  73034. /**
  73035. * Represents a physics radial explosion event
  73036. */
  73037. class PhysicsRadialExplosionEvent {
  73038. private _scene;
  73039. private _options;
  73040. private _sphere;
  73041. private _dataFetched;
  73042. /**
  73043. * Initializes a radial explosioin event
  73044. * @param _scene BabylonJS scene
  73045. * @param _options The options for the vortex event
  73046. */
  73047. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73048. /**
  73049. * Returns the data related to the radial explosion event (sphere).
  73050. * @returns The radial explosion event data
  73051. */
  73052. getData(): PhysicsRadialExplosionEventData;
  73053. /**
  73054. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73055. * @param impostor A physics imposter
  73056. * @param origin the origin of the explosion
  73057. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73058. */
  73059. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73060. /**
  73061. * Triggers affecterd impostors callbacks
  73062. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73063. */
  73064. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73065. /**
  73066. * Disposes the sphere.
  73067. * @param force Specifies if the sphere should be disposed by force
  73068. */
  73069. dispose(force?: boolean): void;
  73070. /*** Helpers ***/
  73071. private _prepareSphere;
  73072. private _intersectsWithSphere;
  73073. }
  73074. /**
  73075. * Represents a gravitational field event
  73076. */
  73077. class PhysicsGravitationalFieldEvent {
  73078. private _physicsHelper;
  73079. private _scene;
  73080. private _origin;
  73081. private _options;
  73082. private _tickCallback;
  73083. private _sphere;
  73084. private _dataFetched;
  73085. /**
  73086. * Initializes the physics gravitational field event
  73087. * @param _physicsHelper A physics helper
  73088. * @param _scene BabylonJS scene
  73089. * @param _origin The origin position of the gravitational field event
  73090. * @param _options The options for the vortex event
  73091. */
  73092. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73093. /**
  73094. * Returns the data related to the gravitational field event (sphere).
  73095. * @returns A gravitational field event
  73096. */
  73097. getData(): PhysicsGravitationalFieldEventData;
  73098. /**
  73099. * Enables the gravitational field.
  73100. */
  73101. enable(): void;
  73102. /**
  73103. * Disables the gravitational field.
  73104. */
  73105. disable(): void;
  73106. /**
  73107. * Disposes the sphere.
  73108. * @param force The force to dispose from the gravitational field event
  73109. */
  73110. dispose(force?: boolean): void;
  73111. private _tick;
  73112. }
  73113. /**
  73114. * Represents a physics updraft event
  73115. */
  73116. class PhysicsUpdraftEvent {
  73117. private _scene;
  73118. private _origin;
  73119. private _options;
  73120. private _physicsEngine;
  73121. private _originTop;
  73122. private _originDirection;
  73123. private _tickCallback;
  73124. private _cylinder;
  73125. private _cylinderPosition;
  73126. private _dataFetched;
  73127. /**
  73128. * Initializes the physics updraft event
  73129. * @param _scene BabylonJS scene
  73130. * @param _origin The origin position of the updraft
  73131. * @param _options The options for the updraft event
  73132. */
  73133. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73134. /**
  73135. * Returns the data related to the updraft event (cylinder).
  73136. * @returns A physics updraft event
  73137. */
  73138. getData(): PhysicsUpdraftEventData;
  73139. /**
  73140. * Enables the updraft.
  73141. */
  73142. enable(): void;
  73143. /**
  73144. * Disables the updraft.
  73145. */
  73146. disable(): void;
  73147. /**
  73148. * Disposes the cylinder.
  73149. * @param force Specifies if the updraft should be disposed by force
  73150. */
  73151. dispose(force?: boolean): void;
  73152. private getImpostorHitData;
  73153. private _tick;
  73154. /*** Helpers ***/
  73155. private _prepareCylinder;
  73156. private _intersectsWithCylinder;
  73157. }
  73158. /**
  73159. * Represents a physics vortex event
  73160. */
  73161. class PhysicsVortexEvent {
  73162. private _scene;
  73163. private _origin;
  73164. private _options;
  73165. private _physicsEngine;
  73166. private _originTop;
  73167. private _tickCallback;
  73168. private _cylinder;
  73169. private _cylinderPosition;
  73170. private _dataFetched;
  73171. /**
  73172. * Initializes the physics vortex event
  73173. * @param _scene The BabylonJS scene
  73174. * @param _origin The origin position of the vortex
  73175. * @param _options The options for the vortex event
  73176. */
  73177. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73178. /**
  73179. * Returns the data related to the vortex event (cylinder).
  73180. * @returns The physics vortex event data
  73181. */
  73182. getData(): PhysicsVortexEventData;
  73183. /**
  73184. * Enables the vortex.
  73185. */
  73186. enable(): void;
  73187. /**
  73188. * Disables the cortex.
  73189. */
  73190. disable(): void;
  73191. /**
  73192. * Disposes the sphere.
  73193. * @param force
  73194. */
  73195. dispose(force?: boolean): void;
  73196. private getImpostorHitData;
  73197. private _tick;
  73198. /*** Helpers ***/
  73199. private _prepareCylinder;
  73200. private _intersectsWithCylinder;
  73201. }
  73202. /**
  73203. * Options fot the radial explosion event
  73204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73205. */
  73206. export class PhysicsRadialExplosionEventOptions {
  73207. /**
  73208. * The radius of the sphere for the radial explosion.
  73209. */
  73210. radius: number;
  73211. /**
  73212. * The strenth of the explosion.
  73213. */
  73214. strength: number;
  73215. /**
  73216. * The strenght of the force in correspondence to the distance of the affected object
  73217. */
  73218. falloff: PhysicsRadialImpulseFalloff;
  73219. /**
  73220. * Sphere options for the radial explosion.
  73221. */
  73222. sphere: {
  73223. segments: number;
  73224. diameter: number;
  73225. };
  73226. /**
  73227. * Sphere options for the radial explosion.
  73228. */
  73229. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73230. }
  73231. /**
  73232. * Options fot the updraft event
  73233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73234. */
  73235. export class PhysicsUpdraftEventOptions {
  73236. /**
  73237. * The radius of the cylinder for the vortex
  73238. */
  73239. radius: number;
  73240. /**
  73241. * The strenth of the updraft.
  73242. */
  73243. strength: number;
  73244. /**
  73245. * The height of the cylinder for the updraft.
  73246. */
  73247. height: number;
  73248. /**
  73249. * The mode for the the updraft.
  73250. */
  73251. updraftMode: PhysicsUpdraftMode;
  73252. }
  73253. /**
  73254. * Options fot the vortex event
  73255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73256. */
  73257. export class PhysicsVortexEventOptions {
  73258. /**
  73259. * The radius of the cylinder for the vortex
  73260. */
  73261. radius: number;
  73262. /**
  73263. * The strenth of the vortex.
  73264. */
  73265. strength: number;
  73266. /**
  73267. * The height of the cylinder for the vortex.
  73268. */
  73269. height: number;
  73270. /**
  73271. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73272. */
  73273. centripetalForceThreshold: number;
  73274. /**
  73275. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73276. */
  73277. centripetalForceMultiplier: number;
  73278. /**
  73279. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73280. */
  73281. centrifugalForceMultiplier: number;
  73282. /**
  73283. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73284. */
  73285. updraftForceMultiplier: number;
  73286. }
  73287. /**
  73288. * The strenght of the force in correspondence to the distance of the affected object
  73289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73290. */
  73291. export enum PhysicsRadialImpulseFalloff {
  73292. /** Defines that impulse is constant in strength across it's whole radius */
  73293. Constant = 0,
  73294. /** Defines that impulse gets weaker if it's further from the origin */
  73295. Linear = 1
  73296. }
  73297. /**
  73298. * The strength of the force in correspondence to the distance of the affected object
  73299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73300. */
  73301. export enum PhysicsUpdraftMode {
  73302. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73303. Center = 0,
  73304. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73305. Perpendicular = 1
  73306. }
  73307. /**
  73308. * Interface for a physics hit data
  73309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73310. */
  73311. export interface PhysicsHitData {
  73312. /**
  73313. * The force applied at the contact point
  73314. */
  73315. force: Vector3;
  73316. /**
  73317. * The contact point
  73318. */
  73319. contactPoint: Vector3;
  73320. /**
  73321. * The distance from the origin to the contact point
  73322. */
  73323. distanceFromOrigin: number;
  73324. }
  73325. /**
  73326. * Interface for radial explosion event data
  73327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73328. */
  73329. export interface PhysicsRadialExplosionEventData {
  73330. /**
  73331. * A sphere used for the radial explosion event
  73332. */
  73333. sphere: Mesh;
  73334. }
  73335. /**
  73336. * Interface for gravitational field event data
  73337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73338. */
  73339. export interface PhysicsGravitationalFieldEventData {
  73340. /**
  73341. * A sphere mesh used for the gravitational field event
  73342. */
  73343. sphere: Mesh;
  73344. }
  73345. /**
  73346. * Interface for updraft event data
  73347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73348. */
  73349. export interface PhysicsUpdraftEventData {
  73350. /**
  73351. * A cylinder used for the updraft event
  73352. */
  73353. cylinder: Mesh;
  73354. }
  73355. /**
  73356. * Interface for vortex event data
  73357. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73358. */
  73359. export interface PhysicsVortexEventData {
  73360. /**
  73361. * A cylinder used for the vortex event
  73362. */
  73363. cylinder: Mesh;
  73364. }
  73365. /**
  73366. * Interface for an affected physics impostor
  73367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73368. */
  73369. export interface PhysicsAffectedImpostorWithData {
  73370. /**
  73371. * The impostor affected by the effect
  73372. */
  73373. impostor: PhysicsImpostor;
  73374. /**
  73375. * The data about the hit/horce from the explosion
  73376. */
  73377. hitData: PhysicsHitData;
  73378. }
  73379. }
  73380. declare module BABYLON {
  73381. /** @hidden */
  73382. export var blackAndWhitePixelShader: {
  73383. name: string;
  73384. shader: string;
  73385. };
  73386. }
  73387. declare module BABYLON {
  73388. /**
  73389. * Post process used to render in black and white
  73390. */
  73391. export class BlackAndWhitePostProcess extends PostProcess {
  73392. /**
  73393. * Linear about to convert he result to black and white (default: 1)
  73394. */
  73395. degree: number;
  73396. /**
  73397. * Gets a string identifying the name of the class
  73398. * @returns "BlackAndWhitePostProcess" string
  73399. */
  73400. getClassName(): string;
  73401. /**
  73402. * Creates a black and white post process
  73403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73404. * @param name The name of the effect.
  73405. * @param options The required width/height ratio to downsize to before computing the render pass.
  73406. * @param camera The camera to apply the render pass to.
  73407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73408. * @param engine The engine which the post process will be applied. (default: current engine)
  73409. * @param reusable If the post process can be reused on the same frame. (default: false)
  73410. */
  73411. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73412. /** @hidden */
  73413. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73414. }
  73415. }
  73416. declare module BABYLON {
  73417. /**
  73418. * This represents a set of one or more post processes in Babylon.
  73419. * A post process can be used to apply a shader to a texture after it is rendered.
  73420. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73421. */
  73422. export class PostProcessRenderEffect {
  73423. private _postProcesses;
  73424. private _getPostProcesses;
  73425. private _singleInstance;
  73426. private _cameras;
  73427. private _indicesForCamera;
  73428. /**
  73429. * Name of the effect
  73430. * @hidden
  73431. */
  73432. _name: string;
  73433. /**
  73434. * Instantiates a post process render effect.
  73435. * A post process can be used to apply a shader to a texture after it is rendered.
  73436. * @param engine The engine the effect is tied to
  73437. * @param name The name of the effect
  73438. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73439. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73440. */
  73441. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73442. /**
  73443. * Checks if all the post processes in the effect are supported.
  73444. */
  73445. get isSupported(): boolean;
  73446. /**
  73447. * Updates the current state of the effect
  73448. * @hidden
  73449. */
  73450. _update(): void;
  73451. /**
  73452. * Attaches the effect on cameras
  73453. * @param cameras The camera to attach to.
  73454. * @hidden
  73455. */
  73456. _attachCameras(cameras: Camera): void;
  73457. /**
  73458. * Attaches the effect on cameras
  73459. * @param cameras The camera to attach to.
  73460. * @hidden
  73461. */
  73462. _attachCameras(cameras: Camera[]): void;
  73463. /**
  73464. * Detaches the effect on cameras
  73465. * @param cameras The camera to detatch from.
  73466. * @hidden
  73467. */
  73468. _detachCameras(cameras: Camera): void;
  73469. /**
  73470. * Detatches the effect on cameras
  73471. * @param cameras The camera to detatch from.
  73472. * @hidden
  73473. */
  73474. _detachCameras(cameras: Camera[]): void;
  73475. /**
  73476. * Enables the effect on given cameras
  73477. * @param cameras The camera to enable.
  73478. * @hidden
  73479. */
  73480. _enable(cameras: Camera): void;
  73481. /**
  73482. * Enables the effect on given cameras
  73483. * @param cameras The camera to enable.
  73484. * @hidden
  73485. */
  73486. _enable(cameras: Nullable<Camera[]>): void;
  73487. /**
  73488. * Disables the effect on the given cameras
  73489. * @param cameras The camera to disable.
  73490. * @hidden
  73491. */
  73492. _disable(cameras: Camera): void;
  73493. /**
  73494. * Disables the effect on the given cameras
  73495. * @param cameras The camera to disable.
  73496. * @hidden
  73497. */
  73498. _disable(cameras: Nullable<Camera[]>): void;
  73499. /**
  73500. * Gets a list of the post processes contained in the effect.
  73501. * @param camera The camera to get the post processes on.
  73502. * @returns The list of the post processes in the effect.
  73503. */
  73504. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73505. }
  73506. }
  73507. declare module BABYLON {
  73508. /** @hidden */
  73509. export var extractHighlightsPixelShader: {
  73510. name: string;
  73511. shader: string;
  73512. };
  73513. }
  73514. declare module BABYLON {
  73515. /**
  73516. * 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.
  73517. */
  73518. export class ExtractHighlightsPostProcess extends PostProcess {
  73519. /**
  73520. * The luminance threshold, pixels below this value will be set to black.
  73521. */
  73522. threshold: number;
  73523. /** @hidden */
  73524. _exposure: number;
  73525. /**
  73526. * Post process which has the input texture to be used when performing highlight extraction
  73527. * @hidden
  73528. */
  73529. _inputPostProcess: Nullable<PostProcess>;
  73530. /**
  73531. * Gets a string identifying the name of the class
  73532. * @returns "ExtractHighlightsPostProcess" string
  73533. */
  73534. getClassName(): string;
  73535. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73536. }
  73537. }
  73538. declare module BABYLON {
  73539. /** @hidden */
  73540. export var bloomMergePixelShader: {
  73541. name: string;
  73542. shader: string;
  73543. };
  73544. }
  73545. declare module BABYLON {
  73546. /**
  73547. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73548. */
  73549. export class BloomMergePostProcess extends PostProcess {
  73550. /** Weight of the bloom to be added to the original input. */
  73551. weight: number;
  73552. /**
  73553. * Gets a string identifying the name of the class
  73554. * @returns "BloomMergePostProcess" string
  73555. */
  73556. getClassName(): string;
  73557. /**
  73558. * Creates a new instance of @see BloomMergePostProcess
  73559. * @param name The name of the effect.
  73560. * @param originalFromInput Post process which's input will be used for the merge.
  73561. * @param blurred Blurred highlights post process which's output will be used.
  73562. * @param weight Weight of the bloom to be added to the original input.
  73563. * @param options The required width/height ratio to downsize to before computing the render pass.
  73564. * @param camera The camera to apply the render pass to.
  73565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73566. * @param engine The engine which the post process will be applied. (default: current engine)
  73567. * @param reusable If the post process can be reused on the same frame. (default: false)
  73568. * @param textureType Type of textures used when performing the post process. (default: 0)
  73569. * @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)
  73570. */
  73571. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73572. /** Weight of the bloom to be added to the original input. */
  73573. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73574. }
  73575. }
  73576. declare module BABYLON {
  73577. /**
  73578. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73579. */
  73580. export class BloomEffect extends PostProcessRenderEffect {
  73581. private bloomScale;
  73582. /**
  73583. * @hidden Internal
  73584. */
  73585. _effects: Array<PostProcess>;
  73586. /**
  73587. * @hidden Internal
  73588. */
  73589. _downscale: ExtractHighlightsPostProcess;
  73590. private _blurX;
  73591. private _blurY;
  73592. private _merge;
  73593. /**
  73594. * The luminance threshold to find bright areas of the image to bloom.
  73595. */
  73596. get threshold(): number;
  73597. set threshold(value: number);
  73598. /**
  73599. * The strength of the bloom.
  73600. */
  73601. get weight(): number;
  73602. set weight(value: number);
  73603. /**
  73604. * Specifies the size of the bloom blur kernel, relative to the final output size
  73605. */
  73606. get kernel(): number;
  73607. set kernel(value: number);
  73608. /**
  73609. * Creates a new instance of @see BloomEffect
  73610. * @param scene The scene the effect belongs to.
  73611. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73612. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73613. * @param bloomWeight The the strength of bloom.
  73614. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73615. * @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)
  73616. */
  73617. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73618. /**
  73619. * Disposes each of the internal effects for a given camera.
  73620. * @param camera The camera to dispose the effect on.
  73621. */
  73622. disposeEffects(camera: Camera): void;
  73623. /**
  73624. * @hidden Internal
  73625. */
  73626. _updateEffects(): void;
  73627. /**
  73628. * Internal
  73629. * @returns if all the contained post processes are ready.
  73630. * @hidden
  73631. */
  73632. _isReady(): boolean;
  73633. }
  73634. }
  73635. declare module BABYLON {
  73636. /** @hidden */
  73637. export var chromaticAberrationPixelShader: {
  73638. name: string;
  73639. shader: string;
  73640. };
  73641. }
  73642. declare module BABYLON {
  73643. /**
  73644. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73645. */
  73646. export class ChromaticAberrationPostProcess extends PostProcess {
  73647. /**
  73648. * The amount of seperation of rgb channels (default: 30)
  73649. */
  73650. aberrationAmount: number;
  73651. /**
  73652. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73653. */
  73654. radialIntensity: number;
  73655. /**
  73656. * 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))
  73657. */
  73658. direction: Vector2;
  73659. /**
  73660. * 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))
  73661. */
  73662. centerPosition: Vector2;
  73663. /** The width of the screen to apply the effect on */
  73664. screenWidth: number;
  73665. /** The height of the screen to apply the effect on */
  73666. screenHeight: number;
  73667. /**
  73668. * Gets a string identifying the name of the class
  73669. * @returns "ChromaticAberrationPostProcess" string
  73670. */
  73671. getClassName(): string;
  73672. /**
  73673. * Creates a new instance ChromaticAberrationPostProcess
  73674. * @param name The name of the effect.
  73675. * @param screenWidth The width of the screen to apply the effect on.
  73676. * @param screenHeight The height of the screen to apply the effect on.
  73677. * @param options The required width/height ratio to downsize to before computing the render pass.
  73678. * @param camera The camera to apply the render pass to.
  73679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73680. * @param engine The engine which the post process will be applied. (default: current engine)
  73681. * @param reusable If the post process can be reused on the same frame. (default: false)
  73682. * @param textureType Type of textures used when performing the post process. (default: 0)
  73683. * @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)
  73684. */
  73685. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73686. /** @hidden */
  73687. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73688. }
  73689. }
  73690. declare module BABYLON {
  73691. /** @hidden */
  73692. export var circleOfConfusionPixelShader: {
  73693. name: string;
  73694. shader: string;
  73695. };
  73696. }
  73697. declare module BABYLON {
  73698. /**
  73699. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73700. */
  73701. export class CircleOfConfusionPostProcess extends PostProcess {
  73702. /**
  73703. * 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.
  73704. */
  73705. lensSize: number;
  73706. /**
  73707. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73708. */
  73709. fStop: number;
  73710. /**
  73711. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73712. */
  73713. focusDistance: number;
  73714. /**
  73715. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73716. */
  73717. focalLength: number;
  73718. /**
  73719. * Gets a string identifying the name of the class
  73720. * @returns "CircleOfConfusionPostProcess" string
  73721. */
  73722. getClassName(): string;
  73723. private _depthTexture;
  73724. /**
  73725. * Creates a new instance CircleOfConfusionPostProcess
  73726. * @param name The name of the effect.
  73727. * @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.
  73728. * @param options The required width/height ratio to downsize to before computing the render pass.
  73729. * @param camera The camera to apply the render pass to.
  73730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73731. * @param engine The engine which the post process will be applied. (default: current engine)
  73732. * @param reusable If the post process can be reused on the same frame. (default: false)
  73733. * @param textureType Type of textures used when performing the post process. (default: 0)
  73734. * @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)
  73735. */
  73736. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73737. /**
  73738. * 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.
  73739. */
  73740. set depthTexture(value: RenderTargetTexture);
  73741. }
  73742. }
  73743. declare module BABYLON {
  73744. /** @hidden */
  73745. export var colorCorrectionPixelShader: {
  73746. name: string;
  73747. shader: string;
  73748. };
  73749. }
  73750. declare module BABYLON {
  73751. /**
  73752. *
  73753. * This post-process allows the modification of rendered colors by using
  73754. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73755. *
  73756. * The object needs to be provided an url to a texture containing the color
  73757. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73758. * Use an image editing software to tweak the LUT to match your needs.
  73759. *
  73760. * For an example of a color LUT, see here:
  73761. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73762. * For explanations on color grading, see here:
  73763. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73764. *
  73765. */
  73766. export class ColorCorrectionPostProcess extends PostProcess {
  73767. private _colorTableTexture;
  73768. /**
  73769. * Gets the color table url used to create the LUT texture
  73770. */
  73771. colorTableUrl: string;
  73772. /**
  73773. * Gets a string identifying the name of the class
  73774. * @returns "ColorCorrectionPostProcess" string
  73775. */
  73776. getClassName(): string;
  73777. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73778. /** @hidden */
  73779. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73780. }
  73781. }
  73782. declare module BABYLON {
  73783. /** @hidden */
  73784. export var convolutionPixelShader: {
  73785. name: string;
  73786. shader: string;
  73787. };
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73792. * input texture to perform effects such as edge detection or sharpening
  73793. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73794. */
  73795. export class ConvolutionPostProcess extends PostProcess {
  73796. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73797. kernel: number[];
  73798. /**
  73799. * Gets a string identifying the name of the class
  73800. * @returns "ConvolutionPostProcess" string
  73801. */
  73802. getClassName(): string;
  73803. /**
  73804. * Creates a new instance ConvolutionPostProcess
  73805. * @param name The name of the effect.
  73806. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73807. * @param options The required width/height ratio to downsize to before computing the render pass.
  73808. * @param camera The camera to apply the render pass to.
  73809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73810. * @param engine The engine which the post process will be applied. (default: current engine)
  73811. * @param reusable If the post process can be reused on the same frame. (default: false)
  73812. * @param textureType Type of textures used when performing the post process. (default: 0)
  73813. */
  73814. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73815. /** @hidden */
  73816. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73817. /**
  73818. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73819. */
  73820. static EdgeDetect0Kernel: number[];
  73821. /**
  73822. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73823. */
  73824. static EdgeDetect1Kernel: number[];
  73825. /**
  73826. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73827. */
  73828. static EdgeDetect2Kernel: number[];
  73829. /**
  73830. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73831. */
  73832. static SharpenKernel: number[];
  73833. /**
  73834. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73835. */
  73836. static EmbossKernel: number[];
  73837. /**
  73838. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73839. */
  73840. static GaussianKernel: number[];
  73841. }
  73842. }
  73843. declare module BABYLON {
  73844. /**
  73845. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73846. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73847. * based on samples that have a large difference in distance than the center pixel.
  73848. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73849. */
  73850. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73851. /**
  73852. * The direction the blur should be applied
  73853. */
  73854. direction: Vector2;
  73855. /**
  73856. * Gets a string identifying the name of the class
  73857. * @returns "DepthOfFieldBlurPostProcess" string
  73858. */
  73859. getClassName(): string;
  73860. /**
  73861. * Creates a new instance CircleOfConfusionPostProcess
  73862. * @param name The name of the effect.
  73863. * @param scene The scene the effect belongs to.
  73864. * @param direction The direction the blur should be applied.
  73865. * @param kernel The size of the kernel used to blur.
  73866. * @param options The required width/height ratio to downsize to before computing the render pass.
  73867. * @param camera The camera to apply the render pass to.
  73868. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73869. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73871. * @param engine The engine which the post process will be applied. (default: current engine)
  73872. * @param reusable If the post process can be reused on the same frame. (default: false)
  73873. * @param textureType Type of textures used when performing the post process. (default: 0)
  73874. * @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)
  73875. */
  73876. 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);
  73877. }
  73878. }
  73879. declare module BABYLON {
  73880. /** @hidden */
  73881. export var depthOfFieldMergePixelShader: {
  73882. name: string;
  73883. shader: string;
  73884. };
  73885. }
  73886. declare module BABYLON {
  73887. /**
  73888. * Options to be set when merging outputs from the default pipeline.
  73889. */
  73890. export class DepthOfFieldMergePostProcessOptions {
  73891. /**
  73892. * The original image to merge on top of
  73893. */
  73894. originalFromInput: PostProcess;
  73895. /**
  73896. * Parameters to perform the merge of the depth of field effect
  73897. */
  73898. depthOfField?: {
  73899. circleOfConfusion: PostProcess;
  73900. blurSteps: Array<PostProcess>;
  73901. };
  73902. /**
  73903. * Parameters to perform the merge of bloom effect
  73904. */
  73905. bloom?: {
  73906. blurred: PostProcess;
  73907. weight: number;
  73908. };
  73909. }
  73910. /**
  73911. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73912. */
  73913. export class DepthOfFieldMergePostProcess extends PostProcess {
  73914. private blurSteps;
  73915. /**
  73916. * Gets a string identifying the name of the class
  73917. * @returns "DepthOfFieldMergePostProcess" string
  73918. */
  73919. getClassName(): string;
  73920. /**
  73921. * Creates a new instance of DepthOfFieldMergePostProcess
  73922. * @param name The name of the effect.
  73923. * @param originalFromInput Post process which's input will be used for the merge.
  73924. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73925. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73926. * @param options The required width/height ratio to downsize to before computing the render pass.
  73927. * @param camera The camera to apply the render pass to.
  73928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73929. * @param engine The engine which the post process will be applied. (default: current engine)
  73930. * @param reusable If the post process can be reused on the same frame. (default: false)
  73931. * @param textureType Type of textures used when performing the post process. (default: 0)
  73932. * @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)
  73933. */
  73934. 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);
  73935. /**
  73936. * Updates the effect with the current post process compile time values and recompiles the shader.
  73937. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73938. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73939. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73940. * @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
  73941. * @param onCompiled Called when the shader has been compiled.
  73942. * @param onError Called if there is an error when compiling a shader.
  73943. */
  73944. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73945. }
  73946. }
  73947. declare module BABYLON {
  73948. /**
  73949. * Specifies the level of max blur that should be applied when using the depth of field effect
  73950. */
  73951. export enum DepthOfFieldEffectBlurLevel {
  73952. /**
  73953. * Subtle blur
  73954. */
  73955. Low = 0,
  73956. /**
  73957. * Medium blur
  73958. */
  73959. Medium = 1,
  73960. /**
  73961. * Large blur
  73962. */
  73963. High = 2
  73964. }
  73965. /**
  73966. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73967. */
  73968. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73969. private _circleOfConfusion;
  73970. /**
  73971. * @hidden Internal, blurs from high to low
  73972. */
  73973. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73974. private _depthOfFieldBlurY;
  73975. private _dofMerge;
  73976. /**
  73977. * @hidden Internal post processes in depth of field effect
  73978. */
  73979. _effects: Array<PostProcess>;
  73980. /**
  73981. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73982. */
  73983. set focalLength(value: number);
  73984. get focalLength(): number;
  73985. /**
  73986. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73987. */
  73988. set fStop(value: number);
  73989. get fStop(): number;
  73990. /**
  73991. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73992. */
  73993. set focusDistance(value: number);
  73994. get focusDistance(): number;
  73995. /**
  73996. * 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.
  73997. */
  73998. set lensSize(value: number);
  73999. get lensSize(): number;
  74000. /**
  74001. * Creates a new instance DepthOfFieldEffect
  74002. * @param scene The scene the effect belongs to.
  74003. * @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.
  74004. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74005. * @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)
  74006. */
  74007. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74008. /**
  74009. * Get the current class name of the current effet
  74010. * @returns "DepthOfFieldEffect"
  74011. */
  74012. getClassName(): string;
  74013. /**
  74014. * 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.
  74015. */
  74016. set depthTexture(value: RenderTargetTexture);
  74017. /**
  74018. * Disposes each of the internal effects for a given camera.
  74019. * @param camera The camera to dispose the effect on.
  74020. */
  74021. disposeEffects(camera: Camera): void;
  74022. /**
  74023. * @hidden Internal
  74024. */
  74025. _updateEffects(): void;
  74026. /**
  74027. * Internal
  74028. * @returns if all the contained post processes are ready.
  74029. * @hidden
  74030. */
  74031. _isReady(): boolean;
  74032. }
  74033. }
  74034. declare module BABYLON {
  74035. /** @hidden */
  74036. export var displayPassPixelShader: {
  74037. name: string;
  74038. shader: string;
  74039. };
  74040. }
  74041. declare module BABYLON {
  74042. /**
  74043. * DisplayPassPostProcess which produces an output the same as it's input
  74044. */
  74045. export class DisplayPassPostProcess extends PostProcess {
  74046. /**
  74047. * Gets a string identifying the name of the class
  74048. * @returns "DisplayPassPostProcess" string
  74049. */
  74050. getClassName(): string;
  74051. /**
  74052. * Creates the DisplayPassPostProcess
  74053. * @param name The name of the effect.
  74054. * @param options The required width/height ratio to downsize to before computing the render pass.
  74055. * @param camera The camera to apply the render pass to.
  74056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74057. * @param engine The engine which the post process will be applied. (default: current engine)
  74058. * @param reusable If the post process can be reused on the same frame. (default: false)
  74059. */
  74060. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74061. /** @hidden */
  74062. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74063. }
  74064. }
  74065. declare module BABYLON {
  74066. /** @hidden */
  74067. export var filterPixelShader: {
  74068. name: string;
  74069. shader: string;
  74070. };
  74071. }
  74072. declare module BABYLON {
  74073. /**
  74074. * Applies a kernel filter to the image
  74075. */
  74076. export class FilterPostProcess extends PostProcess {
  74077. /** The matrix to be applied to the image */
  74078. kernelMatrix: Matrix;
  74079. /**
  74080. * Gets a string identifying the name of the class
  74081. * @returns "FilterPostProcess" string
  74082. */
  74083. getClassName(): string;
  74084. /**
  74085. *
  74086. * @param name The name of the effect.
  74087. * @param kernelMatrix The matrix to be applied to the image
  74088. * @param options The required width/height ratio to downsize to before computing the render pass.
  74089. * @param camera The camera to apply the render pass to.
  74090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74091. * @param engine The engine which the post process will be applied. (default: current engine)
  74092. * @param reusable If the post process can be reused on the same frame. (default: false)
  74093. */
  74094. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74095. /** @hidden */
  74096. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74097. }
  74098. }
  74099. declare module BABYLON {
  74100. /** @hidden */
  74101. export var fxaaPixelShader: {
  74102. name: string;
  74103. shader: string;
  74104. };
  74105. }
  74106. declare module BABYLON {
  74107. /** @hidden */
  74108. export var fxaaVertexShader: {
  74109. name: string;
  74110. shader: string;
  74111. };
  74112. }
  74113. declare module BABYLON {
  74114. /**
  74115. * Fxaa post process
  74116. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74117. */
  74118. export class FxaaPostProcess extends PostProcess {
  74119. /**
  74120. * Gets a string identifying the name of the class
  74121. * @returns "FxaaPostProcess" string
  74122. */
  74123. getClassName(): string;
  74124. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74125. private _getDefines;
  74126. /** @hidden */
  74127. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74128. }
  74129. }
  74130. declare module BABYLON {
  74131. /** @hidden */
  74132. export var grainPixelShader: {
  74133. name: string;
  74134. shader: string;
  74135. };
  74136. }
  74137. declare module BABYLON {
  74138. /**
  74139. * The GrainPostProcess adds noise to the image at mid luminance levels
  74140. */
  74141. export class GrainPostProcess extends PostProcess {
  74142. /**
  74143. * The intensity of the grain added (default: 30)
  74144. */
  74145. intensity: number;
  74146. /**
  74147. * If the grain should be randomized on every frame
  74148. */
  74149. animated: boolean;
  74150. /**
  74151. * Gets a string identifying the name of the class
  74152. * @returns "GrainPostProcess" string
  74153. */
  74154. getClassName(): string;
  74155. /**
  74156. * Creates a new instance of @see GrainPostProcess
  74157. * @param name The name of the effect.
  74158. * @param options The required width/height ratio to downsize to before computing the render pass.
  74159. * @param camera The camera to apply the render pass to.
  74160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74161. * @param engine The engine which the post process will be applied. (default: current engine)
  74162. * @param reusable If the post process can be reused on the same frame. (default: false)
  74163. * @param textureType Type of textures used when performing the post process. (default: 0)
  74164. * @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)
  74165. */
  74166. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74167. /** @hidden */
  74168. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74169. }
  74170. }
  74171. declare module BABYLON {
  74172. /** @hidden */
  74173. export var highlightsPixelShader: {
  74174. name: string;
  74175. shader: string;
  74176. };
  74177. }
  74178. declare module BABYLON {
  74179. /**
  74180. * Extracts highlights from the image
  74181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74182. */
  74183. export class HighlightsPostProcess extends PostProcess {
  74184. /**
  74185. * Gets a string identifying the name of the class
  74186. * @returns "HighlightsPostProcess" string
  74187. */
  74188. getClassName(): string;
  74189. /**
  74190. * Extracts highlights from the image
  74191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74192. * @param name The name of the effect.
  74193. * @param options The required width/height ratio to downsize to before computing the render pass.
  74194. * @param camera The camera to apply the render pass to.
  74195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74196. * @param engine The engine which the post process will be applied. (default: current engine)
  74197. * @param reusable If the post process can be reused on the same frame. (default: false)
  74198. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74199. */
  74200. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74201. }
  74202. }
  74203. declare module BABYLON {
  74204. /**
  74205. * Contains all parameters needed for the prepass to perform
  74206. * motion blur
  74207. */
  74208. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74209. /**
  74210. * Is motion blur enabled
  74211. */
  74212. enabled: boolean;
  74213. /**
  74214. * Name of the configuration
  74215. */
  74216. name: string;
  74217. /**
  74218. * Textures that should be present in the MRT for this effect to work
  74219. */
  74220. readonly texturesRequired: number[];
  74221. }
  74222. }
  74223. declare module BABYLON {
  74224. interface Scene {
  74225. /** @hidden (Backing field) */
  74226. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74227. /**
  74228. * Gets or Sets the current geometry buffer associated to the scene.
  74229. */
  74230. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74231. /**
  74232. * Enables a GeometryBufferRender and associates it with the scene
  74233. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74234. * @returns the GeometryBufferRenderer
  74235. */
  74236. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74237. /**
  74238. * Disables the GeometryBufferRender associated with the scene
  74239. */
  74240. disableGeometryBufferRenderer(): void;
  74241. }
  74242. /**
  74243. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74244. * in several rendering techniques.
  74245. */
  74246. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74247. /**
  74248. * The component name helpful to identify the component in the list of scene components.
  74249. */
  74250. readonly name: string;
  74251. /**
  74252. * The scene the component belongs to.
  74253. */
  74254. scene: Scene;
  74255. /**
  74256. * Creates a new instance of the component for the given scene
  74257. * @param scene Defines the scene to register the component in
  74258. */
  74259. constructor(scene: Scene);
  74260. /**
  74261. * Registers the component in a given scene
  74262. */
  74263. register(): void;
  74264. /**
  74265. * Rebuilds the elements related to this component in case of
  74266. * context lost for instance.
  74267. */
  74268. rebuild(): void;
  74269. /**
  74270. * Disposes the component and the associated ressources
  74271. */
  74272. dispose(): void;
  74273. private _gatherRenderTargets;
  74274. }
  74275. }
  74276. declare module BABYLON {
  74277. /** @hidden */
  74278. export var motionBlurPixelShader: {
  74279. name: string;
  74280. shader: string;
  74281. };
  74282. }
  74283. declare module BABYLON {
  74284. /**
  74285. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74286. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74287. * As an example, all you have to do is to create the post-process:
  74288. * var mb = new BABYLON.MotionBlurPostProcess(
  74289. * 'mb', // The name of the effect.
  74290. * scene, // The scene containing the objects to blur according to their velocity.
  74291. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74292. * camera // The camera to apply the render pass to.
  74293. * );
  74294. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74295. */
  74296. export class MotionBlurPostProcess extends PostProcess {
  74297. /**
  74298. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74299. */
  74300. motionStrength: number;
  74301. /**
  74302. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74303. */
  74304. get motionBlurSamples(): number;
  74305. /**
  74306. * Sets the number of iterations to be used for motion blur quality
  74307. */
  74308. set motionBlurSamples(samples: number);
  74309. private _motionBlurSamples;
  74310. /**
  74311. * Gets wether or not the motion blur post-process is in object based mode.
  74312. */
  74313. get isObjectBased(): boolean;
  74314. /**
  74315. * Sets wether or not the motion blur post-process is in object based mode.
  74316. */
  74317. set isObjectBased(value: boolean);
  74318. private _isObjectBased;
  74319. private _forceGeometryBuffer;
  74320. private _geometryBufferRenderer;
  74321. private _prePassRenderer;
  74322. private _invViewProjection;
  74323. private _previousViewProjection;
  74324. /**
  74325. * Gets a string identifying the name of the class
  74326. * @returns "MotionBlurPostProcess" string
  74327. */
  74328. getClassName(): string;
  74329. /**
  74330. * Creates a new instance MotionBlurPostProcess
  74331. * @param name The name of the effect.
  74332. * @param scene The scene containing the objects to blur according to their velocity.
  74333. * @param options The required width/height ratio to downsize to before computing the render pass.
  74334. * @param camera The camera to apply the render pass to.
  74335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74336. * @param engine The engine which the post process will be applied. (default: current engine)
  74337. * @param reusable If the post process can be reused on the same frame. (default: false)
  74338. * @param textureType Type of textures used when performing the post process. (default: 0)
  74339. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  74340. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74341. */
  74342. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74343. /**
  74344. * Excludes the given skinned mesh from computing bones velocities.
  74345. * 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.
  74346. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74347. */
  74348. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74349. /**
  74350. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74351. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74352. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74353. */
  74354. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74355. /**
  74356. * Disposes the post process.
  74357. * @param camera The camera to dispose the post process on.
  74358. */
  74359. dispose(camera?: Camera): void;
  74360. /**
  74361. * Called on the mode changed (object based or screen based).
  74362. */
  74363. private _applyMode;
  74364. /**
  74365. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74366. */
  74367. private _onApplyObjectBased;
  74368. /**
  74369. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74370. */
  74371. private _onApplyScreenBased;
  74372. /**
  74373. * Called on the effect must be updated (changed mode, samples count, etc.).
  74374. */
  74375. private _updateEffect;
  74376. /** @hidden */
  74377. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74378. }
  74379. }
  74380. declare module BABYLON {
  74381. /** @hidden */
  74382. export var refractionPixelShader: {
  74383. name: string;
  74384. shader: string;
  74385. };
  74386. }
  74387. declare module BABYLON {
  74388. /**
  74389. * Post process which applies a refractin texture
  74390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74391. */
  74392. export class RefractionPostProcess extends PostProcess {
  74393. private _refTexture;
  74394. private _ownRefractionTexture;
  74395. /** the base color of the refraction (used to taint the rendering) */
  74396. color: Color3;
  74397. /** simulated refraction depth */
  74398. depth: number;
  74399. /** the coefficient of the base color (0 to remove base color tainting) */
  74400. colorLevel: number;
  74401. /** Gets the url used to load the refraction texture */
  74402. refractionTextureUrl: string;
  74403. /**
  74404. * Gets or sets the refraction texture
  74405. * Please note that you are responsible for disposing the texture if you set it manually
  74406. */
  74407. get refractionTexture(): Texture;
  74408. set refractionTexture(value: Texture);
  74409. /**
  74410. * Gets a string identifying the name of the class
  74411. * @returns "RefractionPostProcess" string
  74412. */
  74413. getClassName(): string;
  74414. /**
  74415. * Initializes the RefractionPostProcess
  74416. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74417. * @param name The name of the effect.
  74418. * @param refractionTextureUrl Url of the refraction texture to use
  74419. * @param color the base color of the refraction (used to taint the rendering)
  74420. * @param depth simulated refraction depth
  74421. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74422. * @param camera The camera to apply the render pass to.
  74423. * @param options The required width/height ratio to downsize to before computing the render pass.
  74424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74425. * @param engine The engine which the post process will be applied. (default: current engine)
  74426. * @param reusable If the post process can be reused on the same frame. (default: false)
  74427. */
  74428. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74429. /**
  74430. * Disposes of the post process
  74431. * @param camera Camera to dispose post process on
  74432. */
  74433. dispose(camera: Camera): void;
  74434. /** @hidden */
  74435. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74436. }
  74437. }
  74438. declare module BABYLON {
  74439. /** @hidden */
  74440. export var sharpenPixelShader: {
  74441. name: string;
  74442. shader: string;
  74443. };
  74444. }
  74445. declare module BABYLON {
  74446. /**
  74447. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74448. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74449. */
  74450. export class SharpenPostProcess extends PostProcess {
  74451. /**
  74452. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74453. */
  74454. colorAmount: number;
  74455. /**
  74456. * How much sharpness should be applied (default: 0.3)
  74457. */
  74458. edgeAmount: number;
  74459. /**
  74460. * Gets a string identifying the name of the class
  74461. * @returns "SharpenPostProcess" string
  74462. */
  74463. getClassName(): string;
  74464. /**
  74465. * Creates a new instance ConvolutionPostProcess
  74466. * @param name The name of the effect.
  74467. * @param options The required width/height ratio to downsize to before computing the render pass.
  74468. * @param camera The camera to apply the render pass to.
  74469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74470. * @param engine The engine which the post process will be applied. (default: current engine)
  74471. * @param reusable If the post process can be reused on the same frame. (default: false)
  74472. * @param textureType Type of textures used when performing the post process. (default: 0)
  74473. * @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)
  74474. */
  74475. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74476. /** @hidden */
  74477. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74478. }
  74479. }
  74480. declare module BABYLON {
  74481. /**
  74482. * PostProcessRenderPipeline
  74483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74484. */
  74485. export class PostProcessRenderPipeline {
  74486. private engine;
  74487. private _renderEffects;
  74488. private _renderEffectsForIsolatedPass;
  74489. /**
  74490. * List of inspectable custom properties (used by the Inspector)
  74491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74492. */
  74493. inspectableCustomProperties: IInspectable[];
  74494. /**
  74495. * @hidden
  74496. */
  74497. protected _cameras: Camera[];
  74498. /** @hidden */
  74499. _name: string;
  74500. /**
  74501. * Gets pipeline name
  74502. */
  74503. get name(): string;
  74504. /** Gets the list of attached cameras */
  74505. get cameras(): Camera[];
  74506. /**
  74507. * Initializes a PostProcessRenderPipeline
  74508. * @param engine engine to add the pipeline to
  74509. * @param name name of the pipeline
  74510. */
  74511. constructor(engine: Engine, name: string);
  74512. /**
  74513. * Gets the class name
  74514. * @returns "PostProcessRenderPipeline"
  74515. */
  74516. getClassName(): string;
  74517. /**
  74518. * If all the render effects in the pipeline are supported
  74519. */
  74520. get isSupported(): boolean;
  74521. /**
  74522. * Adds an effect to the pipeline
  74523. * @param renderEffect the effect to add
  74524. */
  74525. addEffect(renderEffect: PostProcessRenderEffect): void;
  74526. /** @hidden */
  74527. _rebuild(): void;
  74528. /** @hidden */
  74529. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74530. /** @hidden */
  74531. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74532. /** @hidden */
  74533. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74534. /** @hidden */
  74535. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74536. /** @hidden */
  74537. _attachCameras(cameras: Camera, unique: boolean): void;
  74538. /** @hidden */
  74539. _attachCameras(cameras: Camera[], unique: boolean): void;
  74540. /** @hidden */
  74541. _detachCameras(cameras: Camera): void;
  74542. /** @hidden */
  74543. _detachCameras(cameras: Nullable<Camera[]>): void;
  74544. /** @hidden */
  74545. _update(): void;
  74546. /** @hidden */
  74547. _reset(): void;
  74548. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74549. /**
  74550. * Sets the required values to the prepass renderer.
  74551. * @param prePassRenderer defines the prepass renderer to setup.
  74552. * @returns true if the pre pass is needed.
  74553. */
  74554. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74555. /**
  74556. * Disposes of the pipeline
  74557. */
  74558. dispose(): void;
  74559. }
  74560. }
  74561. declare module BABYLON {
  74562. /**
  74563. * PostProcessRenderPipelineManager class
  74564. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74565. */
  74566. export class PostProcessRenderPipelineManager {
  74567. private _renderPipelines;
  74568. /**
  74569. * Initializes a PostProcessRenderPipelineManager
  74570. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74571. */
  74572. constructor();
  74573. /**
  74574. * Gets the list of supported render pipelines
  74575. */
  74576. get supportedPipelines(): PostProcessRenderPipeline[];
  74577. /**
  74578. * Adds a pipeline to the manager
  74579. * @param renderPipeline The pipeline to add
  74580. */
  74581. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74582. /**
  74583. * Attaches a camera to the pipeline
  74584. * @param renderPipelineName The name of the pipeline to attach to
  74585. * @param cameras the camera to attach
  74586. * @param unique if the camera can be attached multiple times to the pipeline
  74587. */
  74588. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74589. /**
  74590. * Detaches a camera from the pipeline
  74591. * @param renderPipelineName The name of the pipeline to detach from
  74592. * @param cameras the camera to detach
  74593. */
  74594. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74595. /**
  74596. * Enables an effect by name on a pipeline
  74597. * @param renderPipelineName the name of the pipeline to enable the effect in
  74598. * @param renderEffectName the name of the effect to enable
  74599. * @param cameras the cameras that the effect should be enabled on
  74600. */
  74601. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74602. /**
  74603. * Disables an effect by name on a pipeline
  74604. * @param renderPipelineName the name of the pipeline to disable the effect in
  74605. * @param renderEffectName the name of the effect to disable
  74606. * @param cameras the cameras that the effect should be disabled on
  74607. */
  74608. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74609. /**
  74610. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74611. */
  74612. update(): void;
  74613. /** @hidden */
  74614. _rebuild(): void;
  74615. /**
  74616. * Disposes of the manager and pipelines
  74617. */
  74618. dispose(): void;
  74619. }
  74620. }
  74621. declare module BABYLON {
  74622. interface Scene {
  74623. /** @hidden (Backing field) */
  74624. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74625. /**
  74626. * Gets the postprocess render pipeline manager
  74627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74628. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74629. */
  74630. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74631. }
  74632. /**
  74633. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74634. */
  74635. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74636. /**
  74637. * The component name helpfull to identify the component in the list of scene components.
  74638. */
  74639. readonly name: string;
  74640. /**
  74641. * The scene the component belongs to.
  74642. */
  74643. scene: Scene;
  74644. /**
  74645. * Creates a new instance of the component for the given scene
  74646. * @param scene Defines the scene to register the component in
  74647. */
  74648. constructor(scene: Scene);
  74649. /**
  74650. * Registers the component in a given scene
  74651. */
  74652. register(): void;
  74653. /**
  74654. * Rebuilds the elements related to this component in case of
  74655. * context lost for instance.
  74656. */
  74657. rebuild(): void;
  74658. /**
  74659. * Disposes the component and the associated ressources
  74660. */
  74661. dispose(): void;
  74662. private _gatherRenderTargets;
  74663. }
  74664. }
  74665. declare module BABYLON {
  74666. /**
  74667. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74668. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74669. */
  74670. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74671. private _scene;
  74672. private _camerasToBeAttached;
  74673. /**
  74674. * ID of the sharpen post process,
  74675. */
  74676. private readonly SharpenPostProcessId;
  74677. /**
  74678. * @ignore
  74679. * ID of the image processing post process;
  74680. */
  74681. readonly ImageProcessingPostProcessId: string;
  74682. /**
  74683. * @ignore
  74684. * ID of the Fast Approximate Anti-Aliasing post process;
  74685. */
  74686. readonly FxaaPostProcessId: string;
  74687. /**
  74688. * ID of the chromatic aberration post process,
  74689. */
  74690. private readonly ChromaticAberrationPostProcessId;
  74691. /**
  74692. * ID of the grain post process
  74693. */
  74694. private readonly GrainPostProcessId;
  74695. /**
  74696. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74697. */
  74698. sharpen: SharpenPostProcess;
  74699. private _sharpenEffect;
  74700. private bloom;
  74701. /**
  74702. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74703. */
  74704. depthOfField: DepthOfFieldEffect;
  74705. /**
  74706. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74707. */
  74708. fxaa: FxaaPostProcess;
  74709. /**
  74710. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74711. */
  74712. imageProcessing: ImageProcessingPostProcess;
  74713. /**
  74714. * Chromatic aberration post process which will shift rgb colors in the image
  74715. */
  74716. chromaticAberration: ChromaticAberrationPostProcess;
  74717. private _chromaticAberrationEffect;
  74718. /**
  74719. * Grain post process which add noise to the image
  74720. */
  74721. grain: GrainPostProcess;
  74722. private _grainEffect;
  74723. /**
  74724. * Glow post process which adds a glow to emissive areas of the image
  74725. */
  74726. private _glowLayer;
  74727. /**
  74728. * Animations which can be used to tweak settings over a period of time
  74729. */
  74730. animations: Animation[];
  74731. private _imageProcessingConfigurationObserver;
  74732. private _sharpenEnabled;
  74733. private _bloomEnabled;
  74734. private _depthOfFieldEnabled;
  74735. private _depthOfFieldBlurLevel;
  74736. private _fxaaEnabled;
  74737. private _imageProcessingEnabled;
  74738. private _defaultPipelineTextureType;
  74739. private _bloomScale;
  74740. private _chromaticAberrationEnabled;
  74741. private _grainEnabled;
  74742. private _buildAllowed;
  74743. /**
  74744. * This is triggered each time the pipeline has been built.
  74745. */
  74746. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74747. /**
  74748. * Gets active scene
  74749. */
  74750. get scene(): Scene;
  74751. /**
  74752. * Enable or disable the sharpen process from the pipeline
  74753. */
  74754. set sharpenEnabled(enabled: boolean);
  74755. get sharpenEnabled(): boolean;
  74756. private _resizeObserver;
  74757. private _hardwareScaleLevel;
  74758. private _bloomKernel;
  74759. /**
  74760. * Specifies the size of the bloom blur kernel, relative to the final output size
  74761. */
  74762. get bloomKernel(): number;
  74763. set bloomKernel(value: number);
  74764. /**
  74765. * Specifies the weight of the bloom in the final rendering
  74766. */
  74767. private _bloomWeight;
  74768. /**
  74769. * Specifies the luma threshold for the area that will be blurred by the bloom
  74770. */
  74771. private _bloomThreshold;
  74772. private _hdr;
  74773. /**
  74774. * The strength of the bloom.
  74775. */
  74776. set bloomWeight(value: number);
  74777. get bloomWeight(): number;
  74778. /**
  74779. * The strength of the bloom.
  74780. */
  74781. set bloomThreshold(value: number);
  74782. get bloomThreshold(): number;
  74783. /**
  74784. * The scale of the bloom, lower value will provide better performance.
  74785. */
  74786. set bloomScale(value: number);
  74787. get bloomScale(): number;
  74788. /**
  74789. * Enable or disable the bloom from the pipeline
  74790. */
  74791. set bloomEnabled(enabled: boolean);
  74792. get bloomEnabled(): boolean;
  74793. private _rebuildBloom;
  74794. /**
  74795. * If the depth of field is enabled.
  74796. */
  74797. get depthOfFieldEnabled(): boolean;
  74798. set depthOfFieldEnabled(enabled: boolean);
  74799. /**
  74800. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74801. */
  74802. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74803. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74804. /**
  74805. * If the anti aliasing is enabled.
  74806. */
  74807. set fxaaEnabled(enabled: boolean);
  74808. get fxaaEnabled(): boolean;
  74809. private _samples;
  74810. /**
  74811. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74812. */
  74813. set samples(sampleCount: number);
  74814. get samples(): number;
  74815. /**
  74816. * If image processing is enabled.
  74817. */
  74818. set imageProcessingEnabled(enabled: boolean);
  74819. get imageProcessingEnabled(): boolean;
  74820. /**
  74821. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74822. */
  74823. set glowLayerEnabled(enabled: boolean);
  74824. get glowLayerEnabled(): boolean;
  74825. /**
  74826. * Gets the glow layer (or null if not defined)
  74827. */
  74828. get glowLayer(): Nullable<GlowLayer>;
  74829. /**
  74830. * Enable or disable the chromaticAberration process from the pipeline
  74831. */
  74832. set chromaticAberrationEnabled(enabled: boolean);
  74833. get chromaticAberrationEnabled(): boolean;
  74834. /**
  74835. * Enable or disable the grain process from the pipeline
  74836. */
  74837. set grainEnabled(enabled: boolean);
  74838. get grainEnabled(): boolean;
  74839. /**
  74840. * @constructor
  74841. * @param name - The rendering pipeline name (default: "")
  74842. * @param hdr - If high dynamic range textures should be used (default: true)
  74843. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74844. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74845. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74846. */
  74847. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74848. /**
  74849. * Get the class name
  74850. * @returns "DefaultRenderingPipeline"
  74851. */
  74852. getClassName(): string;
  74853. /**
  74854. * Force the compilation of the entire pipeline.
  74855. */
  74856. prepare(): void;
  74857. private _hasCleared;
  74858. private _prevPostProcess;
  74859. private _prevPrevPostProcess;
  74860. private _setAutoClearAndTextureSharing;
  74861. private _depthOfFieldSceneObserver;
  74862. private _buildPipeline;
  74863. private _disposePostProcesses;
  74864. /**
  74865. * Adds a camera to the pipeline
  74866. * @param camera the camera to be added
  74867. */
  74868. addCamera(camera: Camera): void;
  74869. /**
  74870. * Removes a camera from the pipeline
  74871. * @param camera the camera to remove
  74872. */
  74873. removeCamera(camera: Camera): void;
  74874. /**
  74875. * Dispose of the pipeline and stop all post processes
  74876. */
  74877. dispose(): void;
  74878. /**
  74879. * Serialize the rendering pipeline (Used when exporting)
  74880. * @returns the serialized object
  74881. */
  74882. serialize(): any;
  74883. /**
  74884. * Parse the serialized pipeline
  74885. * @param source Source pipeline.
  74886. * @param scene The scene to load the pipeline to.
  74887. * @param rootUrl The URL of the serialized pipeline.
  74888. * @returns An instantiated pipeline from the serialized object.
  74889. */
  74890. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74891. }
  74892. }
  74893. declare module BABYLON {
  74894. /** @hidden */
  74895. export var lensHighlightsPixelShader: {
  74896. name: string;
  74897. shader: string;
  74898. };
  74899. }
  74900. declare module BABYLON {
  74901. /** @hidden */
  74902. export var depthOfFieldPixelShader: {
  74903. name: string;
  74904. shader: string;
  74905. };
  74906. }
  74907. declare module BABYLON {
  74908. /**
  74909. * BABYLON.JS Chromatic Aberration GLSL Shader
  74910. * Author: Olivier Guyot
  74911. * Separates very slightly R, G and B colors on the edges of the screen
  74912. * Inspired by Francois Tarlier & Martins Upitis
  74913. */
  74914. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74915. /**
  74916. * @ignore
  74917. * The chromatic aberration PostProcess id in the pipeline
  74918. */
  74919. LensChromaticAberrationEffect: string;
  74920. /**
  74921. * @ignore
  74922. * The highlights enhancing PostProcess id in the pipeline
  74923. */
  74924. HighlightsEnhancingEffect: string;
  74925. /**
  74926. * @ignore
  74927. * The depth-of-field PostProcess id in the pipeline
  74928. */
  74929. LensDepthOfFieldEffect: string;
  74930. private _scene;
  74931. private _depthTexture;
  74932. private _grainTexture;
  74933. private _chromaticAberrationPostProcess;
  74934. private _highlightsPostProcess;
  74935. private _depthOfFieldPostProcess;
  74936. private _edgeBlur;
  74937. private _grainAmount;
  74938. private _chromaticAberration;
  74939. private _distortion;
  74940. private _highlightsGain;
  74941. private _highlightsThreshold;
  74942. private _dofDistance;
  74943. private _dofAperture;
  74944. private _dofDarken;
  74945. private _dofPentagon;
  74946. private _blurNoise;
  74947. /**
  74948. * @constructor
  74949. *
  74950. * Effect parameters are as follow:
  74951. * {
  74952. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74953. * edge_blur: number; // from 0 to x (1 for realism)
  74954. * distortion: number; // from 0 to x (1 for realism)
  74955. * grain_amount: number; // from 0 to 1
  74956. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74957. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74958. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74959. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74960. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74961. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74962. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74963. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74964. * }
  74965. * Note: if an effect parameter is unset, effect is disabled
  74966. *
  74967. * @param name The rendering pipeline name
  74968. * @param parameters - An object containing all parameters (see above)
  74969. * @param scene The scene linked to this pipeline
  74970. * @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)
  74971. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74972. */
  74973. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74974. /**
  74975. * Get the class name
  74976. * @returns "LensRenderingPipeline"
  74977. */
  74978. getClassName(): string;
  74979. /**
  74980. * Gets associated scene
  74981. */
  74982. get scene(): Scene;
  74983. /**
  74984. * Gets or sets the edge blur
  74985. */
  74986. get edgeBlur(): number;
  74987. set edgeBlur(value: number);
  74988. /**
  74989. * Gets or sets the grain amount
  74990. */
  74991. get grainAmount(): number;
  74992. set grainAmount(value: number);
  74993. /**
  74994. * Gets or sets the chromatic aberration amount
  74995. */
  74996. get chromaticAberration(): number;
  74997. set chromaticAberration(value: number);
  74998. /**
  74999. * Gets or sets the depth of field aperture
  75000. */
  75001. get dofAperture(): number;
  75002. set dofAperture(value: number);
  75003. /**
  75004. * Gets or sets the edge distortion
  75005. */
  75006. get edgeDistortion(): number;
  75007. set edgeDistortion(value: number);
  75008. /**
  75009. * Gets or sets the depth of field distortion
  75010. */
  75011. get dofDistortion(): number;
  75012. set dofDistortion(value: number);
  75013. /**
  75014. * Gets or sets the darken out of focus amount
  75015. */
  75016. get darkenOutOfFocus(): number;
  75017. set darkenOutOfFocus(value: number);
  75018. /**
  75019. * Gets or sets a boolean indicating if blur noise is enabled
  75020. */
  75021. get blurNoise(): boolean;
  75022. set blurNoise(value: boolean);
  75023. /**
  75024. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75025. */
  75026. get pentagonBokeh(): boolean;
  75027. set pentagonBokeh(value: boolean);
  75028. /**
  75029. * Gets or sets the highlight grain amount
  75030. */
  75031. get highlightsGain(): number;
  75032. set highlightsGain(value: number);
  75033. /**
  75034. * Gets or sets the highlight threshold
  75035. */
  75036. get highlightsThreshold(): number;
  75037. set highlightsThreshold(value: number);
  75038. /**
  75039. * Sets the amount of blur at the edges
  75040. * @param amount blur amount
  75041. */
  75042. setEdgeBlur(amount: number): void;
  75043. /**
  75044. * Sets edge blur to 0
  75045. */
  75046. disableEdgeBlur(): void;
  75047. /**
  75048. * Sets the amout of grain
  75049. * @param amount Amount of grain
  75050. */
  75051. setGrainAmount(amount: number): void;
  75052. /**
  75053. * Set grain amount to 0
  75054. */
  75055. disableGrain(): void;
  75056. /**
  75057. * Sets the chromatic aberration amount
  75058. * @param amount amount of chromatic aberration
  75059. */
  75060. setChromaticAberration(amount: number): void;
  75061. /**
  75062. * Sets chromatic aberration amount to 0
  75063. */
  75064. disableChromaticAberration(): void;
  75065. /**
  75066. * Sets the EdgeDistortion amount
  75067. * @param amount amount of EdgeDistortion
  75068. */
  75069. setEdgeDistortion(amount: number): void;
  75070. /**
  75071. * Sets edge distortion to 0
  75072. */
  75073. disableEdgeDistortion(): void;
  75074. /**
  75075. * Sets the FocusDistance amount
  75076. * @param amount amount of FocusDistance
  75077. */
  75078. setFocusDistance(amount: number): void;
  75079. /**
  75080. * Disables depth of field
  75081. */
  75082. disableDepthOfField(): void;
  75083. /**
  75084. * Sets the Aperture amount
  75085. * @param amount amount of Aperture
  75086. */
  75087. setAperture(amount: number): void;
  75088. /**
  75089. * Sets the DarkenOutOfFocus amount
  75090. * @param amount amount of DarkenOutOfFocus
  75091. */
  75092. setDarkenOutOfFocus(amount: number): void;
  75093. private _pentagonBokehIsEnabled;
  75094. /**
  75095. * Creates a pentagon bokeh effect
  75096. */
  75097. enablePentagonBokeh(): void;
  75098. /**
  75099. * Disables the pentagon bokeh effect
  75100. */
  75101. disablePentagonBokeh(): void;
  75102. /**
  75103. * Enables noise blur
  75104. */
  75105. enableNoiseBlur(): void;
  75106. /**
  75107. * Disables noise blur
  75108. */
  75109. disableNoiseBlur(): void;
  75110. /**
  75111. * Sets the HighlightsGain amount
  75112. * @param amount amount of HighlightsGain
  75113. */
  75114. setHighlightsGain(amount: number): void;
  75115. /**
  75116. * Sets the HighlightsThreshold amount
  75117. * @param amount amount of HighlightsThreshold
  75118. */
  75119. setHighlightsThreshold(amount: number): void;
  75120. /**
  75121. * Disables highlights
  75122. */
  75123. disableHighlights(): void;
  75124. /**
  75125. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75126. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75127. */
  75128. dispose(disableDepthRender?: boolean): void;
  75129. private _createChromaticAberrationPostProcess;
  75130. private _createHighlightsPostProcess;
  75131. private _createDepthOfFieldPostProcess;
  75132. private _createGrainTexture;
  75133. }
  75134. }
  75135. declare module BABYLON {
  75136. /**
  75137. * Contains all parameters needed for the prepass to perform
  75138. * screen space subsurface scattering
  75139. */
  75140. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75141. /**
  75142. * Is subsurface enabled
  75143. */
  75144. enabled: boolean;
  75145. /**
  75146. * Name of the configuration
  75147. */
  75148. name: string;
  75149. /**
  75150. * Textures that should be present in the MRT for this effect to work
  75151. */
  75152. readonly texturesRequired: number[];
  75153. }
  75154. }
  75155. declare module BABYLON {
  75156. /** @hidden */
  75157. export var ssao2PixelShader: {
  75158. name: string;
  75159. shader: string;
  75160. };
  75161. }
  75162. declare module BABYLON {
  75163. /** @hidden */
  75164. export var ssaoCombinePixelShader: {
  75165. name: string;
  75166. shader: string;
  75167. };
  75168. }
  75169. declare module BABYLON {
  75170. /**
  75171. * Render pipeline to produce ssao effect
  75172. */
  75173. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75174. /**
  75175. * @ignore
  75176. * The PassPostProcess id in the pipeline that contains the original scene color
  75177. */
  75178. SSAOOriginalSceneColorEffect: string;
  75179. /**
  75180. * @ignore
  75181. * The SSAO PostProcess id in the pipeline
  75182. */
  75183. SSAORenderEffect: string;
  75184. /**
  75185. * @ignore
  75186. * The horizontal blur PostProcess id in the pipeline
  75187. */
  75188. SSAOBlurHRenderEffect: string;
  75189. /**
  75190. * @ignore
  75191. * The vertical blur PostProcess id in the pipeline
  75192. */
  75193. SSAOBlurVRenderEffect: string;
  75194. /**
  75195. * @ignore
  75196. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75197. */
  75198. SSAOCombineRenderEffect: string;
  75199. /**
  75200. * The output strength of the SSAO post-process. Default value is 1.0.
  75201. */
  75202. totalStrength: number;
  75203. /**
  75204. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75205. */
  75206. maxZ: number;
  75207. /**
  75208. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75209. */
  75210. minZAspect: number;
  75211. private _samples;
  75212. /**
  75213. * Number of samples used for the SSAO calculations. Default value is 8
  75214. */
  75215. set samples(n: number);
  75216. get samples(): number;
  75217. private _textureSamples;
  75218. /**
  75219. * Number of samples to use for antialiasing
  75220. */
  75221. set textureSamples(n: number);
  75222. get textureSamples(): number;
  75223. /**
  75224. * Force rendering the geometry through geometry buffer
  75225. */
  75226. private _forceGeometryBuffer;
  75227. /**
  75228. * Ratio object used for SSAO ratio and blur ratio
  75229. */
  75230. private _ratio;
  75231. /**
  75232. * Dynamically generated sphere sampler.
  75233. */
  75234. private _sampleSphere;
  75235. /**
  75236. * Blur filter offsets
  75237. */
  75238. private _samplerOffsets;
  75239. private _expensiveBlur;
  75240. /**
  75241. * If bilateral blur should be used
  75242. */
  75243. set expensiveBlur(b: boolean);
  75244. get expensiveBlur(): boolean;
  75245. /**
  75246. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75247. */
  75248. radius: number;
  75249. /**
  75250. * The base color of the SSAO post-process
  75251. * The final result is "base + ssao" between [0, 1]
  75252. */
  75253. base: number;
  75254. /**
  75255. * Support test.
  75256. */
  75257. static get IsSupported(): boolean;
  75258. private _scene;
  75259. private _randomTexture;
  75260. private _originalColorPostProcess;
  75261. private _ssaoPostProcess;
  75262. private _blurHPostProcess;
  75263. private _blurVPostProcess;
  75264. private _ssaoCombinePostProcess;
  75265. private _prePassRenderer;
  75266. /**
  75267. * Gets active scene
  75268. */
  75269. get scene(): Scene;
  75270. /**
  75271. * @constructor
  75272. * @param name The rendering pipeline name
  75273. * @param scene The scene linked to this pipeline
  75274. * @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 }
  75275. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75276. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75277. */
  75278. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75279. /**
  75280. * Get the class name
  75281. * @returns "SSAO2RenderingPipeline"
  75282. */
  75283. getClassName(): string;
  75284. /**
  75285. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75286. */
  75287. dispose(disableGeometryBufferRenderer?: boolean): void;
  75288. private _createBlurPostProcess;
  75289. /** @hidden */
  75290. _rebuild(): void;
  75291. private _bits;
  75292. private _radicalInverse_VdC;
  75293. private _hammersley;
  75294. private _hemisphereSample_uniform;
  75295. private _generateHemisphere;
  75296. private _getDefinesForSSAO;
  75297. private static readonly ORTHO_DEPTH_PROJECTION;
  75298. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75299. private _createSSAOPostProcess;
  75300. private _createSSAOCombinePostProcess;
  75301. private _createRandomTexture;
  75302. /**
  75303. * Serialize the rendering pipeline (Used when exporting)
  75304. * @returns the serialized object
  75305. */
  75306. serialize(): any;
  75307. /**
  75308. * Parse the serialized pipeline
  75309. * @param source Source pipeline.
  75310. * @param scene The scene to load the pipeline to.
  75311. * @param rootUrl The URL of the serialized pipeline.
  75312. * @returns An instantiated pipeline from the serialized object.
  75313. */
  75314. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75315. }
  75316. }
  75317. declare module BABYLON {
  75318. /** @hidden */
  75319. export var ssaoPixelShader: {
  75320. name: string;
  75321. shader: string;
  75322. };
  75323. }
  75324. declare module BABYLON {
  75325. /**
  75326. * Render pipeline to produce ssao effect
  75327. */
  75328. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75329. /**
  75330. * @ignore
  75331. * The PassPostProcess id in the pipeline that contains the original scene color
  75332. */
  75333. SSAOOriginalSceneColorEffect: string;
  75334. /**
  75335. * @ignore
  75336. * The SSAO PostProcess id in the pipeline
  75337. */
  75338. SSAORenderEffect: string;
  75339. /**
  75340. * @ignore
  75341. * The horizontal blur PostProcess id in the pipeline
  75342. */
  75343. SSAOBlurHRenderEffect: string;
  75344. /**
  75345. * @ignore
  75346. * The vertical blur PostProcess id in the pipeline
  75347. */
  75348. SSAOBlurVRenderEffect: string;
  75349. /**
  75350. * @ignore
  75351. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75352. */
  75353. SSAOCombineRenderEffect: string;
  75354. /**
  75355. * The output strength of the SSAO post-process. Default value is 1.0.
  75356. */
  75357. totalStrength: number;
  75358. /**
  75359. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75360. */
  75361. radius: number;
  75362. /**
  75363. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75364. * Must not be equal to fallOff and superior to fallOff.
  75365. * Default value is 0.0075
  75366. */
  75367. area: number;
  75368. /**
  75369. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75370. * Must not be equal to area and inferior to area.
  75371. * Default value is 0.000001
  75372. */
  75373. fallOff: number;
  75374. /**
  75375. * The base color of the SSAO post-process
  75376. * The final result is "base + ssao" between [0, 1]
  75377. */
  75378. base: number;
  75379. private _scene;
  75380. private _depthTexture;
  75381. private _randomTexture;
  75382. private _originalColorPostProcess;
  75383. private _ssaoPostProcess;
  75384. private _blurHPostProcess;
  75385. private _blurVPostProcess;
  75386. private _ssaoCombinePostProcess;
  75387. private _firstUpdate;
  75388. /**
  75389. * Gets active scene
  75390. */
  75391. get scene(): Scene;
  75392. /**
  75393. * @constructor
  75394. * @param name - The rendering pipeline name
  75395. * @param scene - The scene linked to this pipeline
  75396. * @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 }
  75397. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75398. */
  75399. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75400. /**
  75401. * Get the class name
  75402. * @returns "SSAORenderingPipeline"
  75403. */
  75404. getClassName(): string;
  75405. /**
  75406. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75407. */
  75408. dispose(disableDepthRender?: boolean): void;
  75409. private _createBlurPostProcess;
  75410. /** @hidden */
  75411. _rebuild(): void;
  75412. private _createSSAOPostProcess;
  75413. private _createSSAOCombinePostProcess;
  75414. private _createRandomTexture;
  75415. }
  75416. }
  75417. declare module BABYLON {
  75418. /**
  75419. * Contains all parameters needed for the prepass to perform
  75420. * screen space reflections
  75421. */
  75422. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75423. /**
  75424. * Is ssr enabled
  75425. */
  75426. enabled: boolean;
  75427. /**
  75428. * Name of the configuration
  75429. */
  75430. name: string;
  75431. /**
  75432. * Textures that should be present in the MRT for this effect to work
  75433. */
  75434. readonly texturesRequired: number[];
  75435. }
  75436. }
  75437. declare module BABYLON {
  75438. /** @hidden */
  75439. export var screenSpaceReflectionPixelShader: {
  75440. name: string;
  75441. shader: string;
  75442. };
  75443. }
  75444. declare module BABYLON {
  75445. /**
  75446. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75447. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75448. */
  75449. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75450. /**
  75451. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75452. */
  75453. threshold: number;
  75454. /**
  75455. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75456. */
  75457. strength: number;
  75458. /**
  75459. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75460. */
  75461. reflectionSpecularFalloffExponent: number;
  75462. /**
  75463. * 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]
  75464. */
  75465. step: number;
  75466. /**
  75467. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75468. */
  75469. roughnessFactor: number;
  75470. private _forceGeometryBuffer;
  75471. private _geometryBufferRenderer;
  75472. private _prePassRenderer;
  75473. private _enableSmoothReflections;
  75474. private _reflectionSamples;
  75475. private _smoothSteps;
  75476. /**
  75477. * Gets a string identifying the name of the class
  75478. * @returns "ScreenSpaceReflectionPostProcess" string
  75479. */
  75480. getClassName(): string;
  75481. /**
  75482. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75483. * @param name The name of the effect.
  75484. * @param scene The scene containing the objects to calculate reflections.
  75485. * @param options The required width/height ratio to downsize to before computing the render pass.
  75486. * @param camera The camera to apply the render pass to.
  75487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75488. * @param engine The engine which the post process will be applied. (default: current engine)
  75489. * @param reusable If the post process can be reused on the same frame. (default: false)
  75490. * @param textureType Type of textures used when performing the post process. (default: 0)
  75491. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  75492. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75493. */
  75494. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75495. /**
  75496. * Gets wether or not smoothing reflections is enabled.
  75497. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75498. */
  75499. get enableSmoothReflections(): boolean;
  75500. /**
  75501. * Sets wether or not smoothing reflections is enabled.
  75502. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75503. */
  75504. set enableSmoothReflections(enabled: boolean);
  75505. /**
  75506. * Gets the number of samples taken while computing reflections. More samples count is high,
  75507. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75508. */
  75509. get reflectionSamples(): number;
  75510. /**
  75511. * Sets the number of samples taken while computing reflections. More samples count is high,
  75512. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75513. */
  75514. set reflectionSamples(samples: number);
  75515. /**
  75516. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75517. * more the post-process will require GPU power and can generate a drop in FPS.
  75518. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75519. */
  75520. get smoothSteps(): number;
  75521. set smoothSteps(steps: number);
  75522. private _updateEffectDefines;
  75523. /** @hidden */
  75524. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75525. }
  75526. }
  75527. declare module BABYLON {
  75528. /** @hidden */
  75529. export var standardPixelShader: {
  75530. name: string;
  75531. shader: string;
  75532. };
  75533. }
  75534. declare module BABYLON {
  75535. /**
  75536. * Standard rendering pipeline
  75537. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75538. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75539. */
  75540. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75541. /**
  75542. * Public members
  75543. */
  75544. /**
  75545. * Post-process which contains the original scene color before the pipeline applies all the effects
  75546. */
  75547. originalPostProcess: Nullable<PostProcess>;
  75548. /**
  75549. * Post-process used to down scale an image x4
  75550. */
  75551. downSampleX4PostProcess: Nullable<PostProcess>;
  75552. /**
  75553. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75554. */
  75555. brightPassPostProcess: Nullable<PostProcess>;
  75556. /**
  75557. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75558. */
  75559. blurHPostProcesses: PostProcess[];
  75560. /**
  75561. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75562. */
  75563. blurVPostProcesses: PostProcess[];
  75564. /**
  75565. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75566. */
  75567. textureAdderPostProcess: Nullable<PostProcess>;
  75568. /**
  75569. * Post-process used to create volumetric lighting effect
  75570. */
  75571. volumetricLightPostProcess: Nullable<PostProcess>;
  75572. /**
  75573. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75574. */
  75575. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75576. /**
  75577. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75578. */
  75579. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75580. /**
  75581. * Post-process used to merge the volumetric light effect and the real scene color
  75582. */
  75583. volumetricLightMergePostProces: Nullable<PostProcess>;
  75584. /**
  75585. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75586. */
  75587. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75588. /**
  75589. * Base post-process used to calculate the average luminance of the final image for HDR
  75590. */
  75591. luminancePostProcess: Nullable<PostProcess>;
  75592. /**
  75593. * Post-processes used to create down sample post-processes in order to get
  75594. * the average luminance of the final image for HDR
  75595. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75596. */
  75597. luminanceDownSamplePostProcesses: PostProcess[];
  75598. /**
  75599. * Post-process used to create a HDR effect (light adaptation)
  75600. */
  75601. hdrPostProcess: Nullable<PostProcess>;
  75602. /**
  75603. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75604. */
  75605. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75606. /**
  75607. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75608. */
  75609. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75610. /**
  75611. * Post-process used to merge the final HDR post-process and the real scene color
  75612. */
  75613. hdrFinalPostProcess: Nullable<PostProcess>;
  75614. /**
  75615. * Post-process used to create a lens flare effect
  75616. */
  75617. lensFlarePostProcess: Nullable<PostProcess>;
  75618. /**
  75619. * Post-process that merges the result of the lens flare post-process and the real scene color
  75620. */
  75621. lensFlareComposePostProcess: Nullable<PostProcess>;
  75622. /**
  75623. * Post-process used to create a motion blur effect
  75624. */
  75625. motionBlurPostProcess: Nullable<PostProcess>;
  75626. /**
  75627. * Post-process used to create a depth of field effect
  75628. */
  75629. depthOfFieldPostProcess: Nullable<PostProcess>;
  75630. /**
  75631. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75632. */
  75633. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75634. /**
  75635. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75636. */
  75637. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75638. /**
  75639. * Represents the brightness threshold in order to configure the illuminated surfaces
  75640. */
  75641. brightThreshold: number;
  75642. /**
  75643. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75644. */
  75645. blurWidth: number;
  75646. /**
  75647. * Sets if the blur for highlighted surfaces must be only horizontal
  75648. */
  75649. horizontalBlur: boolean;
  75650. /**
  75651. * Gets the overall exposure used by the pipeline
  75652. */
  75653. get exposure(): number;
  75654. /**
  75655. * Sets the overall exposure used by the pipeline
  75656. */
  75657. set exposure(value: number);
  75658. /**
  75659. * Texture used typically to simulate "dirty" on camera lens
  75660. */
  75661. lensTexture: Nullable<Texture>;
  75662. /**
  75663. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75664. */
  75665. volumetricLightCoefficient: number;
  75666. /**
  75667. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75668. */
  75669. volumetricLightPower: number;
  75670. /**
  75671. * Used the set the blur intensity to smooth the volumetric lights
  75672. */
  75673. volumetricLightBlurScale: number;
  75674. /**
  75675. * Light (spot or directional) used to generate the volumetric lights rays
  75676. * The source light must have a shadow generate so the pipeline can get its
  75677. * depth map
  75678. */
  75679. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75680. /**
  75681. * For eye adaptation, represents the minimum luminance the eye can see
  75682. */
  75683. hdrMinimumLuminance: number;
  75684. /**
  75685. * For eye adaptation, represents the decrease luminance speed
  75686. */
  75687. hdrDecreaseRate: number;
  75688. /**
  75689. * For eye adaptation, represents the increase luminance speed
  75690. */
  75691. hdrIncreaseRate: number;
  75692. /**
  75693. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75694. */
  75695. get hdrAutoExposure(): boolean;
  75696. /**
  75697. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75698. */
  75699. set hdrAutoExposure(value: boolean);
  75700. /**
  75701. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75702. */
  75703. lensColorTexture: Nullable<Texture>;
  75704. /**
  75705. * The overall strengh for the lens flare effect
  75706. */
  75707. lensFlareStrength: number;
  75708. /**
  75709. * Dispersion coefficient for lens flare ghosts
  75710. */
  75711. lensFlareGhostDispersal: number;
  75712. /**
  75713. * Main lens flare halo width
  75714. */
  75715. lensFlareHaloWidth: number;
  75716. /**
  75717. * Based on the lens distortion effect, defines how much the lens flare result
  75718. * is distorted
  75719. */
  75720. lensFlareDistortionStrength: number;
  75721. /**
  75722. * Configures the blur intensity used for for lens flare (halo)
  75723. */
  75724. lensFlareBlurWidth: number;
  75725. /**
  75726. * Lens star texture must be used to simulate rays on the flares and is available
  75727. * in the documentation
  75728. */
  75729. lensStarTexture: Nullable<Texture>;
  75730. /**
  75731. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75732. * flare effect by taking account of the dirt texture
  75733. */
  75734. lensFlareDirtTexture: Nullable<Texture>;
  75735. /**
  75736. * Represents the focal length for the depth of field effect
  75737. */
  75738. depthOfFieldDistance: number;
  75739. /**
  75740. * Represents the blur intensity for the blurred part of the depth of field effect
  75741. */
  75742. depthOfFieldBlurWidth: number;
  75743. /**
  75744. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75745. */
  75746. get motionStrength(): number;
  75747. /**
  75748. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75749. */
  75750. set motionStrength(strength: number);
  75751. /**
  75752. * Gets wether or not the motion blur post-process is object based or screen based.
  75753. */
  75754. get objectBasedMotionBlur(): boolean;
  75755. /**
  75756. * Sets wether or not the motion blur post-process should be object based or screen based
  75757. */
  75758. set objectBasedMotionBlur(value: boolean);
  75759. /**
  75760. * List of animations for the pipeline (IAnimatable implementation)
  75761. */
  75762. animations: Animation[];
  75763. /**
  75764. * Private members
  75765. */
  75766. private _scene;
  75767. private _currentDepthOfFieldSource;
  75768. private _basePostProcess;
  75769. private _fixedExposure;
  75770. private _currentExposure;
  75771. private _hdrAutoExposure;
  75772. private _hdrCurrentLuminance;
  75773. private _motionStrength;
  75774. private _isObjectBasedMotionBlur;
  75775. private _floatTextureType;
  75776. private _camerasToBeAttached;
  75777. private _ratio;
  75778. private _bloomEnabled;
  75779. private _depthOfFieldEnabled;
  75780. private _vlsEnabled;
  75781. private _lensFlareEnabled;
  75782. private _hdrEnabled;
  75783. private _motionBlurEnabled;
  75784. private _fxaaEnabled;
  75785. private _screenSpaceReflectionsEnabled;
  75786. private _motionBlurSamples;
  75787. private _volumetricLightStepsCount;
  75788. private _samples;
  75789. /**
  75790. * @ignore
  75791. * Specifies if the bloom pipeline is enabled
  75792. */
  75793. get BloomEnabled(): boolean;
  75794. set BloomEnabled(enabled: boolean);
  75795. /**
  75796. * @ignore
  75797. * Specifies if the depth of field pipeline is enabed
  75798. */
  75799. get DepthOfFieldEnabled(): boolean;
  75800. set DepthOfFieldEnabled(enabled: boolean);
  75801. /**
  75802. * @ignore
  75803. * Specifies if the lens flare pipeline is enabed
  75804. */
  75805. get LensFlareEnabled(): boolean;
  75806. set LensFlareEnabled(enabled: boolean);
  75807. /**
  75808. * @ignore
  75809. * Specifies if the HDR pipeline is enabled
  75810. */
  75811. get HDREnabled(): boolean;
  75812. set HDREnabled(enabled: boolean);
  75813. /**
  75814. * @ignore
  75815. * Specifies if the volumetric lights scattering effect is enabled
  75816. */
  75817. get VLSEnabled(): boolean;
  75818. set VLSEnabled(enabled: boolean);
  75819. /**
  75820. * @ignore
  75821. * Specifies if the motion blur effect is enabled
  75822. */
  75823. get MotionBlurEnabled(): boolean;
  75824. set MotionBlurEnabled(enabled: boolean);
  75825. /**
  75826. * Specifies if anti-aliasing is enabled
  75827. */
  75828. get fxaaEnabled(): boolean;
  75829. set fxaaEnabled(enabled: boolean);
  75830. /**
  75831. * Specifies if screen space reflections are enabled.
  75832. */
  75833. get screenSpaceReflectionsEnabled(): boolean;
  75834. set screenSpaceReflectionsEnabled(enabled: boolean);
  75835. /**
  75836. * Specifies the number of steps used to calculate the volumetric lights
  75837. * Typically in interval [50, 200]
  75838. */
  75839. get volumetricLightStepsCount(): number;
  75840. set volumetricLightStepsCount(count: number);
  75841. /**
  75842. * Specifies the number of samples used for the motion blur effect
  75843. * Typically in interval [16, 64]
  75844. */
  75845. get motionBlurSamples(): number;
  75846. set motionBlurSamples(samples: number);
  75847. /**
  75848. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75849. */
  75850. get samples(): number;
  75851. set samples(sampleCount: number);
  75852. /**
  75853. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75854. * @constructor
  75855. * @param name The rendering pipeline name
  75856. * @param scene The scene linked to this pipeline
  75857. * @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)
  75858. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75859. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75860. */
  75861. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75862. private _buildPipeline;
  75863. private _createDownSampleX4PostProcess;
  75864. private _createBrightPassPostProcess;
  75865. private _createBlurPostProcesses;
  75866. private _createTextureAdderPostProcess;
  75867. private _createVolumetricLightPostProcess;
  75868. private _createLuminancePostProcesses;
  75869. private _createHdrPostProcess;
  75870. private _createLensFlarePostProcess;
  75871. private _createDepthOfFieldPostProcess;
  75872. private _createMotionBlurPostProcess;
  75873. private _getDepthTexture;
  75874. private _disposePostProcesses;
  75875. /**
  75876. * Dispose of the pipeline and stop all post processes
  75877. */
  75878. dispose(): void;
  75879. /**
  75880. * Serialize the rendering pipeline (Used when exporting)
  75881. * @returns the serialized object
  75882. */
  75883. serialize(): any;
  75884. /**
  75885. * Parse the serialized pipeline
  75886. * @param source Source pipeline.
  75887. * @param scene The scene to load the pipeline to.
  75888. * @param rootUrl The URL of the serialized pipeline.
  75889. * @returns An instantiated pipeline from the serialized object.
  75890. */
  75891. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75892. /**
  75893. * Luminance steps
  75894. */
  75895. static LuminanceSteps: number;
  75896. }
  75897. }
  75898. declare module BABYLON {
  75899. /** @hidden */
  75900. export var tonemapPixelShader: {
  75901. name: string;
  75902. shader: string;
  75903. };
  75904. }
  75905. declare module BABYLON {
  75906. /** Defines operator used for tonemapping */
  75907. export enum TonemappingOperator {
  75908. /** Hable */
  75909. Hable = 0,
  75910. /** Reinhard */
  75911. Reinhard = 1,
  75912. /** HejiDawson */
  75913. HejiDawson = 2,
  75914. /** Photographic */
  75915. Photographic = 3
  75916. }
  75917. /**
  75918. * Defines a post process to apply tone mapping
  75919. */
  75920. export class TonemapPostProcess extends PostProcess {
  75921. private _operator;
  75922. /** Defines the required exposure adjustement */
  75923. exposureAdjustment: number;
  75924. /**
  75925. * Gets a string identifying the name of the class
  75926. * @returns "TonemapPostProcess" string
  75927. */
  75928. getClassName(): string;
  75929. /**
  75930. * Creates a new TonemapPostProcess
  75931. * @param name defines the name of the postprocess
  75932. * @param _operator defines the operator to use
  75933. * @param exposureAdjustment defines the required exposure adjustement
  75934. * @param camera defines the camera to use (can be null)
  75935. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75936. * @param engine defines the hosting engine (can be ignore if camera is set)
  75937. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75938. */
  75939. constructor(name: string, _operator: TonemappingOperator,
  75940. /** Defines the required exposure adjustement */
  75941. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75942. }
  75943. }
  75944. declare module BABYLON {
  75945. /** @hidden */
  75946. export var volumetricLightScatteringPixelShader: {
  75947. name: string;
  75948. shader: string;
  75949. };
  75950. }
  75951. declare module BABYLON {
  75952. /** @hidden */
  75953. export var volumetricLightScatteringPassVertexShader: {
  75954. name: string;
  75955. shader: string;
  75956. };
  75957. }
  75958. declare module BABYLON {
  75959. /** @hidden */
  75960. export var volumetricLightScatteringPassPixelShader: {
  75961. name: string;
  75962. shader: string;
  75963. };
  75964. }
  75965. declare module BABYLON {
  75966. /**
  75967. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75968. */
  75969. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75970. private _volumetricLightScatteringPass;
  75971. private _volumetricLightScatteringRTT;
  75972. private _viewPort;
  75973. private _screenCoordinates;
  75974. private _cachedDefines;
  75975. /**
  75976. * If not undefined, the mesh position is computed from the attached node position
  75977. */
  75978. attachedNode: {
  75979. position: Vector3;
  75980. };
  75981. /**
  75982. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75983. */
  75984. customMeshPosition: Vector3;
  75985. /**
  75986. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75987. */
  75988. useCustomMeshPosition: boolean;
  75989. /**
  75990. * If the post-process should inverse the light scattering direction
  75991. */
  75992. invert: boolean;
  75993. /**
  75994. * The internal mesh used by the post-process
  75995. */
  75996. mesh: Mesh;
  75997. /**
  75998. * @hidden
  75999. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76000. */
  76001. get useDiffuseColor(): boolean;
  76002. set useDiffuseColor(useDiffuseColor: boolean);
  76003. /**
  76004. * Array containing the excluded meshes not rendered in the internal pass
  76005. */
  76006. excludedMeshes: AbstractMesh[];
  76007. /**
  76008. * Controls the overall intensity of the post-process
  76009. */
  76010. exposure: number;
  76011. /**
  76012. * Dissipates each sample's contribution in range [0, 1]
  76013. */
  76014. decay: number;
  76015. /**
  76016. * Controls the overall intensity of each sample
  76017. */
  76018. weight: number;
  76019. /**
  76020. * Controls the density of each sample
  76021. */
  76022. density: number;
  76023. /**
  76024. * @constructor
  76025. * @param name The post-process name
  76026. * @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)
  76027. * @param camera The camera that the post-process will be attached to
  76028. * @param mesh The mesh used to create the light scattering
  76029. * @param samples The post-process quality, default 100
  76030. * @param samplingModeThe post-process filtering mode
  76031. * @param engine The babylon engine
  76032. * @param reusable If the post-process is reusable
  76033. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76034. */
  76035. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76036. /**
  76037. * Returns the string "VolumetricLightScatteringPostProcess"
  76038. * @returns "VolumetricLightScatteringPostProcess"
  76039. */
  76040. getClassName(): string;
  76041. private _isReady;
  76042. /**
  76043. * Sets the new light position for light scattering effect
  76044. * @param position The new custom light position
  76045. */
  76046. setCustomMeshPosition(position: Vector3): void;
  76047. /**
  76048. * Returns the light position for light scattering effect
  76049. * @return Vector3 The custom light position
  76050. */
  76051. getCustomMeshPosition(): Vector3;
  76052. /**
  76053. * Disposes the internal assets and detaches the post-process from the camera
  76054. */
  76055. dispose(camera: Camera): void;
  76056. /**
  76057. * Returns the render target texture used by the post-process
  76058. * @return the render target texture used by the post-process
  76059. */
  76060. getPass(): RenderTargetTexture;
  76061. private _meshExcluded;
  76062. private _createPass;
  76063. private _updateMeshScreenCoordinates;
  76064. /**
  76065. * Creates a default mesh for the Volumeric Light Scattering post-process
  76066. * @param name The mesh name
  76067. * @param scene The scene where to create the mesh
  76068. * @return the default mesh
  76069. */
  76070. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76071. }
  76072. }
  76073. declare module BABYLON {
  76074. /** @hidden */
  76075. export var screenSpaceCurvaturePixelShader: {
  76076. name: string;
  76077. shader: string;
  76078. };
  76079. }
  76080. declare module BABYLON {
  76081. /**
  76082. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76083. */
  76084. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76085. /**
  76086. * Defines how much ridge the curvature effect displays.
  76087. */
  76088. ridge: number;
  76089. /**
  76090. * Defines how much valley the curvature effect displays.
  76091. */
  76092. valley: number;
  76093. private _geometryBufferRenderer;
  76094. /**
  76095. * Gets a string identifying the name of the class
  76096. * @returns "ScreenSpaceCurvaturePostProcess" string
  76097. */
  76098. getClassName(): string;
  76099. /**
  76100. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76101. * @param name The name of the effect.
  76102. * @param scene The scene containing the objects to blur according to their velocity.
  76103. * @param options The required width/height ratio to downsize to before computing the render pass.
  76104. * @param camera The camera to apply the render pass to.
  76105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76106. * @param engine The engine which the post process will be applied. (default: current engine)
  76107. * @param reusable If the post process can be reused on the same frame. (default: false)
  76108. * @param textureType Type of textures used when performing the post process. (default: 0)
  76109. * @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)
  76110. */
  76111. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76112. /**
  76113. * Support test.
  76114. */
  76115. static get IsSupported(): boolean;
  76116. /** @hidden */
  76117. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76118. }
  76119. }
  76120. declare module BABYLON {
  76121. interface Scene {
  76122. /** @hidden (Backing field) */
  76123. _boundingBoxRenderer: BoundingBoxRenderer;
  76124. /** @hidden (Backing field) */
  76125. _forceShowBoundingBoxes: boolean;
  76126. /**
  76127. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76128. */
  76129. forceShowBoundingBoxes: boolean;
  76130. /**
  76131. * Gets the bounding box renderer associated with the scene
  76132. * @returns a BoundingBoxRenderer
  76133. */
  76134. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76135. }
  76136. interface AbstractMesh {
  76137. /** @hidden (Backing field) */
  76138. _showBoundingBox: boolean;
  76139. /**
  76140. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76141. */
  76142. showBoundingBox: boolean;
  76143. }
  76144. /**
  76145. * Component responsible of rendering the bounding box of the meshes in a scene.
  76146. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76147. */
  76148. export class BoundingBoxRenderer implements ISceneComponent {
  76149. /**
  76150. * The component name helpfull to identify the component in the list of scene components.
  76151. */
  76152. readonly name: string;
  76153. /**
  76154. * The scene the component belongs to.
  76155. */
  76156. scene: Scene;
  76157. /**
  76158. * Color of the bounding box lines placed in front of an object
  76159. */
  76160. frontColor: Color3;
  76161. /**
  76162. * Color of the bounding box lines placed behind an object
  76163. */
  76164. backColor: Color3;
  76165. /**
  76166. * Defines if the renderer should show the back lines or not
  76167. */
  76168. showBackLines: boolean;
  76169. /**
  76170. * Observable raised before rendering a bounding box
  76171. */
  76172. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76173. /**
  76174. * Observable raised after rendering a bounding box
  76175. */
  76176. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76177. /**
  76178. * Observable raised after resources are created
  76179. */
  76180. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76181. /**
  76182. * When false, no bounding boxes will be rendered
  76183. */
  76184. enabled: boolean;
  76185. /**
  76186. * @hidden
  76187. */
  76188. renderList: SmartArray<BoundingBox>;
  76189. private _colorShader;
  76190. private _vertexBuffers;
  76191. private _indexBuffer;
  76192. private _fillIndexBuffer;
  76193. private _fillIndexData;
  76194. /**
  76195. * Instantiates a new bounding box renderer in a scene.
  76196. * @param scene the scene the renderer renders in
  76197. */
  76198. constructor(scene: Scene);
  76199. /**
  76200. * Registers the component in a given scene
  76201. */
  76202. register(): void;
  76203. private _evaluateSubMesh;
  76204. private _preActiveMesh;
  76205. private _prepareResources;
  76206. private _createIndexBuffer;
  76207. /**
  76208. * Rebuilds the elements related to this component in case of
  76209. * context lost for instance.
  76210. */
  76211. rebuild(): void;
  76212. /**
  76213. * @hidden
  76214. */
  76215. reset(): void;
  76216. /**
  76217. * Render the bounding boxes of a specific rendering group
  76218. * @param renderingGroupId defines the rendering group to render
  76219. */
  76220. render(renderingGroupId: number): void;
  76221. /**
  76222. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76223. * @param mesh Define the mesh to render the occlusion bounding box for
  76224. */
  76225. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76226. /**
  76227. * Dispose and release the resources attached to this renderer.
  76228. */
  76229. dispose(): void;
  76230. }
  76231. }
  76232. declare module BABYLON {
  76233. interface Scene {
  76234. /** @hidden (Backing field) */
  76235. _depthRenderer: {
  76236. [id: string]: DepthRenderer;
  76237. };
  76238. /**
  76239. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76240. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76241. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76242. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76243. * @returns the created depth renderer
  76244. */
  76245. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76246. /**
  76247. * Disables a depth renderer for a given camera
  76248. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76249. */
  76250. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76251. }
  76252. /**
  76253. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76254. * in several rendering techniques.
  76255. */
  76256. export class DepthRendererSceneComponent implements ISceneComponent {
  76257. /**
  76258. * The component name helpfull to identify the component in the list of scene components.
  76259. */
  76260. readonly name: string;
  76261. /**
  76262. * The scene the component belongs to.
  76263. */
  76264. scene: Scene;
  76265. /**
  76266. * Creates a new instance of the component for the given scene
  76267. * @param scene Defines the scene to register the component in
  76268. */
  76269. constructor(scene: Scene);
  76270. /**
  76271. * Registers the component in a given scene
  76272. */
  76273. register(): void;
  76274. /**
  76275. * Rebuilds the elements related to this component in case of
  76276. * context lost for instance.
  76277. */
  76278. rebuild(): void;
  76279. /**
  76280. * Disposes the component and the associated ressources
  76281. */
  76282. dispose(): void;
  76283. private _gatherRenderTargets;
  76284. private _gatherActiveCameraRenderTargets;
  76285. }
  76286. }
  76287. declare module BABYLON {
  76288. interface AbstractScene {
  76289. /** @hidden (Backing field) */
  76290. _prePassRenderer: Nullable<PrePassRenderer>;
  76291. /**
  76292. * Gets or Sets the current prepass renderer associated to the scene.
  76293. */
  76294. prePassRenderer: Nullable<PrePassRenderer>;
  76295. /**
  76296. * Enables the prepass and associates it with the scene
  76297. * @returns the PrePassRenderer
  76298. */
  76299. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76300. /**
  76301. * Disables the prepass associated with the scene
  76302. */
  76303. disablePrePassRenderer(): void;
  76304. }
  76305. /**
  76306. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76307. * in several rendering techniques.
  76308. */
  76309. export class PrePassRendererSceneComponent implements ISceneComponent {
  76310. /**
  76311. * The component name helpful to identify the component in the list of scene components.
  76312. */
  76313. readonly name: string;
  76314. /**
  76315. * The scene the component belongs to.
  76316. */
  76317. scene: Scene;
  76318. /**
  76319. * Creates a new instance of the component for the given scene
  76320. * @param scene Defines the scene to register the component in
  76321. */
  76322. constructor(scene: Scene);
  76323. /**
  76324. * Registers the component in a given scene
  76325. */
  76326. register(): void;
  76327. private _beforeCameraDraw;
  76328. private _afterCameraDraw;
  76329. private _beforeClearStage;
  76330. private _beforeRenderingMeshStage;
  76331. private _afterRenderingMeshStage;
  76332. /**
  76333. * Rebuilds the elements related to this component in case of
  76334. * context lost for instance.
  76335. */
  76336. rebuild(): void;
  76337. /**
  76338. * Disposes the component and the associated ressources
  76339. */
  76340. dispose(): void;
  76341. }
  76342. }
  76343. declare module BABYLON {
  76344. /** @hidden */
  76345. export var fibonacci: {
  76346. name: string;
  76347. shader: string;
  76348. };
  76349. }
  76350. declare module BABYLON {
  76351. /** @hidden */
  76352. export var diffusionProfile: {
  76353. name: string;
  76354. shader: string;
  76355. };
  76356. }
  76357. declare module BABYLON {
  76358. /** @hidden */
  76359. export var subSurfaceScatteringPixelShader: {
  76360. name: string;
  76361. shader: string;
  76362. };
  76363. }
  76364. declare module BABYLON {
  76365. /**
  76366. * Sub surface scattering post process
  76367. */
  76368. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76369. /**
  76370. * Gets a string identifying the name of the class
  76371. * @returns "SubSurfaceScatteringPostProcess" string
  76372. */
  76373. getClassName(): string;
  76374. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76375. }
  76376. }
  76377. declare module BABYLON {
  76378. /**
  76379. * Contains all parameters needed for the prepass to perform
  76380. * screen space subsurface scattering
  76381. */
  76382. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76383. /** @hidden */
  76384. static _SceneComponentInitialization: (scene: Scene) => void;
  76385. private _ssDiffusionS;
  76386. private _ssFilterRadii;
  76387. private _ssDiffusionD;
  76388. /**
  76389. * Post process to attach for screen space subsurface scattering
  76390. */
  76391. postProcess: SubSurfaceScatteringPostProcess;
  76392. /**
  76393. * Diffusion profile color for subsurface scattering
  76394. */
  76395. get ssDiffusionS(): number[];
  76396. /**
  76397. * Diffusion profile max color channel value for subsurface scattering
  76398. */
  76399. get ssDiffusionD(): number[];
  76400. /**
  76401. * Diffusion profile filter radius for subsurface scattering
  76402. */
  76403. get ssFilterRadii(): number[];
  76404. /**
  76405. * Is subsurface enabled
  76406. */
  76407. enabled: boolean;
  76408. /**
  76409. * Name of the configuration
  76410. */
  76411. name: string;
  76412. /**
  76413. * Diffusion profile colors for subsurface scattering
  76414. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76415. * See ...
  76416. * Note that you can only store up to 5 of them
  76417. */
  76418. ssDiffusionProfileColors: Color3[];
  76419. /**
  76420. * Defines the ratio real world => scene units.
  76421. * Used for subsurface scattering
  76422. */
  76423. metersPerUnit: number;
  76424. /**
  76425. * Textures that should be present in the MRT for this effect to work
  76426. */
  76427. readonly texturesRequired: number[];
  76428. private _scene;
  76429. /**
  76430. * Builds a subsurface configuration object
  76431. * @param scene The scene
  76432. */
  76433. constructor(scene: Scene);
  76434. /**
  76435. * Adds a new diffusion profile.
  76436. * Useful for more realistic subsurface scattering on diverse materials.
  76437. * @param color The color of the diffusion profile. Should be the average color of the material.
  76438. * @return The index of the diffusion profile for the material subsurface configuration
  76439. */
  76440. addDiffusionProfile(color: Color3): number;
  76441. /**
  76442. * Creates the sss post process
  76443. * @return The created post process
  76444. */
  76445. createPostProcess(): SubSurfaceScatteringPostProcess;
  76446. /**
  76447. * Deletes all diffusion profiles.
  76448. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76449. */
  76450. clearAllDiffusionProfiles(): void;
  76451. /**
  76452. * Disposes this object
  76453. */
  76454. dispose(): void;
  76455. /**
  76456. * @hidden
  76457. * https://zero-radiance.github.io/post/sampling-diffusion/
  76458. *
  76459. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76460. * ------------------------------------------------------------------------------------
  76461. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76462. * PDF[r, phi, s] = r * R[r, phi, s]
  76463. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76464. * ------------------------------------------------------------------------------------
  76465. * We importance sample the color channel with the widest scattering distance.
  76466. */
  76467. getDiffusionProfileParameters(color: Color3): number;
  76468. /**
  76469. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76470. * 'u' is the random number (the value of the CDF): [0, 1).
  76471. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76472. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76473. */
  76474. private _sampleBurleyDiffusionProfile;
  76475. }
  76476. }
  76477. declare module BABYLON {
  76478. interface AbstractScene {
  76479. /** @hidden (Backing field) */
  76480. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76481. /**
  76482. * Gets or Sets the current prepass renderer associated to the scene.
  76483. */
  76484. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76485. /**
  76486. * Enables the subsurface effect for prepass
  76487. * @returns the SubSurfaceConfiguration
  76488. */
  76489. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76490. /**
  76491. * Disables the subsurface effect for prepass
  76492. */
  76493. disableSubSurfaceForPrePass(): void;
  76494. }
  76495. /**
  76496. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76497. * in several rendering techniques.
  76498. */
  76499. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76500. /**
  76501. * The component name helpful to identify the component in the list of scene components.
  76502. */
  76503. readonly name: string;
  76504. /**
  76505. * The scene the component belongs to.
  76506. */
  76507. scene: Scene;
  76508. /**
  76509. * Creates a new instance of the component for the given scene
  76510. * @param scene Defines the scene to register the component in
  76511. */
  76512. constructor(scene: Scene);
  76513. /**
  76514. * Registers the component in a given scene
  76515. */
  76516. register(): void;
  76517. /**
  76518. * Serializes the component data to the specified json object
  76519. * @param serializationObject The object to serialize to
  76520. */
  76521. serialize(serializationObject: any): void;
  76522. /**
  76523. * Adds all the elements from the container to the scene
  76524. * @param container the container holding the elements
  76525. */
  76526. addFromContainer(container: AbstractScene): void;
  76527. /**
  76528. * Removes all the elements in the container from the scene
  76529. * @param container contains the elements to remove
  76530. * @param dispose if the removed element should be disposed (default: false)
  76531. */
  76532. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76533. /**
  76534. * Rebuilds the elements related to this component in case of
  76535. * context lost for instance.
  76536. */
  76537. rebuild(): void;
  76538. /**
  76539. * Disposes the component and the associated ressources
  76540. */
  76541. dispose(): void;
  76542. }
  76543. }
  76544. declare module BABYLON {
  76545. /** @hidden */
  76546. export var outlinePixelShader: {
  76547. name: string;
  76548. shader: string;
  76549. };
  76550. }
  76551. declare module BABYLON {
  76552. /** @hidden */
  76553. export var outlineVertexShader: {
  76554. name: string;
  76555. shader: string;
  76556. };
  76557. }
  76558. declare module BABYLON {
  76559. interface Scene {
  76560. /** @hidden */
  76561. _outlineRenderer: OutlineRenderer;
  76562. /**
  76563. * Gets the outline renderer associated with the scene
  76564. * @returns a OutlineRenderer
  76565. */
  76566. getOutlineRenderer(): OutlineRenderer;
  76567. }
  76568. interface AbstractMesh {
  76569. /** @hidden (Backing field) */
  76570. _renderOutline: boolean;
  76571. /**
  76572. * Gets or sets a boolean indicating if the outline must be rendered as well
  76573. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76574. */
  76575. renderOutline: boolean;
  76576. /** @hidden (Backing field) */
  76577. _renderOverlay: boolean;
  76578. /**
  76579. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76580. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76581. */
  76582. renderOverlay: boolean;
  76583. }
  76584. /**
  76585. * This class is responsible to draw bothe outline/overlay of meshes.
  76586. * It should not be used directly but through the available method on mesh.
  76587. */
  76588. export class OutlineRenderer implements ISceneComponent {
  76589. /**
  76590. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76591. */
  76592. private static _StencilReference;
  76593. /**
  76594. * The name of the component. Each component must have a unique name.
  76595. */
  76596. name: string;
  76597. /**
  76598. * The scene the component belongs to.
  76599. */
  76600. scene: Scene;
  76601. /**
  76602. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76603. */
  76604. zOffset: number;
  76605. private _engine;
  76606. private _effect;
  76607. private _cachedDefines;
  76608. private _savedDepthWrite;
  76609. /**
  76610. * Instantiates a new outline renderer. (There could be only one per scene).
  76611. * @param scene Defines the scene it belongs to
  76612. */
  76613. constructor(scene: Scene);
  76614. /**
  76615. * Register the component to one instance of a scene.
  76616. */
  76617. register(): void;
  76618. /**
  76619. * Rebuilds the elements related to this component in case of
  76620. * context lost for instance.
  76621. */
  76622. rebuild(): void;
  76623. /**
  76624. * Disposes the component and the associated ressources.
  76625. */
  76626. dispose(): void;
  76627. /**
  76628. * Renders the outline in the canvas.
  76629. * @param subMesh Defines the sumesh to render
  76630. * @param batch Defines the batch of meshes in case of instances
  76631. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76632. */
  76633. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76634. /**
  76635. * Returns whether or not the outline renderer is ready for a given submesh.
  76636. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76637. * @param subMesh Defines the submesh to check readyness for
  76638. * @param useInstances Defines wheter wee are trying to render instances or not
  76639. * @returns true if ready otherwise false
  76640. */
  76641. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76642. private _beforeRenderingMesh;
  76643. private _afterRenderingMesh;
  76644. }
  76645. }
  76646. declare module BABYLON {
  76647. /**
  76648. * Defines the basic options interface of a Sprite Frame Source Size.
  76649. */
  76650. export interface ISpriteJSONSpriteSourceSize {
  76651. /**
  76652. * number of the original width of the Frame
  76653. */
  76654. w: number;
  76655. /**
  76656. * number of the original height of the Frame
  76657. */
  76658. h: number;
  76659. }
  76660. /**
  76661. * Defines the basic options interface of a Sprite Frame Data.
  76662. */
  76663. export interface ISpriteJSONSpriteFrameData {
  76664. /**
  76665. * number of the x offset of the Frame
  76666. */
  76667. x: number;
  76668. /**
  76669. * number of the y offset of the Frame
  76670. */
  76671. y: number;
  76672. /**
  76673. * number of the width of the Frame
  76674. */
  76675. w: number;
  76676. /**
  76677. * number of the height of the Frame
  76678. */
  76679. h: number;
  76680. }
  76681. /**
  76682. * Defines the basic options interface of a JSON Sprite.
  76683. */
  76684. export interface ISpriteJSONSprite {
  76685. /**
  76686. * string name of the Frame
  76687. */
  76688. filename: string;
  76689. /**
  76690. * ISpriteJSONSpriteFrame basic object of the frame data
  76691. */
  76692. frame: ISpriteJSONSpriteFrameData;
  76693. /**
  76694. * boolean to flag is the frame was rotated.
  76695. */
  76696. rotated: boolean;
  76697. /**
  76698. * boolean to flag is the frame was trimmed.
  76699. */
  76700. trimmed: boolean;
  76701. /**
  76702. * ISpriteJSONSpriteFrame basic object of the source data
  76703. */
  76704. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76705. /**
  76706. * ISpriteJSONSpriteFrame basic object of the source data
  76707. */
  76708. sourceSize: ISpriteJSONSpriteSourceSize;
  76709. }
  76710. /**
  76711. * Defines the basic options interface of a JSON atlas.
  76712. */
  76713. export interface ISpriteJSONAtlas {
  76714. /**
  76715. * Array of objects that contain the frame data.
  76716. */
  76717. frames: Array<ISpriteJSONSprite>;
  76718. /**
  76719. * object basic object containing the sprite meta data.
  76720. */
  76721. meta?: object;
  76722. }
  76723. }
  76724. declare module BABYLON {
  76725. /** @hidden */
  76726. export var spriteMapPixelShader: {
  76727. name: string;
  76728. shader: string;
  76729. };
  76730. }
  76731. declare module BABYLON {
  76732. /** @hidden */
  76733. export var spriteMapVertexShader: {
  76734. name: string;
  76735. shader: string;
  76736. };
  76737. }
  76738. declare module BABYLON {
  76739. /**
  76740. * Defines the basic options interface of a SpriteMap
  76741. */
  76742. export interface ISpriteMapOptions {
  76743. /**
  76744. * Vector2 of the number of cells in the grid.
  76745. */
  76746. stageSize?: Vector2;
  76747. /**
  76748. * Vector2 of the size of the output plane in World Units.
  76749. */
  76750. outputSize?: Vector2;
  76751. /**
  76752. * Vector3 of the position of the output plane in World Units.
  76753. */
  76754. outputPosition?: Vector3;
  76755. /**
  76756. * Vector3 of the rotation of the output plane.
  76757. */
  76758. outputRotation?: Vector3;
  76759. /**
  76760. * number of layers that the system will reserve in resources.
  76761. */
  76762. layerCount?: number;
  76763. /**
  76764. * number of max animation frames a single cell will reserve in resources.
  76765. */
  76766. maxAnimationFrames?: number;
  76767. /**
  76768. * number cell index of the base tile when the system compiles.
  76769. */
  76770. baseTile?: number;
  76771. /**
  76772. * boolean flip the sprite after its been repositioned by the framing data.
  76773. */
  76774. flipU?: boolean;
  76775. /**
  76776. * Vector3 scalar of the global RGB values of the SpriteMap.
  76777. */
  76778. colorMultiply?: Vector3;
  76779. }
  76780. /**
  76781. * Defines the IDisposable interface in order to be cleanable from resources.
  76782. */
  76783. export interface ISpriteMap extends IDisposable {
  76784. /**
  76785. * String name of the SpriteMap.
  76786. */
  76787. name: string;
  76788. /**
  76789. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76790. */
  76791. atlasJSON: ISpriteJSONAtlas;
  76792. /**
  76793. * Texture of the SpriteMap.
  76794. */
  76795. spriteSheet: Texture;
  76796. /**
  76797. * The parameters to initialize the SpriteMap with.
  76798. */
  76799. options: ISpriteMapOptions;
  76800. }
  76801. /**
  76802. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76803. */
  76804. export class SpriteMap implements ISpriteMap {
  76805. /** The Name of the spriteMap */
  76806. name: string;
  76807. /** The JSON file with the frame and meta data */
  76808. atlasJSON: ISpriteJSONAtlas;
  76809. /** The systems Sprite Sheet Texture */
  76810. spriteSheet: Texture;
  76811. /** Arguments passed with the Constructor */
  76812. options: ISpriteMapOptions;
  76813. /** Public Sprite Storage array, parsed from atlasJSON */
  76814. sprites: Array<ISpriteJSONSprite>;
  76815. /** Returns the Number of Sprites in the System */
  76816. get spriteCount(): number;
  76817. /** Returns the Position of Output Plane*/
  76818. get position(): Vector3;
  76819. /** Returns the Position of Output Plane*/
  76820. set position(v: Vector3);
  76821. /** Returns the Rotation of Output Plane*/
  76822. get rotation(): Vector3;
  76823. /** Returns the Rotation of Output Plane*/
  76824. set rotation(v: Vector3);
  76825. /** Sets the AnimationMap*/
  76826. get animationMap(): RawTexture;
  76827. /** Sets the AnimationMap*/
  76828. set animationMap(v: RawTexture);
  76829. /** Scene that the SpriteMap was created in */
  76830. private _scene;
  76831. /** Texture Buffer of Float32 that holds tile frame data*/
  76832. private _frameMap;
  76833. /** Texture Buffers of Float32 that holds tileMap data*/
  76834. private _tileMaps;
  76835. /** Texture Buffer of Float32 that holds Animation Data*/
  76836. private _animationMap;
  76837. /** Custom ShaderMaterial Central to the System*/
  76838. private _material;
  76839. /** Custom ShaderMaterial Central to the System*/
  76840. private _output;
  76841. /** Systems Time Ticker*/
  76842. private _time;
  76843. /**
  76844. * Creates a new SpriteMap
  76845. * @param name defines the SpriteMaps Name
  76846. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76847. * @param spriteSheet is the Texture that the Sprites are on.
  76848. * @param options a basic deployment configuration
  76849. * @param scene The Scene that the map is deployed on
  76850. */
  76851. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76852. /**
  76853. * Returns tileID location
  76854. * @returns Vector2 the cell position ID
  76855. */
  76856. getTileID(): Vector2;
  76857. /**
  76858. * Gets the UV location of the mouse over the SpriteMap.
  76859. * @returns Vector2 the UV position of the mouse interaction
  76860. */
  76861. getMousePosition(): Vector2;
  76862. /**
  76863. * Creates the "frame" texture Buffer
  76864. * -------------------------------------
  76865. * Structure of frames
  76866. * "filename": "Falling-Water-2.png",
  76867. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76868. * "rotated": true,
  76869. * "trimmed": true,
  76870. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76871. * "sourceSize": {"w":32,"h":32}
  76872. * @returns RawTexture of the frameMap
  76873. */
  76874. private _createFrameBuffer;
  76875. /**
  76876. * Creates the tileMap texture Buffer
  76877. * @param buffer normally and array of numbers, or a false to generate from scratch
  76878. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76879. * @returns RawTexture of the tileMap
  76880. */
  76881. private _createTileBuffer;
  76882. /**
  76883. * Modifies the data of the tileMaps
  76884. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76885. * @param pos is the iVector2 Coordinates of the Tile
  76886. * @param tile The SpriteIndex of the new Tile
  76887. */
  76888. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76889. /**
  76890. * Creates the animationMap texture Buffer
  76891. * @param buffer normally and array of numbers, or a false to generate from scratch
  76892. * @returns RawTexture of the animationMap
  76893. */
  76894. private _createTileAnimationBuffer;
  76895. /**
  76896. * Modifies the data of the animationMap
  76897. * @param cellID is the Index of the Sprite
  76898. * @param _frame is the target Animation frame
  76899. * @param toCell is the Target Index of the next frame of the animation
  76900. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76901. * @param speed is a global scalar of the time variable on the map.
  76902. */
  76903. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76904. /**
  76905. * Exports the .tilemaps file
  76906. */
  76907. saveTileMaps(): void;
  76908. /**
  76909. * Imports the .tilemaps file
  76910. * @param url of the .tilemaps file
  76911. */
  76912. loadTileMaps(url: string): void;
  76913. /**
  76914. * Release associated resources
  76915. */
  76916. dispose(): void;
  76917. }
  76918. }
  76919. declare module BABYLON {
  76920. /**
  76921. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76922. * @see https://doc.babylonjs.com/babylon101/sprites
  76923. */
  76924. export class SpritePackedManager extends SpriteManager {
  76925. /** defines the packed manager's name */
  76926. name: string;
  76927. /**
  76928. * Creates a new sprite manager from a packed sprite sheet
  76929. * @param name defines the manager's name
  76930. * @param imgUrl defines the sprite sheet url
  76931. * @param capacity defines the maximum allowed number of sprites
  76932. * @param scene defines the hosting scene
  76933. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76934. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76935. * @param samplingMode defines the smapling mode to use with spritesheet
  76936. * @param fromPacked set to true; do not alter
  76937. */
  76938. constructor(
  76939. /** defines the packed manager's name */
  76940. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76941. }
  76942. }
  76943. declare module BABYLON {
  76944. /**
  76945. * Defines the list of states available for a task inside a AssetsManager
  76946. */
  76947. export enum AssetTaskState {
  76948. /**
  76949. * Initialization
  76950. */
  76951. INIT = 0,
  76952. /**
  76953. * Running
  76954. */
  76955. RUNNING = 1,
  76956. /**
  76957. * Done
  76958. */
  76959. DONE = 2,
  76960. /**
  76961. * Error
  76962. */
  76963. ERROR = 3
  76964. }
  76965. /**
  76966. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76967. */
  76968. export abstract class AbstractAssetTask {
  76969. /**
  76970. * Task name
  76971. */ name: string;
  76972. /**
  76973. * Callback called when the task is successful
  76974. */
  76975. onSuccess: (task: any) => void;
  76976. /**
  76977. * Callback called when the task is not successful
  76978. */
  76979. onError: (task: any, message?: string, exception?: any) => void;
  76980. /**
  76981. * Creates a new AssetsManager
  76982. * @param name defines the name of the task
  76983. */
  76984. constructor(
  76985. /**
  76986. * Task name
  76987. */ name: string);
  76988. private _isCompleted;
  76989. private _taskState;
  76990. private _errorObject;
  76991. /**
  76992. * Get if the task is completed
  76993. */
  76994. get isCompleted(): boolean;
  76995. /**
  76996. * Gets the current state of the task
  76997. */
  76998. get taskState(): AssetTaskState;
  76999. /**
  77000. * Gets the current error object (if task is in error)
  77001. */
  77002. get errorObject(): {
  77003. message?: string;
  77004. exception?: any;
  77005. };
  77006. /**
  77007. * Internal only
  77008. * @hidden
  77009. */
  77010. _setErrorObject(message?: string, exception?: any): void;
  77011. /**
  77012. * Execute the current task
  77013. * @param scene defines the scene where you want your assets to be loaded
  77014. * @param onSuccess is a callback called when the task is successfully executed
  77015. * @param onError is a callback called if an error occurs
  77016. */
  77017. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77018. /**
  77019. * Execute the current task
  77020. * @param scene defines the scene where you want your assets to be loaded
  77021. * @param onSuccess is a callback called when the task is successfully executed
  77022. * @param onError is a callback called if an error occurs
  77023. */
  77024. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77025. /**
  77026. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77027. * This can be used with failed tasks that have the reason for failure fixed.
  77028. */
  77029. reset(): void;
  77030. private onErrorCallback;
  77031. private onDoneCallback;
  77032. }
  77033. /**
  77034. * Define the interface used by progress events raised during assets loading
  77035. */
  77036. export interface IAssetsProgressEvent {
  77037. /**
  77038. * Defines the number of remaining tasks to process
  77039. */
  77040. remainingCount: number;
  77041. /**
  77042. * Defines the total number of tasks
  77043. */
  77044. totalCount: number;
  77045. /**
  77046. * Defines the task that was just processed
  77047. */
  77048. task: AbstractAssetTask;
  77049. }
  77050. /**
  77051. * Class used to share progress information about assets loading
  77052. */
  77053. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77054. /**
  77055. * Defines the number of remaining tasks to process
  77056. */
  77057. remainingCount: number;
  77058. /**
  77059. * Defines the total number of tasks
  77060. */
  77061. totalCount: number;
  77062. /**
  77063. * Defines the task that was just processed
  77064. */
  77065. task: AbstractAssetTask;
  77066. /**
  77067. * Creates a AssetsProgressEvent
  77068. * @param remainingCount defines the number of remaining tasks to process
  77069. * @param totalCount defines the total number of tasks
  77070. * @param task defines the task that was just processed
  77071. */
  77072. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77073. }
  77074. /**
  77075. * Define a task used by AssetsManager to load assets into a container
  77076. */
  77077. export class ContainerAssetTask extends AbstractAssetTask {
  77078. /**
  77079. * Defines the name of the task
  77080. */
  77081. name: string;
  77082. /**
  77083. * Defines the list of mesh's names you want to load
  77084. */
  77085. meshesNames: any;
  77086. /**
  77087. * Defines the root url to use as a base to load your meshes and associated resources
  77088. */
  77089. rootUrl: string;
  77090. /**
  77091. * Defines the filename or File of the scene to load from
  77092. */
  77093. sceneFilename: string | File;
  77094. /**
  77095. * Get the loaded asset container
  77096. */
  77097. loadedContainer: AssetContainer;
  77098. /**
  77099. * Gets the list of loaded meshes
  77100. */
  77101. loadedMeshes: Array<AbstractMesh>;
  77102. /**
  77103. * Gets the list of loaded particle systems
  77104. */
  77105. loadedParticleSystems: Array<IParticleSystem>;
  77106. /**
  77107. * Gets the list of loaded skeletons
  77108. */
  77109. loadedSkeletons: Array<Skeleton>;
  77110. /**
  77111. * Gets the list of loaded animation groups
  77112. */
  77113. loadedAnimationGroups: Array<AnimationGroup>;
  77114. /**
  77115. * Callback called when the task is successful
  77116. */
  77117. onSuccess: (task: ContainerAssetTask) => void;
  77118. /**
  77119. * Callback called when the task is successful
  77120. */
  77121. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77122. /**
  77123. * Creates a new ContainerAssetTask
  77124. * @param name defines the name of the task
  77125. * @param meshesNames defines the list of mesh's names you want to load
  77126. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77127. * @param sceneFilename defines the filename or File of the scene to load from
  77128. */
  77129. constructor(
  77130. /**
  77131. * Defines the name of the task
  77132. */
  77133. name: string,
  77134. /**
  77135. * Defines the list of mesh's names you want to load
  77136. */
  77137. meshesNames: any,
  77138. /**
  77139. * Defines the root url to use as a base to load your meshes and associated resources
  77140. */
  77141. rootUrl: string,
  77142. /**
  77143. * Defines the filename or File of the scene to load from
  77144. */
  77145. sceneFilename: string | File);
  77146. /**
  77147. * Execute the current task
  77148. * @param scene defines the scene where you want your assets to be loaded
  77149. * @param onSuccess is a callback called when the task is successfully executed
  77150. * @param onError is a callback called if an error occurs
  77151. */
  77152. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77153. }
  77154. /**
  77155. * Define a task used by AssetsManager to load meshes
  77156. */
  77157. export class MeshAssetTask extends AbstractAssetTask {
  77158. /**
  77159. * Defines the name of the task
  77160. */
  77161. name: string;
  77162. /**
  77163. * Defines the list of mesh's names you want to load
  77164. */
  77165. meshesNames: any;
  77166. /**
  77167. * Defines the root url to use as a base to load your meshes and associated resources
  77168. */
  77169. rootUrl: string;
  77170. /**
  77171. * Defines the filename or File of the scene to load from
  77172. */
  77173. sceneFilename: string | File;
  77174. /**
  77175. * Gets the list of loaded meshes
  77176. */
  77177. loadedMeshes: Array<AbstractMesh>;
  77178. /**
  77179. * Gets the list of loaded particle systems
  77180. */
  77181. loadedParticleSystems: Array<IParticleSystem>;
  77182. /**
  77183. * Gets the list of loaded skeletons
  77184. */
  77185. loadedSkeletons: Array<Skeleton>;
  77186. /**
  77187. * Gets the list of loaded animation groups
  77188. */
  77189. loadedAnimationGroups: Array<AnimationGroup>;
  77190. /**
  77191. * Callback called when the task is successful
  77192. */
  77193. onSuccess: (task: MeshAssetTask) => void;
  77194. /**
  77195. * Callback called when the task is successful
  77196. */
  77197. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77198. /**
  77199. * Creates a new MeshAssetTask
  77200. * @param name defines the name of the task
  77201. * @param meshesNames defines the list of mesh's names you want to load
  77202. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77203. * @param sceneFilename defines the filename or File of the scene to load from
  77204. */
  77205. constructor(
  77206. /**
  77207. * Defines the name of the task
  77208. */
  77209. name: string,
  77210. /**
  77211. * Defines the list of mesh's names you want to load
  77212. */
  77213. meshesNames: any,
  77214. /**
  77215. * Defines the root url to use as a base to load your meshes and associated resources
  77216. */
  77217. rootUrl: string,
  77218. /**
  77219. * Defines the filename or File of the scene to load from
  77220. */
  77221. sceneFilename: string | File);
  77222. /**
  77223. * Execute the current task
  77224. * @param scene defines the scene where you want your assets to be loaded
  77225. * @param onSuccess is a callback called when the task is successfully executed
  77226. * @param onError is a callback called if an error occurs
  77227. */
  77228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77229. }
  77230. /**
  77231. * Define a task used by AssetsManager to load text content
  77232. */
  77233. export class TextFileAssetTask extends AbstractAssetTask {
  77234. /**
  77235. * Defines the name of the task
  77236. */
  77237. name: string;
  77238. /**
  77239. * Defines the location of the file to load
  77240. */
  77241. url: string;
  77242. /**
  77243. * Gets the loaded text string
  77244. */
  77245. text: string;
  77246. /**
  77247. * Callback called when the task is successful
  77248. */
  77249. onSuccess: (task: TextFileAssetTask) => void;
  77250. /**
  77251. * Callback called when the task is successful
  77252. */
  77253. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77254. /**
  77255. * Creates a new TextFileAssetTask object
  77256. * @param name defines the name of the task
  77257. * @param url defines the location of the file to load
  77258. */
  77259. constructor(
  77260. /**
  77261. * Defines the name of the task
  77262. */
  77263. name: string,
  77264. /**
  77265. * Defines the location of the file to load
  77266. */
  77267. url: string);
  77268. /**
  77269. * Execute the current task
  77270. * @param scene defines the scene where you want your assets to be loaded
  77271. * @param onSuccess is a callback called when the task is successfully executed
  77272. * @param onError is a callback called if an error occurs
  77273. */
  77274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77275. }
  77276. /**
  77277. * Define a task used by AssetsManager to load binary data
  77278. */
  77279. export class BinaryFileAssetTask extends AbstractAssetTask {
  77280. /**
  77281. * Defines the name of the task
  77282. */
  77283. name: string;
  77284. /**
  77285. * Defines the location of the file to load
  77286. */
  77287. url: string;
  77288. /**
  77289. * Gets the lodaded data (as an array buffer)
  77290. */
  77291. data: ArrayBuffer;
  77292. /**
  77293. * Callback called when the task is successful
  77294. */
  77295. onSuccess: (task: BinaryFileAssetTask) => void;
  77296. /**
  77297. * Callback called when the task is successful
  77298. */
  77299. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77300. /**
  77301. * Creates a new BinaryFileAssetTask object
  77302. * @param name defines the name of the new task
  77303. * @param url defines the location of the file to load
  77304. */
  77305. constructor(
  77306. /**
  77307. * Defines the name of the task
  77308. */
  77309. name: string,
  77310. /**
  77311. * Defines the location of the file to load
  77312. */
  77313. url: string);
  77314. /**
  77315. * Execute the current task
  77316. * @param scene defines the scene where you want your assets to be loaded
  77317. * @param onSuccess is a callback called when the task is successfully executed
  77318. * @param onError is a callback called if an error occurs
  77319. */
  77320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77321. }
  77322. /**
  77323. * Define a task used by AssetsManager to load images
  77324. */
  77325. export class ImageAssetTask extends AbstractAssetTask {
  77326. /**
  77327. * Defines the name of the task
  77328. */
  77329. name: string;
  77330. /**
  77331. * Defines the location of the image to load
  77332. */
  77333. url: string;
  77334. /**
  77335. * Gets the loaded images
  77336. */
  77337. image: HTMLImageElement;
  77338. /**
  77339. * Callback called when the task is successful
  77340. */
  77341. onSuccess: (task: ImageAssetTask) => void;
  77342. /**
  77343. * Callback called when the task is successful
  77344. */
  77345. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77346. /**
  77347. * Creates a new ImageAssetTask
  77348. * @param name defines the name of the task
  77349. * @param url defines the location of the image to load
  77350. */
  77351. constructor(
  77352. /**
  77353. * Defines the name of the task
  77354. */
  77355. name: string,
  77356. /**
  77357. * Defines the location of the image to load
  77358. */
  77359. url: string);
  77360. /**
  77361. * Execute the current task
  77362. * @param scene defines the scene where you want your assets to be loaded
  77363. * @param onSuccess is a callback called when the task is successfully executed
  77364. * @param onError is a callback called if an error occurs
  77365. */
  77366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77367. }
  77368. /**
  77369. * Defines the interface used by texture loading tasks
  77370. */
  77371. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77372. /**
  77373. * Gets the loaded texture
  77374. */
  77375. texture: TEX;
  77376. }
  77377. /**
  77378. * Define a task used by AssetsManager to load 2D textures
  77379. */
  77380. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77381. /**
  77382. * Defines the name of the task
  77383. */
  77384. name: string;
  77385. /**
  77386. * Defines the location of the file to load
  77387. */
  77388. url: string;
  77389. /**
  77390. * Defines if mipmap should not be generated (default is false)
  77391. */
  77392. noMipmap?: boolean | undefined;
  77393. /**
  77394. * Defines if texture must be inverted on Y axis (default is true)
  77395. */
  77396. invertY: boolean;
  77397. /**
  77398. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77399. */
  77400. samplingMode: number;
  77401. /**
  77402. * Gets the loaded texture
  77403. */
  77404. texture: Texture;
  77405. /**
  77406. * Callback called when the task is successful
  77407. */
  77408. onSuccess: (task: TextureAssetTask) => void;
  77409. /**
  77410. * Callback called when the task is successful
  77411. */
  77412. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77413. /**
  77414. * Creates a new TextureAssetTask object
  77415. * @param name defines the name of the task
  77416. * @param url defines the location of the file to load
  77417. * @param noMipmap defines if mipmap should not be generated (default is false)
  77418. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77419. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77420. */
  77421. constructor(
  77422. /**
  77423. * Defines the name of the task
  77424. */
  77425. name: string,
  77426. /**
  77427. * Defines the location of the file to load
  77428. */
  77429. url: string,
  77430. /**
  77431. * Defines if mipmap should not be generated (default is false)
  77432. */
  77433. noMipmap?: boolean | undefined,
  77434. /**
  77435. * Defines if texture must be inverted on Y axis (default is true)
  77436. */
  77437. invertY?: boolean,
  77438. /**
  77439. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77440. */
  77441. samplingMode?: number);
  77442. /**
  77443. * Execute the current task
  77444. * @param scene defines the scene where you want your assets to be loaded
  77445. * @param onSuccess is a callback called when the task is successfully executed
  77446. * @param onError is a callback called if an error occurs
  77447. */
  77448. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77449. }
  77450. /**
  77451. * Define a task used by AssetsManager to load cube textures
  77452. */
  77453. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77454. /**
  77455. * Defines the name of the task
  77456. */
  77457. name: string;
  77458. /**
  77459. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77460. */
  77461. url: string;
  77462. /**
  77463. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77464. */
  77465. extensions?: string[] | undefined;
  77466. /**
  77467. * Defines if mipmaps should not be generated (default is false)
  77468. */
  77469. noMipmap?: boolean | undefined;
  77470. /**
  77471. * Defines the explicit list of files (undefined by default)
  77472. */
  77473. files?: string[] | undefined;
  77474. /**
  77475. * Gets the loaded texture
  77476. */
  77477. texture: CubeTexture;
  77478. /**
  77479. * Callback called when the task is successful
  77480. */
  77481. onSuccess: (task: CubeTextureAssetTask) => void;
  77482. /**
  77483. * Callback called when the task is successful
  77484. */
  77485. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77486. /**
  77487. * Creates a new CubeTextureAssetTask
  77488. * @param name defines the name of the task
  77489. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77490. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77491. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77492. * @param files defines the explicit list of files (undefined by default)
  77493. */
  77494. constructor(
  77495. /**
  77496. * Defines the name of the task
  77497. */
  77498. name: string,
  77499. /**
  77500. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77501. */
  77502. url: string,
  77503. /**
  77504. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77505. */
  77506. extensions?: string[] | undefined,
  77507. /**
  77508. * Defines if mipmaps should not be generated (default is false)
  77509. */
  77510. noMipmap?: boolean | undefined,
  77511. /**
  77512. * Defines the explicit list of files (undefined by default)
  77513. */
  77514. files?: string[] | undefined);
  77515. /**
  77516. * Execute the current task
  77517. * @param scene defines the scene where you want your assets to be loaded
  77518. * @param onSuccess is a callback called when the task is successfully executed
  77519. * @param onError is a callback called if an error occurs
  77520. */
  77521. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77522. }
  77523. /**
  77524. * Define a task used by AssetsManager to load HDR cube textures
  77525. */
  77526. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77527. /**
  77528. * Defines the name of the task
  77529. */
  77530. name: string;
  77531. /**
  77532. * Defines the location of the file to load
  77533. */
  77534. url: string;
  77535. /**
  77536. * Defines the desired size (the more it increases the longer the generation will be)
  77537. */
  77538. size: number;
  77539. /**
  77540. * Defines if mipmaps should not be generated (default is false)
  77541. */
  77542. noMipmap: boolean;
  77543. /**
  77544. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77545. */
  77546. generateHarmonics: boolean;
  77547. /**
  77548. * 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)
  77549. */
  77550. gammaSpace: boolean;
  77551. /**
  77552. * Internal Use Only
  77553. */
  77554. reserved: boolean;
  77555. /**
  77556. * Gets the loaded texture
  77557. */
  77558. texture: HDRCubeTexture;
  77559. /**
  77560. * Callback called when the task is successful
  77561. */
  77562. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77563. /**
  77564. * Callback called when the task is successful
  77565. */
  77566. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77567. /**
  77568. * Creates a new HDRCubeTextureAssetTask object
  77569. * @param name defines the name of the task
  77570. * @param url defines the location of the file to load
  77571. * @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.
  77572. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77573. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77574. * @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)
  77575. * @param reserved Internal use only
  77576. */
  77577. constructor(
  77578. /**
  77579. * Defines the name of the task
  77580. */
  77581. name: string,
  77582. /**
  77583. * Defines the location of the file to load
  77584. */
  77585. url: string,
  77586. /**
  77587. * Defines the desired size (the more it increases the longer the generation will be)
  77588. */
  77589. size: number,
  77590. /**
  77591. * Defines if mipmaps should not be generated (default is false)
  77592. */
  77593. noMipmap?: boolean,
  77594. /**
  77595. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77596. */
  77597. generateHarmonics?: boolean,
  77598. /**
  77599. * 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)
  77600. */
  77601. gammaSpace?: boolean,
  77602. /**
  77603. * Internal Use Only
  77604. */
  77605. reserved?: boolean);
  77606. /**
  77607. * Execute the current task
  77608. * @param scene defines the scene where you want your assets to be loaded
  77609. * @param onSuccess is a callback called when the task is successfully executed
  77610. * @param onError is a callback called if an error occurs
  77611. */
  77612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77613. }
  77614. /**
  77615. * Define a task used by AssetsManager to load Equirectangular cube textures
  77616. */
  77617. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77618. /**
  77619. * Defines the name of the task
  77620. */
  77621. name: string;
  77622. /**
  77623. * Defines the location of the file to load
  77624. */
  77625. url: string;
  77626. /**
  77627. * Defines the desired size (the more it increases the longer the generation will be)
  77628. */
  77629. size: number;
  77630. /**
  77631. * Defines if mipmaps should not be generated (default is false)
  77632. */
  77633. noMipmap: boolean;
  77634. /**
  77635. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77636. * but the standard material would require them in Gamma space) (default is true)
  77637. */
  77638. gammaSpace: boolean;
  77639. /**
  77640. * Gets the loaded texture
  77641. */
  77642. texture: EquiRectangularCubeTexture;
  77643. /**
  77644. * Callback called when the task is successful
  77645. */
  77646. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77647. /**
  77648. * Callback called when the task is successful
  77649. */
  77650. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77651. /**
  77652. * Creates a new EquiRectangularCubeTextureAssetTask object
  77653. * @param name defines the name of the task
  77654. * @param url defines the location of the file to load
  77655. * @param size defines the desired size (the more it increases the longer the generation will be)
  77656. * If the size is omitted this implies you are using a preprocessed cubemap.
  77657. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77658. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77659. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77660. * (default is true)
  77661. */
  77662. constructor(
  77663. /**
  77664. * Defines the name of the task
  77665. */
  77666. name: string,
  77667. /**
  77668. * Defines the location of the file to load
  77669. */
  77670. url: string,
  77671. /**
  77672. * Defines the desired size (the more it increases the longer the generation will be)
  77673. */
  77674. size: number,
  77675. /**
  77676. * Defines if mipmaps should not be generated (default is false)
  77677. */
  77678. noMipmap?: boolean,
  77679. /**
  77680. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77681. * but the standard material would require them in Gamma space) (default is true)
  77682. */
  77683. gammaSpace?: boolean);
  77684. /**
  77685. * Execute the current task
  77686. * @param scene defines the scene where you want your assets to be loaded
  77687. * @param onSuccess is a callback called when the task is successfully executed
  77688. * @param onError is a callback called if an error occurs
  77689. */
  77690. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77691. }
  77692. /**
  77693. * This class can be used to easily import assets into a scene
  77694. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77695. */
  77696. export class AssetsManager {
  77697. private _scene;
  77698. private _isLoading;
  77699. protected _tasks: AbstractAssetTask[];
  77700. protected _waitingTasksCount: number;
  77701. protected _totalTasksCount: number;
  77702. /**
  77703. * Callback called when all tasks are processed
  77704. */
  77705. onFinish: (tasks: AbstractAssetTask[]) => void;
  77706. /**
  77707. * Callback called when a task is successful
  77708. */
  77709. onTaskSuccess: (task: AbstractAssetTask) => void;
  77710. /**
  77711. * Callback called when a task had an error
  77712. */
  77713. onTaskError: (task: AbstractAssetTask) => void;
  77714. /**
  77715. * Callback called when a task is done (whatever the result is)
  77716. */
  77717. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77718. /**
  77719. * Observable called when all tasks are processed
  77720. */
  77721. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77722. /**
  77723. * Observable called when a task had an error
  77724. */
  77725. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77726. /**
  77727. * Observable called when all tasks were executed
  77728. */
  77729. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77730. /**
  77731. * Observable called when a task is done (whatever the result is)
  77732. */
  77733. onProgressObservable: Observable<IAssetsProgressEvent>;
  77734. /**
  77735. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77736. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77737. */
  77738. useDefaultLoadingScreen: boolean;
  77739. /**
  77740. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77741. * when all assets have been downloaded.
  77742. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77743. */
  77744. autoHideLoadingUI: boolean;
  77745. /**
  77746. * Creates a new AssetsManager
  77747. * @param scene defines the scene to work on
  77748. */
  77749. constructor(scene: Scene);
  77750. /**
  77751. * Add a ContainerAssetTask to the list of active tasks
  77752. * @param taskName defines the name of the new task
  77753. * @param meshesNames defines the name of meshes to load
  77754. * @param rootUrl defines the root url to use to locate files
  77755. * @param sceneFilename defines the filename of the scene file
  77756. * @returns a new ContainerAssetTask object
  77757. */
  77758. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77759. /**
  77760. * Add a MeshAssetTask to the list of active tasks
  77761. * @param taskName defines the name of the new task
  77762. * @param meshesNames defines the name of meshes to load
  77763. * @param rootUrl defines the root url to use to locate files
  77764. * @param sceneFilename defines the filename of the scene file
  77765. * @returns a new MeshAssetTask object
  77766. */
  77767. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77768. /**
  77769. * Add a TextFileAssetTask to the list of active tasks
  77770. * @param taskName defines the name of the new task
  77771. * @param url defines the url of the file to load
  77772. * @returns a new TextFileAssetTask object
  77773. */
  77774. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77775. /**
  77776. * Add a BinaryFileAssetTask to the list of active tasks
  77777. * @param taskName defines the name of the new task
  77778. * @param url defines the url of the file to load
  77779. * @returns a new BinaryFileAssetTask object
  77780. */
  77781. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77782. /**
  77783. * Add a ImageAssetTask to the list of active tasks
  77784. * @param taskName defines the name of the new task
  77785. * @param url defines the url of the file to load
  77786. * @returns a new ImageAssetTask object
  77787. */
  77788. addImageTask(taskName: string, url: string): ImageAssetTask;
  77789. /**
  77790. * Add a TextureAssetTask to the list of active tasks
  77791. * @param taskName defines the name of the new task
  77792. * @param url defines the url of the file to load
  77793. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77794. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77795. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77796. * @returns a new TextureAssetTask object
  77797. */
  77798. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77799. /**
  77800. * Add a CubeTextureAssetTask to the list of active tasks
  77801. * @param taskName defines the name of the new task
  77802. * @param url defines the url of the file to load
  77803. * @param extensions defines the extension to use to load the cube map (can be null)
  77804. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77805. * @param files defines the list of files to load (can be null)
  77806. * @returns a new CubeTextureAssetTask object
  77807. */
  77808. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77809. /**
  77810. *
  77811. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77812. * @param taskName defines the name of the new task
  77813. * @param url defines the url of the file to load
  77814. * @param size defines the size you want for the cubemap (can be null)
  77815. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77816. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77817. * @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)
  77818. * @param reserved Internal use only
  77819. * @returns a new HDRCubeTextureAssetTask object
  77820. */
  77821. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77822. /**
  77823. *
  77824. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77825. * @param taskName defines the name of the new task
  77826. * @param url defines the url of the file to load
  77827. * @param size defines the size you want for the cubemap (can be null)
  77828. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77829. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77830. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77831. * @returns a new EquiRectangularCubeTextureAssetTask object
  77832. */
  77833. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77834. /**
  77835. * Remove a task from the assets manager.
  77836. * @param task the task to remove
  77837. */
  77838. removeTask(task: AbstractAssetTask): void;
  77839. private _decreaseWaitingTasksCount;
  77840. private _runTask;
  77841. /**
  77842. * Reset the AssetsManager and remove all tasks
  77843. * @return the current instance of the AssetsManager
  77844. */
  77845. reset(): AssetsManager;
  77846. /**
  77847. * Start the loading process
  77848. * @return the current instance of the AssetsManager
  77849. */
  77850. load(): AssetsManager;
  77851. /**
  77852. * Start the loading process as an async operation
  77853. * @return a promise returning the list of failed tasks
  77854. */
  77855. loadAsync(): Promise<void>;
  77856. }
  77857. }
  77858. declare module BABYLON {
  77859. /**
  77860. * Wrapper class for promise with external resolve and reject.
  77861. */
  77862. export class Deferred<T> {
  77863. /**
  77864. * The promise associated with this deferred object.
  77865. */
  77866. readonly promise: Promise<T>;
  77867. private _resolve;
  77868. private _reject;
  77869. /**
  77870. * The resolve method of the promise associated with this deferred object.
  77871. */
  77872. get resolve(): (value: T | PromiseLike<T>) => void;
  77873. /**
  77874. * The reject method of the promise associated with this deferred object.
  77875. */
  77876. get reject(): (reason?: any) => void;
  77877. /**
  77878. * Constructor for this deferred object.
  77879. */
  77880. constructor();
  77881. }
  77882. }
  77883. declare module BABYLON {
  77884. /**
  77885. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77886. */
  77887. export class MeshExploder {
  77888. private _centerMesh;
  77889. private _meshes;
  77890. private _meshesOrigins;
  77891. private _toCenterVectors;
  77892. private _scaledDirection;
  77893. private _newPosition;
  77894. private _centerPosition;
  77895. /**
  77896. * Explodes meshes from a center mesh.
  77897. * @param meshes The meshes to explode.
  77898. * @param centerMesh The mesh to be center of explosion.
  77899. */
  77900. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77901. private _setCenterMesh;
  77902. /**
  77903. * Get class name
  77904. * @returns "MeshExploder"
  77905. */
  77906. getClassName(): string;
  77907. /**
  77908. * "Exploded meshes"
  77909. * @returns Array of meshes with the centerMesh at index 0.
  77910. */
  77911. getMeshes(): Array<Mesh>;
  77912. /**
  77913. * Explodes meshes giving a specific direction
  77914. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77915. */
  77916. explode(direction?: number): void;
  77917. }
  77918. }
  77919. declare module BABYLON {
  77920. /**
  77921. * Class used to help managing file picking and drag'n'drop
  77922. */
  77923. export class FilesInput {
  77924. /**
  77925. * List of files ready to be loaded
  77926. */
  77927. static get FilesToLoad(): {
  77928. [key: string]: File;
  77929. };
  77930. /**
  77931. * Callback called when a file is processed
  77932. */
  77933. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  77934. /**
  77935. * Function used when loading the scene file
  77936. */
  77937. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  77938. private _engine;
  77939. private _currentScene;
  77940. private _sceneLoadedCallback;
  77941. private _progressCallback;
  77942. private _additionalRenderLoopLogicCallback;
  77943. private _textureLoadingCallback;
  77944. private _startingProcessingFilesCallback;
  77945. private _onReloadCallback;
  77946. private _errorCallback;
  77947. private _elementToMonitor;
  77948. private _sceneFileToLoad;
  77949. private _filesToLoad;
  77950. /**
  77951. * Creates a new FilesInput
  77952. * @param engine defines the rendering engine
  77953. * @param scene defines the hosting scene
  77954. * @param sceneLoadedCallback callback called when scene is loaded
  77955. * @param progressCallback callback called to track progress
  77956. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77957. * @param textureLoadingCallback callback called when a texture is loading
  77958. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77959. * @param onReloadCallback callback called when a reload is requested
  77960. * @param errorCallback callback call if an error occurs
  77961. */
  77962. 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>);
  77963. private _dragEnterHandler;
  77964. private _dragOverHandler;
  77965. private _dropHandler;
  77966. /**
  77967. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77968. * @param elementToMonitor defines the DOM element to track
  77969. */
  77970. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77971. /** Gets the current list of files to load */
  77972. get filesToLoad(): File[];
  77973. /**
  77974. * Release all associated resources
  77975. */
  77976. dispose(): void;
  77977. private renderFunction;
  77978. private drag;
  77979. private drop;
  77980. private _traverseFolder;
  77981. private _processFiles;
  77982. /**
  77983. * Load files from a drop event
  77984. * @param event defines the drop event to use as source
  77985. */
  77986. loadFiles(event: any): void;
  77987. private _processReload;
  77988. /**
  77989. * Reload the current scene from the loaded files
  77990. */
  77991. reload(): void;
  77992. }
  77993. }
  77994. declare module BABYLON {
  77995. /**
  77996. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77997. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77998. */
  77999. export class SceneOptimization {
  78000. /**
  78001. * Defines the priority of this optimization (0 by default which means first in the list)
  78002. */
  78003. priority: number;
  78004. /**
  78005. * Gets a string describing the action executed by the current optimization
  78006. * @returns description string
  78007. */
  78008. getDescription(): string;
  78009. /**
  78010. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78011. * @param scene defines the current scene where to apply this optimization
  78012. * @param optimizer defines the current optimizer
  78013. * @returns true if everything that can be done was applied
  78014. */
  78015. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78016. /**
  78017. * Creates the SceneOptimization object
  78018. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78019. * @param desc defines the description associated with the optimization
  78020. */
  78021. constructor(
  78022. /**
  78023. * Defines the priority of this optimization (0 by default which means first in the list)
  78024. */
  78025. priority?: number);
  78026. }
  78027. /**
  78028. * Defines an optimization used to reduce the size of render target textures
  78029. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78030. */
  78031. export class TextureOptimization extends SceneOptimization {
  78032. /**
  78033. * Defines the priority of this optimization (0 by default which means first in the list)
  78034. */
  78035. priority: number;
  78036. /**
  78037. * 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
  78038. */
  78039. maximumSize: number;
  78040. /**
  78041. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78042. */
  78043. step: number;
  78044. /**
  78045. * Gets a string describing the action executed by the current optimization
  78046. * @returns description string
  78047. */
  78048. getDescription(): string;
  78049. /**
  78050. * Creates the TextureOptimization object
  78051. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78052. * @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
  78053. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78054. */
  78055. constructor(
  78056. /**
  78057. * Defines the priority of this optimization (0 by default which means first in the list)
  78058. */
  78059. priority?: number,
  78060. /**
  78061. * 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
  78062. */
  78063. maximumSize?: number,
  78064. /**
  78065. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78066. */
  78067. step?: number);
  78068. /**
  78069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78070. * @param scene defines the current scene where to apply this optimization
  78071. * @param optimizer defines the current optimizer
  78072. * @returns true if everything that can be done was applied
  78073. */
  78074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78075. }
  78076. /**
  78077. * Defines an optimization used to increase or decrease the rendering resolution
  78078. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78079. */
  78080. export class HardwareScalingOptimization extends SceneOptimization {
  78081. /**
  78082. * Defines the priority of this optimization (0 by default which means first in the list)
  78083. */
  78084. priority: number;
  78085. /**
  78086. * Defines the maximum scale to use (2 by default)
  78087. */
  78088. maximumScale: number;
  78089. /**
  78090. * Defines the step to use between two passes (0.5 by default)
  78091. */
  78092. step: number;
  78093. private _currentScale;
  78094. private _directionOffset;
  78095. /**
  78096. * Gets a string describing the action executed by the current optimization
  78097. * @return description string
  78098. */
  78099. getDescription(): string;
  78100. /**
  78101. * Creates the HardwareScalingOptimization object
  78102. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78103. * @param maximumScale defines the maximum scale to use (2 by default)
  78104. * @param step defines the step to use between two passes (0.5 by default)
  78105. */
  78106. constructor(
  78107. /**
  78108. * Defines the priority of this optimization (0 by default which means first in the list)
  78109. */
  78110. priority?: number,
  78111. /**
  78112. * Defines the maximum scale to use (2 by default)
  78113. */
  78114. maximumScale?: number,
  78115. /**
  78116. * Defines the step to use between two passes (0.5 by default)
  78117. */
  78118. step?: number);
  78119. /**
  78120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78121. * @param scene defines the current scene where to apply this optimization
  78122. * @param optimizer defines the current optimizer
  78123. * @returns true if everything that can be done was applied
  78124. */
  78125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78126. }
  78127. /**
  78128. * Defines an optimization used to remove shadows
  78129. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78130. */
  78131. export class ShadowsOptimization extends SceneOptimization {
  78132. /**
  78133. * Gets a string describing the action executed by the current optimization
  78134. * @return description string
  78135. */
  78136. getDescription(): string;
  78137. /**
  78138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78139. * @param scene defines the current scene where to apply this optimization
  78140. * @param optimizer defines the current optimizer
  78141. * @returns true if everything that can be done was applied
  78142. */
  78143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78144. }
  78145. /**
  78146. * Defines an optimization used to turn post-processes off
  78147. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78148. */
  78149. export class PostProcessesOptimization extends SceneOptimization {
  78150. /**
  78151. * Gets a string describing the action executed by the current optimization
  78152. * @return description string
  78153. */
  78154. getDescription(): string;
  78155. /**
  78156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78157. * @param scene defines the current scene where to apply this optimization
  78158. * @param optimizer defines the current optimizer
  78159. * @returns true if everything that can be done was applied
  78160. */
  78161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78162. }
  78163. /**
  78164. * Defines an optimization used to turn lens flares off
  78165. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78166. */
  78167. export class LensFlaresOptimization extends SceneOptimization {
  78168. /**
  78169. * Gets a string describing the action executed by the current optimization
  78170. * @return description string
  78171. */
  78172. getDescription(): string;
  78173. /**
  78174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78175. * @param scene defines the current scene where to apply this optimization
  78176. * @param optimizer defines the current optimizer
  78177. * @returns true if everything that can be done was applied
  78178. */
  78179. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78180. }
  78181. /**
  78182. * Defines an optimization based on user defined callback.
  78183. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78184. */
  78185. export class CustomOptimization extends SceneOptimization {
  78186. /**
  78187. * Callback called to apply the custom optimization.
  78188. */
  78189. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78190. /**
  78191. * Callback called to get custom description
  78192. */
  78193. onGetDescription: () => string;
  78194. /**
  78195. * Gets a string describing the action executed by the current optimization
  78196. * @returns description string
  78197. */
  78198. getDescription(): string;
  78199. /**
  78200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78201. * @param scene defines the current scene where to apply this optimization
  78202. * @param optimizer defines the current optimizer
  78203. * @returns true if everything that can be done was applied
  78204. */
  78205. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78206. }
  78207. /**
  78208. * Defines an optimization used to turn particles off
  78209. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78210. */
  78211. export class ParticlesOptimization extends SceneOptimization {
  78212. /**
  78213. * Gets a string describing the action executed by the current optimization
  78214. * @return description string
  78215. */
  78216. getDescription(): string;
  78217. /**
  78218. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78219. * @param scene defines the current scene where to apply this optimization
  78220. * @param optimizer defines the current optimizer
  78221. * @returns true if everything that can be done was applied
  78222. */
  78223. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78224. }
  78225. /**
  78226. * Defines an optimization used to turn render targets off
  78227. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78228. */
  78229. export class RenderTargetsOptimization extends SceneOptimization {
  78230. /**
  78231. * Gets a string describing the action executed by the current optimization
  78232. * @return description string
  78233. */
  78234. getDescription(): string;
  78235. /**
  78236. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78237. * @param scene defines the current scene where to apply this optimization
  78238. * @param optimizer defines the current optimizer
  78239. * @returns true if everything that can be done was applied
  78240. */
  78241. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78242. }
  78243. /**
  78244. * Defines an optimization used to merge meshes with compatible materials
  78245. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78246. */
  78247. export class MergeMeshesOptimization extends SceneOptimization {
  78248. private static _UpdateSelectionTree;
  78249. /**
  78250. * Gets or sets a boolean which defines if optimization octree has to be updated
  78251. */
  78252. static get UpdateSelectionTree(): boolean;
  78253. /**
  78254. * Gets or sets a boolean which defines if optimization octree has to be updated
  78255. */
  78256. static set UpdateSelectionTree(value: boolean);
  78257. /**
  78258. * Gets a string describing the action executed by the current optimization
  78259. * @return description string
  78260. */
  78261. getDescription(): string;
  78262. private _canBeMerged;
  78263. /**
  78264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78265. * @param scene defines the current scene where to apply this optimization
  78266. * @param optimizer defines the current optimizer
  78267. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78268. * @returns true if everything that can be done was applied
  78269. */
  78270. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78271. }
  78272. /**
  78273. * Defines a list of options used by SceneOptimizer
  78274. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78275. */
  78276. export class SceneOptimizerOptions {
  78277. /**
  78278. * Defines the target frame rate to reach (60 by default)
  78279. */
  78280. targetFrameRate: number;
  78281. /**
  78282. * Defines the interval between two checkes (2000ms by default)
  78283. */
  78284. trackerDuration: number;
  78285. /**
  78286. * Gets the list of optimizations to apply
  78287. */
  78288. optimizations: SceneOptimization[];
  78289. /**
  78290. * Creates a new list of options used by SceneOptimizer
  78291. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78292. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78293. */
  78294. constructor(
  78295. /**
  78296. * Defines the target frame rate to reach (60 by default)
  78297. */
  78298. targetFrameRate?: number,
  78299. /**
  78300. * Defines the interval between two checkes (2000ms by default)
  78301. */
  78302. trackerDuration?: number);
  78303. /**
  78304. * Add a new optimization
  78305. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78306. * @returns the current SceneOptimizerOptions
  78307. */
  78308. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78309. /**
  78310. * Add a new custom optimization
  78311. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78312. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78313. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78314. * @returns the current SceneOptimizerOptions
  78315. */
  78316. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78317. /**
  78318. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78319. * @param targetFrameRate defines the target frame rate (60 by default)
  78320. * @returns a SceneOptimizerOptions object
  78321. */
  78322. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78323. /**
  78324. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78325. * @param targetFrameRate defines the target frame rate (60 by default)
  78326. * @returns a SceneOptimizerOptions object
  78327. */
  78328. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78329. /**
  78330. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78331. * @param targetFrameRate defines the target frame rate (60 by default)
  78332. * @returns a SceneOptimizerOptions object
  78333. */
  78334. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78335. }
  78336. /**
  78337. * Class used to run optimizations in order to reach a target frame rate
  78338. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78339. */
  78340. export class SceneOptimizer implements IDisposable {
  78341. private _isRunning;
  78342. private _options;
  78343. private _scene;
  78344. private _currentPriorityLevel;
  78345. private _targetFrameRate;
  78346. private _trackerDuration;
  78347. private _currentFrameRate;
  78348. private _sceneDisposeObserver;
  78349. private _improvementMode;
  78350. /**
  78351. * Defines an observable called when the optimizer reaches the target frame rate
  78352. */
  78353. onSuccessObservable: Observable<SceneOptimizer>;
  78354. /**
  78355. * Defines an observable called when the optimizer enables an optimization
  78356. */
  78357. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78358. /**
  78359. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78360. */
  78361. onFailureObservable: Observable<SceneOptimizer>;
  78362. /**
  78363. * Gets a boolean indicating if the optimizer is in improvement mode
  78364. */
  78365. get isInImprovementMode(): boolean;
  78366. /**
  78367. * Gets the current priority level (0 at start)
  78368. */
  78369. get currentPriorityLevel(): number;
  78370. /**
  78371. * Gets the current frame rate checked by the SceneOptimizer
  78372. */
  78373. get currentFrameRate(): number;
  78374. /**
  78375. * Gets or sets the current target frame rate (60 by default)
  78376. */
  78377. get targetFrameRate(): number;
  78378. /**
  78379. * Gets or sets the current target frame rate (60 by default)
  78380. */
  78381. set targetFrameRate(value: number);
  78382. /**
  78383. * Gets or sets the current interval between two checks (every 2000ms by default)
  78384. */
  78385. get trackerDuration(): number;
  78386. /**
  78387. * Gets or sets the current interval between two checks (every 2000ms by default)
  78388. */
  78389. set trackerDuration(value: number);
  78390. /**
  78391. * Gets the list of active optimizations
  78392. */
  78393. get optimizations(): SceneOptimization[];
  78394. /**
  78395. * Creates a new SceneOptimizer
  78396. * @param scene defines the scene to work on
  78397. * @param options defines the options to use with the SceneOptimizer
  78398. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78399. * @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)
  78400. */
  78401. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78402. /**
  78403. * Stops the current optimizer
  78404. */
  78405. stop(): void;
  78406. /**
  78407. * Reset the optimizer to initial step (current priority level = 0)
  78408. */
  78409. reset(): void;
  78410. /**
  78411. * Start the optimizer. By default it will try to reach a specific framerate
  78412. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78413. */
  78414. start(): void;
  78415. private _checkCurrentState;
  78416. /**
  78417. * Release all resources
  78418. */
  78419. dispose(): void;
  78420. /**
  78421. * Helper function to create a SceneOptimizer with one single line of code
  78422. * @param scene defines the scene to work on
  78423. * @param options defines the options to use with the SceneOptimizer
  78424. * @param onSuccess defines a callback to call on success
  78425. * @param onFailure defines a callback to call on failure
  78426. * @returns the new SceneOptimizer object
  78427. */
  78428. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78429. }
  78430. }
  78431. declare module BABYLON {
  78432. /**
  78433. * Class used to serialize a scene into a string
  78434. */
  78435. export class SceneSerializer {
  78436. /**
  78437. * Clear cache used by a previous serialization
  78438. */
  78439. static ClearCache(): void;
  78440. /**
  78441. * Serialize a scene into a JSON compatible object
  78442. * @param scene defines the scene to serialize
  78443. * @returns a JSON compatible object
  78444. */
  78445. static Serialize(scene: Scene): any;
  78446. /**
  78447. * Serialize a mesh into a JSON compatible object
  78448. * @param toSerialize defines the mesh to serialize
  78449. * @param withParents defines if parents must be serialized as well
  78450. * @param withChildren defines if children must be serialized as well
  78451. * @returns a JSON compatible object
  78452. */
  78453. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78454. }
  78455. }
  78456. declare module BABYLON {
  78457. /**
  78458. * This represents the different options available for the video capture.
  78459. */
  78460. export interface VideoRecorderOptions {
  78461. /** Defines the mime type of the video. */
  78462. mimeType: string;
  78463. /** Defines the FPS the video should be recorded at. */
  78464. fps: number;
  78465. /** Defines the chunk size for the recording data. */
  78466. recordChunckSize: number;
  78467. /** The audio tracks to attach to the recording. */
  78468. audioTracks?: MediaStreamTrack[];
  78469. }
  78470. /**
  78471. * This can help with recording videos from BabylonJS.
  78472. * This is based on the available WebRTC functionalities of the browser.
  78473. *
  78474. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78475. */
  78476. export class VideoRecorder {
  78477. private static readonly _defaultOptions;
  78478. /**
  78479. * Returns whether or not the VideoRecorder is available in your browser.
  78480. * @param engine Defines the Babylon Engine.
  78481. * @returns true if supported otherwise false.
  78482. */
  78483. static IsSupported(engine: Engine): boolean;
  78484. private readonly _options;
  78485. private _canvas;
  78486. private _mediaRecorder;
  78487. private _recordedChunks;
  78488. private _fileName;
  78489. private _resolve;
  78490. private _reject;
  78491. /**
  78492. * True when a recording is already in progress.
  78493. */
  78494. get isRecording(): boolean;
  78495. /**
  78496. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78497. * @param engine Defines the BabylonJS Engine you wish to record.
  78498. * @param options Defines options that can be used to customize the capture.
  78499. */
  78500. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78501. /**
  78502. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78503. */
  78504. stopRecording(): void;
  78505. /**
  78506. * Starts recording the canvas for a max duration specified in parameters.
  78507. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78508. * If null no automatic download will start and you can rely on the promise to get the data back.
  78509. * @param maxDuration Defines the maximum recording time in seconds.
  78510. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78511. * @return A promise callback at the end of the recording with the video data in Blob.
  78512. */
  78513. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78514. /**
  78515. * Releases internal resources used during the recording.
  78516. */
  78517. dispose(): void;
  78518. private _handleDataAvailable;
  78519. private _handleError;
  78520. private _handleStop;
  78521. }
  78522. }
  78523. declare module BABYLON {
  78524. /**
  78525. * Class containing a set of static utilities functions for screenshots
  78526. */
  78527. export class ScreenshotTools {
  78528. /**
  78529. * Captures a screenshot of the current rendering
  78530. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78531. * @param engine defines the rendering engine
  78532. * @param camera defines the source camera
  78533. * @param size This parameter can be set to a single number or to an object with the
  78534. * following (optional) properties: precision, width, height. If a single number is passed,
  78535. * it will be used for both width and height. If an object is passed, the screenshot size
  78536. * will be derived from the parameters. The precision property is a multiplier allowing
  78537. * rendering at a higher or lower resolution
  78538. * @param successCallback defines the callback receives a single parameter which contains the
  78539. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78540. * src parameter of an <img> to display it
  78541. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78542. * Check your browser for supported MIME types
  78543. * @param forceDownload force the system to download the image even if a successCallback is provided
  78544. */
  78545. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78546. /**
  78547. * Captures a screenshot of the current rendering
  78548. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78549. * @param engine defines the rendering engine
  78550. * @param camera defines the source camera
  78551. * @param size This parameter can be set to a single number or to an object with the
  78552. * following (optional) properties: precision, width, height. If a single number is passed,
  78553. * it will be used for both width and height. If an object is passed, the screenshot size
  78554. * will be derived from the parameters. The precision property is a multiplier allowing
  78555. * rendering at a higher or lower resolution
  78556. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78557. * Check your browser for supported MIME types
  78558. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78559. * to the src parameter of an <img> to display it
  78560. */
  78561. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78562. /**
  78563. * Captures a screenshot of the current rendering for a specific size. This will render the entire canvas but will generate a blink (due to canvas resize)
  78564. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78565. * @param engine defines the rendering engine
  78566. * @param camera defines the source camera
  78567. * @param width defines the expected width
  78568. * @param height defines the expected height
  78569. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78570. * Check your browser for supported MIME types
  78571. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78572. * to the src parameter of an <img> to display it
  78573. */
  78574. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78575. /**
  78576. * Generates an image screenshot from the specified camera.
  78577. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78578. * @param engine The engine to use for rendering
  78579. * @param camera The camera to use for rendering
  78580. * @param size This parameter can be set to a single number or to an object with the
  78581. * following (optional) properties: precision, width, height. If a single number is passed,
  78582. * it will be used for both width and height. If an object is passed, the screenshot size
  78583. * will be derived from the parameters. The precision property is a multiplier allowing
  78584. * rendering at a higher or lower resolution
  78585. * @param successCallback The callback receives a single parameter which contains the
  78586. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78587. * src parameter of an <img> to display it
  78588. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78589. * Check your browser for supported MIME types
  78590. * @param samples Texture samples (default: 1)
  78591. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78592. * @param fileName A name for for the downloaded file.
  78593. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78594. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78595. */
  78596. 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;
  78597. /**
  78598. * Generates an image screenshot from the specified camera.
  78599. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78600. * @param engine The engine to use for rendering
  78601. * @param camera The camera to use for rendering
  78602. * @param size This parameter can be set to a single number or to an object with the
  78603. * following (optional) properties: precision, width, height. If a single number is passed,
  78604. * it will be used for both width and height. If an object is passed, the screenshot size
  78605. * will be derived from the parameters. The precision property is a multiplier allowing
  78606. * rendering at a higher or lower resolution
  78607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78608. * Check your browser for supported MIME types
  78609. * @param samples Texture samples (default: 1)
  78610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78611. * @param fileName A name for for the downloaded file.
  78612. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78613. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78614. * to the src parameter of an <img> to display it
  78615. */
  78616. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78617. /**
  78618. * Gets height and width for screenshot size
  78619. * @private
  78620. */
  78621. private static _getScreenshotSize;
  78622. }
  78623. }
  78624. declare module BABYLON {
  78625. /**
  78626. * Interface for a data buffer
  78627. */
  78628. export interface IDataBuffer {
  78629. /**
  78630. * Reads bytes from the data buffer.
  78631. * @param byteOffset The byte offset to read
  78632. * @param byteLength The byte length to read
  78633. * @returns A promise that resolves when the bytes are read
  78634. */
  78635. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78636. /**
  78637. * The byte length of the buffer.
  78638. */
  78639. readonly byteLength: number;
  78640. }
  78641. /**
  78642. * Utility class for reading from a data buffer
  78643. */
  78644. export class DataReader {
  78645. /**
  78646. * The data buffer associated with this data reader.
  78647. */
  78648. readonly buffer: IDataBuffer;
  78649. /**
  78650. * The current byte offset from the beginning of the data buffer.
  78651. */
  78652. byteOffset: number;
  78653. private _dataView;
  78654. private _dataByteOffset;
  78655. /**
  78656. * Constructor
  78657. * @param buffer The buffer to read
  78658. */
  78659. constructor(buffer: IDataBuffer);
  78660. /**
  78661. * Loads the given byte length.
  78662. * @param byteLength The byte length to load
  78663. * @returns A promise that resolves when the load is complete
  78664. */
  78665. loadAsync(byteLength: number): Promise<void>;
  78666. /**
  78667. * Read a unsigned 32-bit integer from the currently loaded data range.
  78668. * @returns The 32-bit integer read
  78669. */
  78670. readUint32(): number;
  78671. /**
  78672. * Read a byte array from the currently loaded data range.
  78673. * @param byteLength The byte length to read
  78674. * @returns The byte array read
  78675. */
  78676. readUint8Array(byteLength: number): Uint8Array;
  78677. /**
  78678. * Read a string from the currently loaded data range.
  78679. * @param byteLength The byte length to read
  78680. * @returns The string read
  78681. */
  78682. readString(byteLength: number): string;
  78683. /**
  78684. * Skips the given byte length the currently loaded data range.
  78685. * @param byteLength The byte length to skip
  78686. */
  78687. skipBytes(byteLength: number): void;
  78688. }
  78689. }
  78690. declare module BABYLON {
  78691. /**
  78692. * Class for storing data to local storage if available or in-memory storage otherwise
  78693. */
  78694. export class DataStorage {
  78695. private static _Storage;
  78696. private static _GetStorage;
  78697. /**
  78698. * Reads a string from the data storage
  78699. * @param key The key to read
  78700. * @param defaultValue The value if the key doesn't exist
  78701. * @returns The string value
  78702. */
  78703. static ReadString(key: string, defaultValue: string): string;
  78704. /**
  78705. * Writes a string to the data storage
  78706. * @param key The key to write
  78707. * @param value The value to write
  78708. */
  78709. static WriteString(key: string, value: string): void;
  78710. /**
  78711. * Reads a boolean from the data storage
  78712. * @param key The key to read
  78713. * @param defaultValue The value if the key doesn't exist
  78714. * @returns The boolean value
  78715. */
  78716. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78717. /**
  78718. * Writes a boolean to the data storage
  78719. * @param key The key to write
  78720. * @param value The value to write
  78721. */
  78722. static WriteBoolean(key: string, value: boolean): void;
  78723. /**
  78724. * Reads a number from the data storage
  78725. * @param key The key to read
  78726. * @param defaultValue The value if the key doesn't exist
  78727. * @returns The number value
  78728. */
  78729. static ReadNumber(key: string, defaultValue: number): number;
  78730. /**
  78731. * Writes a number to the data storage
  78732. * @param key The key to write
  78733. * @param value The value to write
  78734. */
  78735. static WriteNumber(key: string, value: number): void;
  78736. }
  78737. }
  78738. declare module BABYLON {
  78739. /**
  78740. * Class used to record delta files between 2 scene states
  78741. */
  78742. export class SceneRecorder {
  78743. private _trackedScene;
  78744. private _savedJSON;
  78745. /**
  78746. * Track a given scene. This means the current scene state will be considered the original state
  78747. * @param scene defines the scene to track
  78748. */
  78749. track(scene: Scene): void;
  78750. /**
  78751. * Get the delta between current state and original state
  78752. * @returns a string containing the delta
  78753. */
  78754. getDelta(): any;
  78755. private _compareArray;
  78756. private _compareObjects;
  78757. private _compareCollections;
  78758. private static GetShadowGeneratorById;
  78759. /**
  78760. * Apply a given delta to a given scene
  78761. * @param deltaJSON defines the JSON containing the delta
  78762. * @param scene defines the scene to apply the delta to
  78763. */
  78764. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78765. private static _ApplyPropertiesToEntity;
  78766. private static _ApplyDeltaForEntity;
  78767. }
  78768. }
  78769. declare module BABYLON {
  78770. /**
  78771. * A 3D trajectory consisting of an order list of vectors describing a
  78772. * path of motion through 3D space.
  78773. */
  78774. export class Trajectory {
  78775. private _points;
  78776. private readonly _segmentLength;
  78777. /**
  78778. * Serialize to JSON.
  78779. * @returns serialized JSON string
  78780. */
  78781. serialize(): string;
  78782. /**
  78783. * Deserialize from JSON.
  78784. * @param json serialized JSON string
  78785. * @returns deserialized Trajectory
  78786. */
  78787. static Deserialize(json: string): Trajectory;
  78788. /**
  78789. * Create a new empty Trajectory.
  78790. * @param segmentLength radius of discretization for Trajectory points
  78791. */
  78792. constructor(segmentLength?: number);
  78793. /**
  78794. * Get the length of the Trajectory.
  78795. * @returns length of the Trajectory
  78796. */
  78797. getLength(): number;
  78798. /**
  78799. * Append a new point to the Trajectory.
  78800. * NOTE: This implementation has many allocations.
  78801. * @param point point to append to the Trajectory
  78802. */
  78803. add(point: DeepImmutable<Vector3>): void;
  78804. /**
  78805. * Create a new Trajectory with a segment length chosen to make it
  78806. * probable that the new Trajectory will have a specified number of
  78807. * segments. This operation is imprecise.
  78808. * @param targetResolution number of segments desired
  78809. * @returns new Trajectory with approximately the requested number of segments
  78810. */
  78811. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78812. /**
  78813. * Convert Trajectory segments into tokenized representation. This
  78814. * representation is an array of numbers where each nth number is the
  78815. * index of the token which is most similar to the nth segment of the
  78816. * Trajectory.
  78817. * @param tokens list of vectors which serve as discrete tokens
  78818. * @returns list of indices of most similar token per segment
  78819. */
  78820. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78821. private static _forwardDir;
  78822. private static _inverseFromVec;
  78823. private static _upDir;
  78824. private static _fromToVec;
  78825. private static _lookMatrix;
  78826. /**
  78827. * Transform the rotation (i.e., direction) of a segment to isolate
  78828. * the relative transformation represented by the segment. This operation
  78829. * may or may not succeed due to singularities in the equations that define
  78830. * motion relativity in this context.
  78831. * @param priorVec the origin of the prior segment
  78832. * @param fromVec the origin of the current segment
  78833. * @param toVec the destination of the current segment
  78834. * @param result reference to output variable
  78835. * @returns whether or not transformation was successful
  78836. */
  78837. private static _transformSegmentDirToRef;
  78838. private static _bestMatch;
  78839. private static _score;
  78840. private static _bestScore;
  78841. /**
  78842. * Determine which token vector is most similar to the
  78843. * segment vector.
  78844. * @param segment segment vector
  78845. * @param tokens token vector list
  78846. * @returns index of the most similar token to the segment
  78847. */
  78848. private static _tokenizeSegment;
  78849. }
  78850. /**
  78851. * Class representing a set of known, named trajectories to which Trajectories can be
  78852. * added and using which Trajectories can be recognized.
  78853. */
  78854. export class TrajectoryClassifier {
  78855. private _maximumAllowableMatchCost;
  78856. private _vector3Alphabet;
  78857. private _levenshteinAlphabet;
  78858. private _nameToDescribedTrajectory;
  78859. /**
  78860. * Serialize to JSON.
  78861. * @returns JSON serialization
  78862. */
  78863. serialize(): string;
  78864. /**
  78865. * Deserialize from JSON.
  78866. * @param json JSON serialization
  78867. * @returns deserialized TrajectorySet
  78868. */
  78869. static Deserialize(json: string): TrajectoryClassifier;
  78870. /**
  78871. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78872. * VERY naive, need to be generating these things from known
  78873. * sets. Better version later, probably eliminating this one.
  78874. * @returns auto-generated TrajectorySet
  78875. */
  78876. static Generate(): TrajectoryClassifier;
  78877. private constructor();
  78878. /**
  78879. * Add a new Trajectory to the set with a given name.
  78880. * @param trajectory new Trajectory to be added
  78881. * @param classification name to which to add the Trajectory
  78882. */
  78883. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78884. /**
  78885. * Remove a known named trajectory and all Trajectories associated with it.
  78886. * @param classification name to remove
  78887. * @returns whether anything was removed
  78888. */
  78889. deleteClassification(classification: string): boolean;
  78890. /**
  78891. * Attempt to recognize a Trajectory from among all the classifications
  78892. * already known to the classifier.
  78893. * @param trajectory Trajectory to be recognized
  78894. * @returns classification of Trajectory if recognized, null otherwise
  78895. */
  78896. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78897. }
  78898. }
  78899. declare module BABYLON {
  78900. /**
  78901. * An interface for all Hit test features
  78902. */
  78903. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78904. /**
  78905. * Triggered when new babylon (transformed) hit test results are available
  78906. */
  78907. onHitTestResultObservable: Observable<T[]>;
  78908. }
  78909. /**
  78910. * Options used for hit testing
  78911. */
  78912. export interface IWebXRLegacyHitTestOptions {
  78913. /**
  78914. * Only test when user interacted with the scene. Default - hit test every frame
  78915. */
  78916. testOnPointerDownOnly?: boolean;
  78917. /**
  78918. * The node to use to transform the local results to world coordinates
  78919. */
  78920. worldParentNode?: TransformNode;
  78921. }
  78922. /**
  78923. * Interface defining the babylon result of raycasting/hit-test
  78924. */
  78925. export interface IWebXRLegacyHitResult {
  78926. /**
  78927. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78928. */
  78929. transformationMatrix: Matrix;
  78930. /**
  78931. * The native hit test result
  78932. */
  78933. xrHitResult: XRHitResult | XRHitTestResult;
  78934. }
  78935. /**
  78936. * The currently-working hit-test module.
  78937. * Hit test (or Ray-casting) is used to interact with the real world.
  78938. * For further information read here - https://github.com/immersive-web/hit-test
  78939. */
  78940. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78941. /**
  78942. * options to use when constructing this feature
  78943. */
  78944. readonly options: IWebXRLegacyHitTestOptions;
  78945. private _direction;
  78946. private _mat;
  78947. private _onSelectEnabled;
  78948. private _origin;
  78949. /**
  78950. * The module's name
  78951. */
  78952. static readonly Name: string;
  78953. /**
  78954. * The (Babylon) version of this module.
  78955. * This is an integer representing the implementation version.
  78956. * This number does not correspond to the WebXR specs version
  78957. */
  78958. static readonly Version: number;
  78959. /**
  78960. * Populated with the last native XR Hit Results
  78961. */
  78962. lastNativeXRHitResults: XRHitResult[];
  78963. /**
  78964. * Triggered when new babylon (transformed) hit test results are available
  78965. */
  78966. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78967. /**
  78968. * Creates a new instance of the (legacy version) hit test feature
  78969. * @param _xrSessionManager an instance of WebXRSessionManager
  78970. * @param options options to use when constructing this feature
  78971. */
  78972. constructor(_xrSessionManager: WebXRSessionManager,
  78973. /**
  78974. * options to use when constructing this feature
  78975. */
  78976. options?: IWebXRLegacyHitTestOptions);
  78977. /**
  78978. * execute a hit test with an XR Ray
  78979. *
  78980. * @param xrSession a native xrSession that will execute this hit test
  78981. * @param xrRay the ray (position and direction) to use for ray-casting
  78982. * @param referenceSpace native XR reference space to use for the hit-test
  78983. * @param filter filter function that will filter the results
  78984. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78985. */
  78986. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78987. /**
  78988. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78989. * @param event the (select) event to use to select with
  78990. * @param referenceSpace the reference space to use for this hit test
  78991. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78992. */
  78993. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78994. /**
  78995. * attach this feature
  78996. * Will usually be called by the features manager
  78997. *
  78998. * @returns true if successful.
  78999. */
  79000. attach(): boolean;
  79001. /**
  79002. * detach this feature.
  79003. * Will usually be called by the features manager
  79004. *
  79005. * @returns true if successful.
  79006. */
  79007. detach(): boolean;
  79008. /**
  79009. * Dispose this feature and all of the resources attached
  79010. */
  79011. dispose(): void;
  79012. protected _onXRFrame(frame: XRFrame): void;
  79013. private _onHitTestResults;
  79014. private _onSelect;
  79015. }
  79016. }
  79017. declare module BABYLON {
  79018. /**
  79019. * Options used for hit testing (version 2)
  79020. */
  79021. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79022. /**
  79023. * Do not create a permanent hit test. Will usually be used when only
  79024. * transient inputs are needed.
  79025. */
  79026. disablePermanentHitTest?: boolean;
  79027. /**
  79028. * Enable transient (for example touch-based) hit test inspections
  79029. */
  79030. enableTransientHitTest?: boolean;
  79031. /**
  79032. * Offset ray for the permanent hit test
  79033. */
  79034. offsetRay?: Vector3;
  79035. /**
  79036. * Offset ray for the transient hit test
  79037. */
  79038. transientOffsetRay?: Vector3;
  79039. /**
  79040. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79041. */
  79042. useReferenceSpace?: boolean;
  79043. /**
  79044. * Override the default entity type(s) of the hit-test result
  79045. */
  79046. entityTypes?: XRHitTestTrackableType[];
  79047. }
  79048. /**
  79049. * Interface defining the babylon result of hit-test
  79050. */
  79051. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79052. /**
  79053. * The input source that generated this hit test (if transient)
  79054. */
  79055. inputSource?: XRInputSource;
  79056. /**
  79057. * Is this a transient hit test
  79058. */
  79059. isTransient?: boolean;
  79060. /**
  79061. * Position of the hit test result
  79062. */
  79063. position: Vector3;
  79064. /**
  79065. * Rotation of the hit test result
  79066. */
  79067. rotationQuaternion: Quaternion;
  79068. /**
  79069. * The native hit test result
  79070. */
  79071. xrHitResult: XRHitTestResult;
  79072. }
  79073. /**
  79074. * The currently-working hit-test module.
  79075. * Hit test (or Ray-casting) is used to interact with the real world.
  79076. * For further information read here - https://github.com/immersive-web/hit-test
  79077. *
  79078. * Tested on chrome (mobile) 80.
  79079. */
  79080. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79081. /**
  79082. * options to use when constructing this feature
  79083. */
  79084. readonly options: IWebXRHitTestOptions;
  79085. private _tmpMat;
  79086. private _tmpPos;
  79087. private _tmpQuat;
  79088. private _transientXrHitTestSource;
  79089. private _xrHitTestSource;
  79090. private initHitTestSource;
  79091. /**
  79092. * The module's name
  79093. */
  79094. static readonly Name: string;
  79095. /**
  79096. * The (Babylon) version of this module.
  79097. * This is an integer representing the implementation version.
  79098. * This number does not correspond to the WebXR specs version
  79099. */
  79100. static readonly Version: number;
  79101. /**
  79102. * When set to true, each hit test will have its own position/rotation objects
  79103. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79104. * the developers will clone them or copy them as they see fit.
  79105. */
  79106. autoCloneTransformation: boolean;
  79107. /**
  79108. * Triggered when new babylon (transformed) hit test results are available
  79109. * Note - this will be called when results come back from the device. It can be an empty array!!
  79110. */
  79111. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79112. /**
  79113. * Use this to temporarily pause hit test checks.
  79114. */
  79115. paused: boolean;
  79116. /**
  79117. * Creates a new instance of the hit test feature
  79118. * @param _xrSessionManager an instance of WebXRSessionManager
  79119. * @param options options to use when constructing this feature
  79120. */
  79121. constructor(_xrSessionManager: WebXRSessionManager,
  79122. /**
  79123. * options to use when constructing this feature
  79124. */
  79125. options?: IWebXRHitTestOptions);
  79126. /**
  79127. * attach this feature
  79128. * Will usually be called by the features manager
  79129. *
  79130. * @returns true if successful.
  79131. */
  79132. attach(): boolean;
  79133. /**
  79134. * detach this feature.
  79135. * Will usually be called by the features manager
  79136. *
  79137. * @returns true if successful.
  79138. */
  79139. detach(): boolean;
  79140. /**
  79141. * Dispose this feature and all of the resources attached
  79142. */
  79143. dispose(): void;
  79144. protected _onXRFrame(frame: XRFrame): void;
  79145. private _processWebXRHitTestResult;
  79146. }
  79147. }
  79148. declare module BABYLON {
  79149. /**
  79150. * Configuration options of the anchor system
  79151. */
  79152. export interface IWebXRAnchorSystemOptions {
  79153. /**
  79154. * a node that will be used to convert local to world coordinates
  79155. */
  79156. worldParentNode?: TransformNode;
  79157. /**
  79158. * If set to true a reference of the created anchors will be kept until the next session starts
  79159. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79160. */
  79161. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79162. }
  79163. /**
  79164. * A babylon container for an XR Anchor
  79165. */
  79166. export interface IWebXRAnchor {
  79167. /**
  79168. * A babylon-assigned ID for this anchor
  79169. */
  79170. id: number;
  79171. /**
  79172. * Transformation matrix to apply to an object attached to this anchor
  79173. */
  79174. transformationMatrix: Matrix;
  79175. /**
  79176. * The native anchor object
  79177. */
  79178. xrAnchor: XRAnchor;
  79179. /**
  79180. * if defined, this object will be constantly updated by the anchor's position and rotation
  79181. */
  79182. attachedNode?: TransformNode;
  79183. /**
  79184. * Remove this anchor from the scene
  79185. */
  79186. remove(): void;
  79187. }
  79188. /**
  79189. * An implementation of the anchor system for WebXR.
  79190. * For further information see https://github.com/immersive-web/anchors/
  79191. */
  79192. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79193. private _options;
  79194. private _lastFrameDetected;
  79195. private _trackedAnchors;
  79196. private _referenceSpaceForFrameAnchors;
  79197. private _futureAnchors;
  79198. /**
  79199. * The module's name
  79200. */
  79201. static readonly Name: string;
  79202. /**
  79203. * The (Babylon) version of this module.
  79204. * This is an integer representing the implementation version.
  79205. * This number does not correspond to the WebXR specs version
  79206. */
  79207. static readonly Version: number;
  79208. /**
  79209. * Observers registered here will be executed when a new anchor was added to the session
  79210. */
  79211. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79212. /**
  79213. * Observers registered here will be executed when an anchor was removed from the session
  79214. */
  79215. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79216. /**
  79217. * Observers registered here will be executed when an existing anchor updates
  79218. * This can execute N times every frame
  79219. */
  79220. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79221. /**
  79222. * Set the reference space to use for anchor creation, when not using a hit test.
  79223. * Will default to the session's reference space if not defined
  79224. */
  79225. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79226. /**
  79227. * constructs a new anchor system
  79228. * @param _xrSessionManager an instance of WebXRSessionManager
  79229. * @param _options configuration object for this feature
  79230. */
  79231. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79232. private _tmpVector;
  79233. private _tmpQuaternion;
  79234. private _populateTmpTransformation;
  79235. /**
  79236. * Create a new anchor point using a hit test result at a specific point in the scene
  79237. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79238. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79239. *
  79240. * @param hitTestResult The hit test result to use for this anchor creation
  79241. * @param position an optional position offset for this anchor
  79242. * @param rotationQuaternion an optional rotation offset for this anchor
  79243. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79244. */
  79245. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79246. /**
  79247. * Add a new anchor at a specific position and rotation
  79248. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79249. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79250. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79251. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79252. *
  79253. * @param position the position in which to add an anchor
  79254. * @param rotationQuaternion an optional rotation for the anchor transformation
  79255. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79256. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79257. */
  79258. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79259. /**
  79260. * Get the list of anchors currently being tracked by the system
  79261. */
  79262. get anchors(): IWebXRAnchor[];
  79263. /**
  79264. * detach this feature.
  79265. * Will usually be called by the features manager
  79266. *
  79267. * @returns true if successful.
  79268. */
  79269. detach(): boolean;
  79270. /**
  79271. * Dispose this feature and all of the resources attached
  79272. */
  79273. dispose(): void;
  79274. protected _onXRFrame(frame: XRFrame): void;
  79275. /**
  79276. * avoiding using Array.find for global support.
  79277. * @param xrAnchor the plane to find in the array
  79278. */
  79279. private _findIndexInAnchorArray;
  79280. private _updateAnchorWithXRFrame;
  79281. private _createAnchorAtTransformation;
  79282. }
  79283. }
  79284. declare module BABYLON {
  79285. /**
  79286. * Options used in the plane detector module
  79287. */
  79288. export interface IWebXRPlaneDetectorOptions {
  79289. /**
  79290. * The node to use to transform the local results to world coordinates
  79291. */
  79292. worldParentNode?: TransformNode;
  79293. /**
  79294. * If set to true a reference of the created planes will be kept until the next session starts
  79295. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79296. */
  79297. doNotRemovePlanesOnSessionEnded?: boolean;
  79298. /**
  79299. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79300. */
  79301. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79302. }
  79303. /**
  79304. * A babylon interface for a WebXR plane.
  79305. * A Plane is actually a polygon, built from N points in space
  79306. *
  79307. * Supported in chrome 79, not supported in canary 81 ATM
  79308. */
  79309. export interface IWebXRPlane {
  79310. /**
  79311. * a babylon-assigned ID for this polygon
  79312. */
  79313. id: number;
  79314. /**
  79315. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79316. */
  79317. polygonDefinition: Array<Vector3>;
  79318. /**
  79319. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79320. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79321. */
  79322. transformationMatrix: Matrix;
  79323. /**
  79324. * the native xr-plane object
  79325. */
  79326. xrPlane: XRPlane;
  79327. }
  79328. /**
  79329. * The plane detector is used to detect planes in the real world when in AR
  79330. * For more information see https://github.com/immersive-web/real-world-geometry/
  79331. */
  79332. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79333. private _options;
  79334. private _detectedPlanes;
  79335. private _enabled;
  79336. private _lastFrameDetected;
  79337. /**
  79338. * The module's name
  79339. */
  79340. static readonly Name: string;
  79341. /**
  79342. * The (Babylon) version of this module.
  79343. * This is an integer representing the implementation version.
  79344. * This number does not correspond to the WebXR specs version
  79345. */
  79346. static readonly Version: number;
  79347. /**
  79348. * Observers registered here will be executed when a new plane was added to the session
  79349. */
  79350. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79351. /**
  79352. * Observers registered here will be executed when a plane is no longer detected in the session
  79353. */
  79354. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79355. /**
  79356. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79357. * This can execute N times every frame
  79358. */
  79359. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79360. /**
  79361. * construct a new Plane Detector
  79362. * @param _xrSessionManager an instance of xr Session manager
  79363. * @param _options configuration to use when constructing this feature
  79364. */
  79365. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79366. /**
  79367. * detach this feature.
  79368. * Will usually be called by the features manager
  79369. *
  79370. * @returns true if successful.
  79371. */
  79372. detach(): boolean;
  79373. /**
  79374. * Dispose this feature and all of the resources attached
  79375. */
  79376. dispose(): void;
  79377. /**
  79378. * Check if the needed objects are defined.
  79379. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79380. */
  79381. isCompatible(): boolean;
  79382. protected _onXRFrame(frame: XRFrame): void;
  79383. private _init;
  79384. private _updatePlaneWithXRPlane;
  79385. /**
  79386. * avoiding using Array.find for global support.
  79387. * @param xrPlane the plane to find in the array
  79388. */
  79389. private _findIndexInPlaneArray;
  79390. }
  79391. }
  79392. declare module BABYLON {
  79393. /**
  79394. * Options interface for the background remover plugin
  79395. */
  79396. export interface IWebXRBackgroundRemoverOptions {
  79397. /**
  79398. * Further background meshes to disable when entering AR
  79399. */
  79400. backgroundMeshes?: AbstractMesh[];
  79401. /**
  79402. * flags to configure the removal of the environment helper.
  79403. * If not set, the entire background will be removed. If set, flags should be set as well.
  79404. */
  79405. environmentHelperRemovalFlags?: {
  79406. /**
  79407. * Should the skybox be removed (default false)
  79408. */
  79409. skyBox?: boolean;
  79410. /**
  79411. * Should the ground be removed (default false)
  79412. */
  79413. ground?: boolean;
  79414. };
  79415. /**
  79416. * don't disable the environment helper
  79417. */
  79418. ignoreEnvironmentHelper?: boolean;
  79419. }
  79420. /**
  79421. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79422. */
  79423. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79424. /**
  79425. * read-only options to be used in this module
  79426. */
  79427. readonly options: IWebXRBackgroundRemoverOptions;
  79428. /**
  79429. * The module's name
  79430. */
  79431. static readonly Name: string;
  79432. /**
  79433. * The (Babylon) version of this module.
  79434. * This is an integer representing the implementation version.
  79435. * This number does not correspond to the WebXR specs version
  79436. */
  79437. static readonly Version: number;
  79438. /**
  79439. * registered observers will be triggered when the background state changes
  79440. */
  79441. onBackgroundStateChangedObservable: Observable<boolean>;
  79442. /**
  79443. * constructs a new background remover module
  79444. * @param _xrSessionManager the session manager for this module
  79445. * @param options read-only options to be used in this module
  79446. */
  79447. constructor(_xrSessionManager: WebXRSessionManager,
  79448. /**
  79449. * read-only options to be used in this module
  79450. */
  79451. options?: IWebXRBackgroundRemoverOptions);
  79452. /**
  79453. * attach this feature
  79454. * Will usually be called by the features manager
  79455. *
  79456. * @returns true if successful.
  79457. */
  79458. attach(): boolean;
  79459. /**
  79460. * detach this feature.
  79461. * Will usually be called by the features manager
  79462. *
  79463. * @returns true if successful.
  79464. */
  79465. detach(): boolean;
  79466. /**
  79467. * Dispose this feature and all of the resources attached
  79468. */
  79469. dispose(): void;
  79470. protected _onXRFrame(_xrFrame: XRFrame): void;
  79471. private _setBackgroundState;
  79472. }
  79473. }
  79474. declare module BABYLON {
  79475. /**
  79476. * Options for the controller physics feature
  79477. */
  79478. export class IWebXRControllerPhysicsOptions {
  79479. /**
  79480. * Should the headset get its own impostor
  79481. */
  79482. enableHeadsetImpostor?: boolean;
  79483. /**
  79484. * Optional parameters for the headset impostor
  79485. */
  79486. headsetImpostorParams?: {
  79487. /**
  79488. * The type of impostor to create. Default is sphere
  79489. */
  79490. impostorType: number;
  79491. /**
  79492. * the size of the impostor. Defaults to 10cm
  79493. */
  79494. impostorSize?: number | {
  79495. width: number;
  79496. height: number;
  79497. depth: number;
  79498. };
  79499. /**
  79500. * Friction definitions
  79501. */
  79502. friction?: number;
  79503. /**
  79504. * Restitution
  79505. */
  79506. restitution?: number;
  79507. };
  79508. /**
  79509. * The physics properties of the future impostors
  79510. */
  79511. physicsProperties?: {
  79512. /**
  79513. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79514. * Note that this requires a physics engine that supports mesh impostors!
  79515. */
  79516. useControllerMesh?: boolean;
  79517. /**
  79518. * The type of impostor to create. Default is sphere
  79519. */
  79520. impostorType?: number;
  79521. /**
  79522. * the size of the impostor. Defaults to 10cm
  79523. */
  79524. impostorSize?: number | {
  79525. width: number;
  79526. height: number;
  79527. depth: number;
  79528. };
  79529. /**
  79530. * Friction definitions
  79531. */
  79532. friction?: number;
  79533. /**
  79534. * Restitution
  79535. */
  79536. restitution?: number;
  79537. };
  79538. /**
  79539. * the xr input to use with this pointer selection
  79540. */
  79541. xrInput: WebXRInput;
  79542. }
  79543. /**
  79544. * Add physics impostor to your webxr controllers,
  79545. * including naive calculation of their linear and angular velocity
  79546. */
  79547. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79548. private readonly _options;
  79549. private _attachController;
  79550. private _controllers;
  79551. private _debugMode;
  79552. private _delta;
  79553. private _headsetImpostor?;
  79554. private _headsetMesh?;
  79555. private _lastTimestamp;
  79556. private _tmpQuaternion;
  79557. private _tmpVector;
  79558. /**
  79559. * The module's name
  79560. */
  79561. static readonly Name: string;
  79562. /**
  79563. * The (Babylon) version of this module.
  79564. * This is an integer representing the implementation version.
  79565. * This number does not correspond to the webxr specs version
  79566. */
  79567. static readonly Version: number;
  79568. /**
  79569. * Construct a new Controller Physics Feature
  79570. * @param _xrSessionManager the corresponding xr session manager
  79571. * @param _options options to create this feature with
  79572. */
  79573. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79574. /**
  79575. * @hidden
  79576. * enable debugging - will show console outputs and the impostor mesh
  79577. */
  79578. _enablePhysicsDebug(): void;
  79579. /**
  79580. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79581. * @param xrController the controller to add
  79582. */
  79583. addController(xrController: WebXRInputSource): void;
  79584. /**
  79585. * attach this feature
  79586. * Will usually be called by the features manager
  79587. *
  79588. * @returns true if successful.
  79589. */
  79590. attach(): boolean;
  79591. /**
  79592. * detach this feature.
  79593. * Will usually be called by the features manager
  79594. *
  79595. * @returns true if successful.
  79596. */
  79597. detach(): boolean;
  79598. /**
  79599. * Get the headset impostor, if enabled
  79600. * @returns the impostor
  79601. */
  79602. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79603. /**
  79604. * Get the physics impostor of a specific controller.
  79605. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79606. * @param controller the controller or the controller id of which to get the impostor
  79607. * @returns the impostor or null
  79608. */
  79609. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79610. /**
  79611. * Update the physics properties provided in the constructor
  79612. * @param newProperties the new properties object
  79613. */
  79614. setPhysicsProperties(newProperties: {
  79615. impostorType?: number;
  79616. impostorSize?: number | {
  79617. width: number;
  79618. height: number;
  79619. depth: number;
  79620. };
  79621. friction?: number;
  79622. restitution?: number;
  79623. }): void;
  79624. protected _onXRFrame(_xrFrame: any): void;
  79625. private _detachController;
  79626. }
  79627. }
  79628. declare module BABYLON {
  79629. /**
  79630. * A babylon interface for a "WebXR" feature point.
  79631. * Represents the position and confidence value of a given feature point.
  79632. */
  79633. export interface IWebXRFeaturePoint {
  79634. /**
  79635. * Represents the position of the feature point in world space.
  79636. */
  79637. position: Vector3;
  79638. /**
  79639. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79640. */
  79641. confidenceValue: number;
  79642. }
  79643. /**
  79644. * The feature point system is used to detect feature points from real world geometry.
  79645. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79646. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79647. */
  79648. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79649. private _enabled;
  79650. private _featurePointCloud;
  79651. /**
  79652. * The module's name
  79653. */
  79654. static readonly Name: string;
  79655. /**
  79656. * The (Babylon) version of this module.
  79657. * This is an integer representing the implementation version.
  79658. * This number does not correspond to the WebXR specs version
  79659. */
  79660. static readonly Version: number;
  79661. /**
  79662. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79663. * Will notify the observers about which feature points have been added.
  79664. */
  79665. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79666. /**
  79667. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79668. * Will notify the observers about which feature points have been updated.
  79669. */
  79670. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79671. /**
  79672. * The current feature point cloud maintained across frames.
  79673. */
  79674. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79675. /**
  79676. * construct the feature point system
  79677. * @param _xrSessionManager an instance of xr Session manager
  79678. */
  79679. constructor(_xrSessionManager: WebXRSessionManager);
  79680. /**
  79681. * Detach this feature.
  79682. * Will usually be called by the features manager
  79683. *
  79684. * @returns true if successful.
  79685. */
  79686. detach(): boolean;
  79687. /**
  79688. * Dispose this feature and all of the resources attached
  79689. */
  79690. dispose(): void;
  79691. /**
  79692. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79693. */
  79694. protected _onXRFrame(frame: XRFrame): void;
  79695. /**
  79696. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79697. */
  79698. private _init;
  79699. }
  79700. }
  79701. declare module BABYLON {
  79702. /**
  79703. * Configuration interface for the hand tracking feature
  79704. */
  79705. export interface IWebXRHandTrackingOptions {
  79706. /**
  79707. * The xrInput that will be used as source for new hands
  79708. */
  79709. xrInput: WebXRInput;
  79710. /**
  79711. * Configuration object for the joint meshes
  79712. */
  79713. jointMeshes?: {
  79714. /**
  79715. * Should the meshes created be invisible (defaults to false)
  79716. */
  79717. invisible?: boolean;
  79718. /**
  79719. * A source mesh to be used to create instances. Defaults to a sphere.
  79720. * This mesh will be the source for all other (25) meshes.
  79721. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79722. */
  79723. sourceMesh?: Mesh;
  79724. /**
  79725. * This function will be called after a mesh was created for a specific joint.
  79726. * Using this function you can either manipulate the instance or return a new mesh.
  79727. * When returning a new mesh the instance created before will be disposed
  79728. */
  79729. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79730. /**
  79731. * Should the source mesh stay visible. Defaults to false
  79732. */
  79733. keepOriginalVisible?: boolean;
  79734. /**
  79735. * Scale factor for all instances (defaults to 2)
  79736. */
  79737. scaleFactor?: number;
  79738. /**
  79739. * Should each instance have its own physics impostor
  79740. */
  79741. enablePhysics?: boolean;
  79742. /**
  79743. * If enabled, override default physics properties
  79744. */
  79745. physicsProps?: {
  79746. friction?: number;
  79747. restitution?: number;
  79748. impostorType?: number;
  79749. };
  79750. /**
  79751. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79752. */
  79753. disableDefaultHandMesh?: boolean;
  79754. /**
  79755. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79756. */
  79757. handMeshes?: {
  79758. right: AbstractMesh;
  79759. left: AbstractMesh;
  79760. };
  79761. /**
  79762. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79763. */
  79764. rigMapping?: {
  79765. right: string[];
  79766. left: string[];
  79767. };
  79768. };
  79769. }
  79770. /**
  79771. * Parts of the hands divided to writs and finger names
  79772. */
  79773. export const enum HandPart {
  79774. /**
  79775. * HandPart - Wrist
  79776. */
  79777. WRIST = "wrist",
  79778. /**
  79779. * HandPart - The THumb
  79780. */
  79781. THUMB = "thumb",
  79782. /**
  79783. * HandPart - Index finger
  79784. */
  79785. INDEX = "index",
  79786. /**
  79787. * HandPart - Middle finger
  79788. */
  79789. MIDDLE = "middle",
  79790. /**
  79791. * HandPart - Ring finger
  79792. */
  79793. RING = "ring",
  79794. /**
  79795. * HandPart - Little finger
  79796. */
  79797. LITTLE = "little"
  79798. }
  79799. /**
  79800. * Representing a single hand (with its corresponding native XRHand object)
  79801. */
  79802. export class WebXRHand implements IDisposable {
  79803. /** the controller to which the hand correlates */
  79804. readonly xrController: WebXRInputSource;
  79805. /** the meshes to be used to track the hand joints */
  79806. readonly trackedMeshes: AbstractMesh[];
  79807. private _handMesh?;
  79808. private _rigMapping?;
  79809. private _scene;
  79810. private _defaultHandMesh;
  79811. private _transformNodeMapping;
  79812. /**
  79813. * Hand-parts definition (key is HandPart)
  79814. */
  79815. handPartsDefinition: {
  79816. [key: string]: number[];
  79817. };
  79818. /**
  79819. * Observers will be triggered when the mesh for this hand was initialized.
  79820. */
  79821. onHandMeshReadyObservable: Observable<WebXRHand>;
  79822. /**
  79823. * Populate the HandPartsDefinition object.
  79824. * This is called as a side effect since certain browsers don't have XRHand defined.
  79825. */
  79826. private generateHandPartsDefinition;
  79827. /**
  79828. * Construct a new hand object
  79829. * @param xrController the controller to which the hand correlates
  79830. * @param trackedMeshes the meshes to be used to track the hand joints
  79831. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79832. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79833. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79834. */
  79835. constructor(
  79836. /** the controller to which the hand correlates */
  79837. xrController: WebXRInputSource,
  79838. /** the meshes to be used to track the hand joints */
  79839. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79840. /**
  79841. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79842. */
  79843. get handMesh(): AbstractMesh | undefined;
  79844. /**
  79845. * Update this hand from the latest xr frame
  79846. * @param xrFrame xrFrame to update from
  79847. * @param referenceSpace The current viewer reference space
  79848. * @param scaleFactor optional scale factor for the meshes
  79849. */
  79850. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79851. /**
  79852. * Get meshes of part of the hand
  79853. * @param part the part of hand to get
  79854. * @returns An array of meshes that correlate to the hand part requested
  79855. */
  79856. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79857. /**
  79858. * Dispose this Hand object
  79859. */
  79860. dispose(): void;
  79861. private _generateDefaultHandMesh;
  79862. }
  79863. /**
  79864. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79865. */
  79866. export class WebXRHandTracking extends WebXRAbstractFeature {
  79867. /**
  79868. * options to use when constructing this feature
  79869. */
  79870. readonly options: IWebXRHandTrackingOptions;
  79871. private static _idCounter;
  79872. /**
  79873. * The module's name
  79874. */
  79875. static readonly Name: string;
  79876. /**
  79877. * The (Babylon) version of this module.
  79878. * This is an integer representing the implementation version.
  79879. * This number does not correspond to the WebXR specs version
  79880. */
  79881. static readonly Version: number;
  79882. /**
  79883. * This observable will notify registered observers when a new hand object was added and initialized
  79884. */
  79885. onHandAddedObservable: Observable<WebXRHand>;
  79886. /**
  79887. * This observable will notify its observers right before the hand object is disposed
  79888. */
  79889. onHandRemovedObservable: Observable<WebXRHand>;
  79890. private _hands;
  79891. /**
  79892. * Creates a new instance of the hit test feature
  79893. * @param _xrSessionManager an instance of WebXRSessionManager
  79894. * @param options options to use when constructing this feature
  79895. */
  79896. constructor(_xrSessionManager: WebXRSessionManager,
  79897. /**
  79898. * options to use when constructing this feature
  79899. */
  79900. options: IWebXRHandTrackingOptions);
  79901. /**
  79902. * Check if the needed objects are defined.
  79903. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79904. */
  79905. isCompatible(): boolean;
  79906. /**
  79907. * attach this feature
  79908. * Will usually be called by the features manager
  79909. *
  79910. * @returns true if successful.
  79911. */
  79912. attach(): boolean;
  79913. /**
  79914. * detach this feature.
  79915. * Will usually be called by the features manager
  79916. *
  79917. * @returns true if successful.
  79918. */
  79919. detach(): boolean;
  79920. /**
  79921. * Dispose this feature and all of the resources attached
  79922. */
  79923. dispose(): void;
  79924. /**
  79925. * Get the hand object according to the controller id
  79926. * @param controllerId the controller id to which we want to get the hand
  79927. * @returns null if not found or the WebXRHand object if found
  79928. */
  79929. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79930. /**
  79931. * Get a hand object according to the requested handedness
  79932. * @param handedness the handedness to request
  79933. * @returns null if not found or the WebXRHand object if found
  79934. */
  79935. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79936. protected _onXRFrame(_xrFrame: XRFrame): void;
  79937. private _attachHand;
  79938. private _detachHand;
  79939. }
  79940. }
  79941. declare module BABYLON {
  79942. /**
  79943. * Options used in the mesh detector module
  79944. */
  79945. export interface IWebXRMeshDetectorOptions {
  79946. /**
  79947. * The node to use to transform the local results to world coordinates
  79948. */
  79949. worldParentNode?: TransformNode;
  79950. /**
  79951. * If set to true a reference of the created meshes will be kept until the next session starts
  79952. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  79953. */
  79954. doNotRemoveMeshesOnSessionEnded?: boolean;
  79955. /**
  79956. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79957. */
  79958. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79959. /**
  79960. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  79961. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  79962. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  79963. */
  79964. convertCoordinateSystems?: boolean;
  79965. }
  79966. /**
  79967. * A babylon interface for a XR mesh's vertex data.
  79968. *
  79969. * Currently not supported by WebXR, available only with BabylonNative
  79970. */
  79971. export interface IWebXRVertexData {
  79972. /**
  79973. * A babylon-assigned ID for this mesh
  79974. */
  79975. id: number;
  79976. /**
  79977. * Data required for constructing a mesh in Babylon.js.
  79978. */
  79979. xrMesh: XRMesh;
  79980. /**
  79981. * The node to use to transform the local results to world coordinates.
  79982. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  79983. */
  79984. worldParentNode?: TransformNode;
  79985. /**
  79986. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  79987. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79988. */
  79989. positions?: Float32Array;
  79990. /**
  79991. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  79992. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79993. */
  79994. indices?: Uint32Array;
  79995. /**
  79996. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  79997. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  79998. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  79999. */
  80000. normals?: Float32Array;
  80001. /**
  80002. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80003. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80004. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80005. */
  80006. transformationMatrix?: Matrix;
  80007. }
  80008. /**
  80009. * The mesh detector is used to detect meshes in the real world when in AR
  80010. */
  80011. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80012. private _options;
  80013. private _detectedMeshes;
  80014. /**
  80015. * The module's name
  80016. */
  80017. static readonly Name: string;
  80018. /**
  80019. * The (Babylon) version of this module.
  80020. * This is an integer representing the implementation version.
  80021. * This number does not correspond to the WebXR specs version
  80022. */
  80023. static readonly Version: number;
  80024. /**
  80025. * Observers registered here will be executed when a new mesh was added to the session
  80026. */
  80027. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80028. /**
  80029. * Observers registered here will be executed when a mesh is no longer detected in the session
  80030. */
  80031. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80032. /**
  80033. * Observers registered here will be executed when an existing mesh updates
  80034. */
  80035. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80036. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80037. detach(): boolean;
  80038. dispose(): void;
  80039. protected _onXRFrame(frame: XRFrame): void;
  80040. private _init;
  80041. private _updateVertexDataWithXRMesh;
  80042. }
  80043. }
  80044. declare module BABYLON {
  80045. /**
  80046. * Options interface for the background remover plugin
  80047. */
  80048. export interface IWebXRImageTrackingOptions {
  80049. /**
  80050. * A required array with images to track
  80051. */
  80052. images: {
  80053. /**
  80054. * The source of the image. can be a URL or an image bitmap
  80055. */
  80056. src: string | ImageBitmap;
  80057. /**
  80058. * The estimated width in the real world (in meters)
  80059. */
  80060. estimatedRealWorldWidth: number;
  80061. }[];
  80062. }
  80063. /**
  80064. * An object representing an image tracked by the system
  80065. */
  80066. export interface IWebXRTrackedImage {
  80067. /**
  80068. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80069. */
  80070. id: number;
  80071. /**
  80072. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80073. */
  80074. emulated?: boolean;
  80075. /**
  80076. * Just in case it is needed - the image bitmap that is being tracked
  80077. */
  80078. originalBitmap: ImageBitmap;
  80079. /**
  80080. * The native XR result image tracking result, untouched
  80081. */
  80082. xrTrackingResult?: XRImageTrackingResult;
  80083. /**
  80084. * Width in real world (meters)
  80085. */
  80086. realWorldWidth?: number;
  80087. /**
  80088. * A transformation matrix of this current image in the current reference space.
  80089. */
  80090. transformationMatrix: Matrix;
  80091. /**
  80092. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80093. */
  80094. ratio?: number;
  80095. }
  80096. /**
  80097. * Image tracking for immersive AR sessions.
  80098. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80099. */
  80100. export class WebXRImageTracking extends WebXRAbstractFeature {
  80101. /**
  80102. * read-only options to be used in this module
  80103. */
  80104. readonly options: IWebXRImageTrackingOptions;
  80105. /**
  80106. * The module's name
  80107. */
  80108. static readonly Name: string;
  80109. /**
  80110. * The (Babylon) version of this module.
  80111. * This is an integer representing the implementation version.
  80112. * This number does not correspond to the WebXR specs version
  80113. */
  80114. static readonly Version: number;
  80115. /**
  80116. * This will be triggered if the underlying system deems an image untrackable.
  80117. * The index is the index of the image from the array used to initialize the feature.
  80118. */
  80119. onUntrackableImageFoundObservable: Observable<number>;
  80120. /**
  80121. * An image was deemed trackable, and the system will start tracking it.
  80122. */
  80123. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80124. /**
  80125. * The image was found and its state was updated.
  80126. */
  80127. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80128. private _trackedImages;
  80129. private _originalTrackingRequest;
  80130. /**
  80131. * constructs the image tracking feature
  80132. * @param _xrSessionManager the session manager for this module
  80133. * @param options read-only options to be used in this module
  80134. */
  80135. constructor(_xrSessionManager: WebXRSessionManager,
  80136. /**
  80137. * read-only options to be used in this module
  80138. */
  80139. options: IWebXRImageTrackingOptions);
  80140. /**
  80141. * attach this feature
  80142. * Will usually be called by the features manager
  80143. *
  80144. * @returns true if successful.
  80145. */
  80146. attach(): boolean;
  80147. /**
  80148. * detach this feature.
  80149. * Will usually be called by the features manager
  80150. *
  80151. * @returns true if successful.
  80152. */
  80153. detach(): boolean;
  80154. /**
  80155. * Check if the needed objects are defined.
  80156. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80157. */
  80158. isCompatible(): boolean;
  80159. /**
  80160. * Get a tracked image by its ID.
  80161. *
  80162. * @param id the id of the image to load (position in the init array)
  80163. * @returns a trackable image, if exists in this location
  80164. */
  80165. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80166. /**
  80167. * Dispose this feature and all of the resources attached
  80168. */
  80169. dispose(): void;
  80170. /**
  80171. * Extends the session init object if needed
  80172. * @returns augmentation object fo the xr session init object.
  80173. */
  80174. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80175. protected _onXRFrame(_xrFrame: XRFrame): void;
  80176. private _init;
  80177. }
  80178. }
  80179. declare module BABYLON {
  80180. /**
  80181. * The motion controller class for all microsoft mixed reality controllers
  80182. */
  80183. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80184. protected readonly _mapping: {
  80185. defaultButton: {
  80186. valueNodeName: string;
  80187. unpressedNodeName: string;
  80188. pressedNodeName: string;
  80189. };
  80190. defaultAxis: {
  80191. valueNodeName: string;
  80192. minNodeName: string;
  80193. maxNodeName: string;
  80194. };
  80195. buttons: {
  80196. "xr-standard-trigger": {
  80197. rootNodeName: string;
  80198. componentProperty: string;
  80199. states: string[];
  80200. };
  80201. "xr-standard-squeeze": {
  80202. rootNodeName: string;
  80203. componentProperty: string;
  80204. states: string[];
  80205. };
  80206. "xr-standard-touchpad": {
  80207. rootNodeName: string;
  80208. labelAnchorNodeName: string;
  80209. touchPointNodeName: string;
  80210. };
  80211. "xr-standard-thumbstick": {
  80212. rootNodeName: string;
  80213. componentProperty: string;
  80214. states: string[];
  80215. };
  80216. };
  80217. axes: {
  80218. "xr-standard-touchpad": {
  80219. "x-axis": {
  80220. rootNodeName: string;
  80221. };
  80222. "y-axis": {
  80223. rootNodeName: string;
  80224. };
  80225. };
  80226. "xr-standard-thumbstick": {
  80227. "x-axis": {
  80228. rootNodeName: string;
  80229. };
  80230. "y-axis": {
  80231. rootNodeName: string;
  80232. };
  80233. };
  80234. };
  80235. };
  80236. /**
  80237. * The base url used to load the left and right controller models
  80238. */
  80239. static MODEL_BASE_URL: string;
  80240. /**
  80241. * The name of the left controller model file
  80242. */
  80243. static MODEL_LEFT_FILENAME: string;
  80244. /**
  80245. * The name of the right controller model file
  80246. */
  80247. static MODEL_RIGHT_FILENAME: string;
  80248. profileId: string;
  80249. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80250. protected _getFilenameAndPath(): {
  80251. filename: string;
  80252. path: string;
  80253. };
  80254. protected _getModelLoadingConstraints(): boolean;
  80255. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80256. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80257. protected _updateModel(): void;
  80258. }
  80259. }
  80260. declare module BABYLON {
  80261. /**
  80262. * The motion controller class for oculus touch (quest, rift).
  80263. * This class supports legacy mapping as well the standard xr mapping
  80264. */
  80265. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80266. private _forceLegacyControllers;
  80267. private _modelRootNode;
  80268. /**
  80269. * The base url used to load the left and right controller models
  80270. */
  80271. static MODEL_BASE_URL: string;
  80272. /**
  80273. * The name of the left controller model file
  80274. */
  80275. static MODEL_LEFT_FILENAME: string;
  80276. /**
  80277. * The name of the right controller model file
  80278. */
  80279. static MODEL_RIGHT_FILENAME: string;
  80280. /**
  80281. * Base Url for the Quest controller model.
  80282. */
  80283. static QUEST_MODEL_BASE_URL: string;
  80284. profileId: string;
  80285. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80286. protected _getFilenameAndPath(): {
  80287. filename: string;
  80288. path: string;
  80289. };
  80290. protected _getModelLoadingConstraints(): boolean;
  80291. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80292. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80293. protected _updateModel(): void;
  80294. /**
  80295. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80296. * between the touch and touch 2.
  80297. */
  80298. private _isQuest;
  80299. }
  80300. }
  80301. declare module BABYLON {
  80302. /**
  80303. * The motion controller class for the standard HTC-Vive controllers
  80304. */
  80305. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80306. private _modelRootNode;
  80307. /**
  80308. * The base url used to load the left and right controller models
  80309. */
  80310. static MODEL_BASE_URL: string;
  80311. /**
  80312. * File name for the controller model.
  80313. */
  80314. static MODEL_FILENAME: string;
  80315. profileId: string;
  80316. /**
  80317. * Create a new Vive motion controller object
  80318. * @param scene the scene to use to create this controller
  80319. * @param gamepadObject the corresponding gamepad object
  80320. * @param handedness the handedness of the controller
  80321. */
  80322. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80323. protected _getFilenameAndPath(): {
  80324. filename: string;
  80325. path: string;
  80326. };
  80327. protected _getModelLoadingConstraints(): boolean;
  80328. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80329. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80330. protected _updateModel(): void;
  80331. }
  80332. }
  80333. declare module BABYLON {
  80334. /**
  80335. * A cursor which tracks a point on a path
  80336. */
  80337. export class PathCursor {
  80338. private path;
  80339. /**
  80340. * Stores path cursor callbacks for when an onchange event is triggered
  80341. */
  80342. private _onchange;
  80343. /**
  80344. * The value of the path cursor
  80345. */
  80346. value: number;
  80347. /**
  80348. * The animation array of the path cursor
  80349. */
  80350. animations: Animation[];
  80351. /**
  80352. * Initializes the path cursor
  80353. * @param path The path to track
  80354. */
  80355. constructor(path: Path2);
  80356. /**
  80357. * Gets the cursor point on the path
  80358. * @returns A point on the path cursor at the cursor location
  80359. */
  80360. getPoint(): Vector3;
  80361. /**
  80362. * Moves the cursor ahead by the step amount
  80363. * @param step The amount to move the cursor forward
  80364. * @returns This path cursor
  80365. */
  80366. moveAhead(step?: number): PathCursor;
  80367. /**
  80368. * Moves the cursor behind by the step amount
  80369. * @param step The amount to move the cursor back
  80370. * @returns This path cursor
  80371. */
  80372. moveBack(step?: number): PathCursor;
  80373. /**
  80374. * Moves the cursor by the step amount
  80375. * If the step amount is greater than one, an exception is thrown
  80376. * @param step The amount to move the cursor
  80377. * @returns This path cursor
  80378. */
  80379. move(step: number): PathCursor;
  80380. /**
  80381. * Ensures that the value is limited between zero and one
  80382. * @returns This path cursor
  80383. */
  80384. private ensureLimits;
  80385. /**
  80386. * Runs onchange callbacks on change (used by the animation engine)
  80387. * @returns This path cursor
  80388. */
  80389. private raiseOnChange;
  80390. /**
  80391. * Executes a function on change
  80392. * @param f A path cursor onchange callback
  80393. * @returns This path cursor
  80394. */
  80395. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80396. }
  80397. }
  80398. declare module BABYLON {
  80399. /** @hidden */
  80400. export var blurPixelShader: {
  80401. name: string;
  80402. shader: string;
  80403. };
  80404. }
  80405. declare module BABYLON {
  80406. /** @hidden */
  80407. export var pointCloudVertexDeclaration: {
  80408. name: string;
  80409. shader: string;
  80410. };
  80411. }
  80412. // Mixins
  80413. interface Window {
  80414. mozIndexedDB: IDBFactory;
  80415. webkitIndexedDB: IDBFactory;
  80416. msIndexedDB: IDBFactory;
  80417. webkitURL: typeof URL;
  80418. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80419. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80420. WebGLRenderingContext: WebGLRenderingContext;
  80421. MSGesture: MSGesture;
  80422. CANNON: any;
  80423. AudioContext: AudioContext;
  80424. webkitAudioContext: AudioContext;
  80425. PointerEvent: any;
  80426. Math: Math;
  80427. Uint8Array: Uint8ArrayConstructor;
  80428. Float32Array: Float32ArrayConstructor;
  80429. mozURL: typeof URL;
  80430. msURL: typeof URL;
  80431. VRFrameData: any; // WebVR, from specs 1.1
  80432. DracoDecoderModule: any;
  80433. setImmediate(handler: (...args: any[]) => void): number;
  80434. }
  80435. interface HTMLCanvasElement {
  80436. requestPointerLock(): void;
  80437. msRequestPointerLock?(): void;
  80438. mozRequestPointerLock?(): void;
  80439. webkitRequestPointerLock?(): void;
  80440. /** Track wether a record is in progress */
  80441. isRecording: boolean;
  80442. /** Capture Stream method defined by some browsers */
  80443. captureStream(fps?: number): MediaStream;
  80444. }
  80445. interface CanvasRenderingContext2D {
  80446. msImageSmoothingEnabled: boolean;
  80447. }
  80448. interface MouseEvent {
  80449. mozMovementX: number;
  80450. mozMovementY: number;
  80451. webkitMovementX: number;
  80452. webkitMovementY: number;
  80453. msMovementX: number;
  80454. msMovementY: number;
  80455. }
  80456. interface Navigator {
  80457. mozGetVRDevices: (any: any) => any;
  80458. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80459. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80460. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80461. webkitGetGamepads(): Gamepad[];
  80462. msGetGamepads(): Gamepad[];
  80463. webkitGamepads(): Gamepad[];
  80464. }
  80465. interface HTMLVideoElement {
  80466. mozSrcObject: any;
  80467. }
  80468. interface Math {
  80469. fround(x: number): number;
  80470. imul(a: number, b: number): number;
  80471. log2(x: number): number;
  80472. }
  80473. interface WebGLRenderingContext {
  80474. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80475. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80476. vertexAttribDivisor(index: number, divisor: number): void;
  80477. createVertexArray(): any;
  80478. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80479. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80480. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80481. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80482. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80483. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80484. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80485. // Queries
  80486. createQuery(): WebGLQuery;
  80487. deleteQuery(query: WebGLQuery): void;
  80488. beginQuery(target: number, query: WebGLQuery): void;
  80489. endQuery(target: number): void;
  80490. getQueryParameter(query: WebGLQuery, pname: number): any;
  80491. getQuery(target: number, pname: number): any;
  80492. MAX_SAMPLES: number;
  80493. RGBA8: number;
  80494. READ_FRAMEBUFFER: number;
  80495. DRAW_FRAMEBUFFER: number;
  80496. UNIFORM_BUFFER: number;
  80497. HALF_FLOAT_OES: number;
  80498. RGBA16F: number;
  80499. RGBA32F: number;
  80500. R32F: number;
  80501. RG32F: number;
  80502. RGB32F: number;
  80503. R16F: number;
  80504. RG16F: number;
  80505. RGB16F: number;
  80506. RED: number;
  80507. RG: number;
  80508. R8: number;
  80509. RG8: number;
  80510. UNSIGNED_INT_24_8: number;
  80511. DEPTH24_STENCIL8: number;
  80512. MIN: number;
  80513. MAX: number;
  80514. /* Multiple Render Targets */
  80515. drawBuffers(buffers: number[]): void;
  80516. readBuffer(src: number): void;
  80517. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80518. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80519. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80520. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80521. // Occlusion Query
  80522. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80523. ANY_SAMPLES_PASSED: number;
  80524. QUERY_RESULT_AVAILABLE: number;
  80525. QUERY_RESULT: number;
  80526. }
  80527. interface WebGLProgram {
  80528. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80529. }
  80530. interface EXT_disjoint_timer_query {
  80531. QUERY_COUNTER_BITS_EXT: number;
  80532. TIME_ELAPSED_EXT: number;
  80533. TIMESTAMP_EXT: number;
  80534. GPU_DISJOINT_EXT: number;
  80535. QUERY_RESULT_EXT: number;
  80536. QUERY_RESULT_AVAILABLE_EXT: number;
  80537. queryCounterEXT(query: WebGLQuery, target: number): void;
  80538. createQueryEXT(): WebGLQuery;
  80539. beginQueryEXT(target: number, query: WebGLQuery): void;
  80540. endQueryEXT(target: number): void;
  80541. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80542. deleteQueryEXT(query: WebGLQuery): void;
  80543. }
  80544. interface WebGLUniformLocation {
  80545. _currentState: any;
  80546. }
  80547. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80548. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80549. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80550. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80551. interface WebGLRenderingContext {
  80552. readonly RASTERIZER_DISCARD: number;
  80553. readonly DEPTH_COMPONENT24: number;
  80554. readonly TEXTURE_3D: number;
  80555. readonly TEXTURE_2D_ARRAY: number;
  80556. readonly TEXTURE_COMPARE_FUNC: number;
  80557. readonly TEXTURE_COMPARE_MODE: number;
  80558. readonly COMPARE_REF_TO_TEXTURE: number;
  80559. readonly TEXTURE_WRAP_R: number;
  80560. readonly HALF_FLOAT: number;
  80561. readonly RGB8: number;
  80562. readonly RED_INTEGER: number;
  80563. readonly RG_INTEGER: number;
  80564. readonly RGB_INTEGER: number;
  80565. readonly RGBA_INTEGER: number;
  80566. readonly R8_SNORM: number;
  80567. readonly RG8_SNORM: number;
  80568. readonly RGB8_SNORM: number;
  80569. readonly RGBA8_SNORM: number;
  80570. readonly R8I: number;
  80571. readonly RG8I: number;
  80572. readonly RGB8I: number;
  80573. readonly RGBA8I: number;
  80574. readonly R8UI: number;
  80575. readonly RG8UI: number;
  80576. readonly RGB8UI: number;
  80577. readonly RGBA8UI: number;
  80578. readonly R16I: number;
  80579. readonly RG16I: number;
  80580. readonly RGB16I: number;
  80581. readonly RGBA16I: number;
  80582. readonly R16UI: number;
  80583. readonly RG16UI: number;
  80584. readonly RGB16UI: number;
  80585. readonly RGBA16UI: number;
  80586. readonly R32I: number;
  80587. readonly RG32I: number;
  80588. readonly RGB32I: number;
  80589. readonly RGBA32I: number;
  80590. readonly R32UI: number;
  80591. readonly RG32UI: number;
  80592. readonly RGB32UI: number;
  80593. readonly RGBA32UI: number;
  80594. readonly RGB10_A2UI: number;
  80595. readonly R11F_G11F_B10F: number;
  80596. readonly RGB9_E5: number;
  80597. readonly RGB10_A2: number;
  80598. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80599. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80600. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80601. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80602. readonly DEPTH_COMPONENT32F: number;
  80603. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80604. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80605. 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;
  80606. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80607. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80608. readonly TRANSFORM_FEEDBACK: number;
  80609. readonly INTERLEAVED_ATTRIBS: number;
  80610. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80611. createTransformFeedback(): WebGLTransformFeedback;
  80612. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80613. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80614. beginTransformFeedback(primitiveMode: number): void;
  80615. endTransformFeedback(): void;
  80616. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80617. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80618. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80619. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80620. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80621. }
  80622. interface ImageBitmap {
  80623. readonly width: number;
  80624. readonly height: number;
  80625. close(): void;
  80626. }
  80627. interface WebGLQuery extends WebGLObject {
  80628. }
  80629. declare var WebGLQuery: {
  80630. prototype: WebGLQuery;
  80631. new(): WebGLQuery;
  80632. };
  80633. interface WebGLSampler extends WebGLObject {
  80634. }
  80635. declare var WebGLSampler: {
  80636. prototype: WebGLSampler;
  80637. new(): WebGLSampler;
  80638. };
  80639. interface WebGLSync extends WebGLObject {
  80640. }
  80641. declare var WebGLSync: {
  80642. prototype: WebGLSync;
  80643. new(): WebGLSync;
  80644. };
  80645. interface WebGLTransformFeedback extends WebGLObject {
  80646. }
  80647. declare var WebGLTransformFeedback: {
  80648. prototype: WebGLTransformFeedback;
  80649. new(): WebGLTransformFeedback;
  80650. };
  80651. interface WebGLVertexArrayObject extends WebGLObject {
  80652. }
  80653. declare var WebGLVertexArrayObject: {
  80654. prototype: WebGLVertexArrayObject;
  80655. new(): WebGLVertexArrayObject;
  80656. };
  80657. interface Navigator {
  80658. readonly gpu: GPU | undefined;
  80659. }
  80660. interface GPUColorDict {
  80661. a: number;
  80662. b: number;
  80663. g: number;
  80664. r: number;
  80665. }
  80666. type GPUColor = [number, number, number, number] | GPUColorDict;
  80667. interface GPUOrigin2DDict {
  80668. x?: number;
  80669. y?: number;
  80670. }
  80671. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80672. interface GPUOrigin3DDict {
  80673. x?: number;
  80674. y?: number;
  80675. z?: number;
  80676. }
  80677. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80678. interface GPUExtent3DDict {
  80679. width: number;
  80680. height: number;
  80681. depth: number;
  80682. }
  80683. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80684. type GPUBindingResource =
  80685. | GPUSampler
  80686. | GPUTextureView
  80687. | GPUBufferBinding;
  80688. type GPUExtensionName =
  80689. | "texture-compression-bc"
  80690. | "timestamp-query"
  80691. | "pipeline-statistics-query"
  80692. | "depth-clamping"
  80693. | "depth24unorm-stencil8"
  80694. | "depth32float-stencil8";
  80695. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80696. type GPUBindingType =
  80697. | "uniform-buffer"
  80698. | "storage-buffer"
  80699. | "readonly-storage-buffer"
  80700. | "sampler"
  80701. | "comparison-sampler"
  80702. | "sampled-texture"
  80703. | "readonly-storage-texture"
  80704. | "writeonly-storage-texture";
  80705. type GPUBlendFactor =
  80706. | "zero"
  80707. | "one"
  80708. | "src-color"
  80709. | "one-minus-src-color"
  80710. | "src-alpha"
  80711. | "one-minus-src-alpha"
  80712. | "dst-color"
  80713. | "one-minus-dst-color"
  80714. | "dst-alpha"
  80715. | "one-minus-dst-alpha"
  80716. | "src-alpha-saturated"
  80717. | "blend-color"
  80718. | "one-minus-blend-color";
  80719. type GPUBlendOperation =
  80720. | "add"
  80721. | "subtract"
  80722. | "reverse-subtract"
  80723. | "min"
  80724. | "max";
  80725. type GPUCompareFunction =
  80726. | "never"
  80727. | "less"
  80728. | "equal"
  80729. | "less-equal"
  80730. | "greater"
  80731. | "not-equal"
  80732. | "greater-equal"
  80733. | "always";
  80734. type GPUCullMode = "none" | "front" | "back";
  80735. type GPUFilterMode = "nearest" | "linear";
  80736. type GPUFrontFace = "ccw" | "cw";
  80737. type GPUIndexFormat = "uint16" | "uint32";
  80738. type GPUInputStepMode = "vertex" | "instance";
  80739. type GPULoadOp = "load";
  80740. type GPUPrimitiveTopology =
  80741. | "point-list"
  80742. | "line-list"
  80743. | "line-strip"
  80744. | "triangle-list"
  80745. | "triangle-strip";
  80746. type GPUStencilOperation =
  80747. | "keep"
  80748. | "zero"
  80749. | "replace"
  80750. | "invert"
  80751. | "increment-clamp"
  80752. | "decrement-clamp"
  80753. | "increment-wrap"
  80754. | "decrement-wrap";
  80755. type GPUStoreOp = "store" | "clear";
  80756. type GPUTextureDimension = "1d" | "2d" | "3d";
  80757. type GPUTextureFormat =
  80758. | "r8unorm"
  80759. | "r8snorm"
  80760. | "r8uint"
  80761. | "r8sint"
  80762. | "r16uint"
  80763. | "r16sint"
  80764. | "r16float"
  80765. | "rg8unorm"
  80766. | "rg8snorm"
  80767. | "rg8uint"
  80768. | "rg8sint"
  80769. | "r32uint"
  80770. | "r32sint"
  80771. | "r32float"
  80772. | "rg16uint"
  80773. | "rg16sint"
  80774. | "rg16float"
  80775. | "rgba8unorm"
  80776. | "rgba8unorm-srgb"
  80777. | "rgba8snorm"
  80778. | "rgba8uint"
  80779. | "rgba8sint"
  80780. | "bgra8unorm"
  80781. | "bgra8unorm-srgb"
  80782. | "rgb9e5ufloat"
  80783. | "rgb10a2unorm"
  80784. | "rg11b10ufloat"
  80785. | "rg32uint"
  80786. | "rg32sint"
  80787. | "rg32float"
  80788. | "rgba16uint"
  80789. | "rgba16sint"
  80790. | "rgba16float"
  80791. | "rgba32uint"
  80792. | "rgba32sint"
  80793. | "rgba32float"
  80794. | "stencil8"
  80795. | "depth16unorm"
  80796. | "depth24plus"
  80797. | "depth24plus-stencil8"
  80798. | "depth32float"
  80799. | "bc1-rgba-unorm"
  80800. | "bc1-rgba-unorm-srgb"
  80801. | "bc2-rgba-unorm"
  80802. | "bc2-rgba-unorm-srgb"
  80803. | "bc3-rgba-unorm"
  80804. | "bc3-rgba-unorm-srgb"
  80805. | "bc4-r-unorm"
  80806. | "bc4-r-snorm"
  80807. | "bc5-rg-unorm"
  80808. | "bc5-rg-snorm"
  80809. | "bc6h-rgb-ufloat"
  80810. | "bc6h-rgb-float"
  80811. | "bc7-rgba-unorm"
  80812. | "bc7-rgba-unorm-srgb"
  80813. | "depth24unorm-stencil8"
  80814. | "depth32float-stencil8";
  80815. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80816. type GPUTextureViewDimension =
  80817. | "1d"
  80818. | "2d"
  80819. | "2d-array"
  80820. | "cube"
  80821. | "cube-array"
  80822. | "3d";
  80823. type GPUVertexFormat =
  80824. | "uchar2"
  80825. | "uchar4"
  80826. | "char2"
  80827. | "char4"
  80828. | "uchar2norm"
  80829. | "uchar4norm"
  80830. | "char2norm"
  80831. | "char4norm"
  80832. | "ushort2"
  80833. | "ushort4"
  80834. | "short2"
  80835. | "short4"
  80836. | "ushort2norm"
  80837. | "ushort4norm"
  80838. | "short2norm"
  80839. | "short4norm"
  80840. | "half2"
  80841. | "half4"
  80842. | "float"
  80843. | "float2"
  80844. | "float3"
  80845. | "float4"
  80846. | "uint"
  80847. | "uint2"
  80848. | "uint3"
  80849. | "uint4"
  80850. | "int"
  80851. | "int2"
  80852. | "int3"
  80853. | "int4";
  80854. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80855. type GPUBufferUsageFlags = number;
  80856. type GPUColorWriteFlags = number;
  80857. type GPUShaderStageFlags = number;
  80858. type GPUTextureUsageFlags = number;
  80859. type GPUMapModeFlags = number;
  80860. interface GPUBindGroupEntry {
  80861. binding: number;
  80862. resource: GPUBindingResource;
  80863. }
  80864. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80865. layout: GPUBindGroupLayout;
  80866. entries: Iterable<GPUBindGroupEntry>;
  80867. }
  80868. interface GPUBindGroupLayoutEntry {
  80869. binding: number;
  80870. visibility: GPUShaderStageFlags;
  80871. type: GPUBindingType;
  80872. hasDynamicOffset?: boolean;
  80873. minBufferBindingSize?: number;
  80874. viewDimension?: GPUTextureViewDimension;
  80875. textureComponentType?: GPUTextureComponentType;
  80876. storageTextureFormat?: GPUTextureFormat;
  80877. }
  80878. interface GPUBindGroupLayoutDescriptor
  80879. extends GPUObjectDescriptorBase {
  80880. entries: Iterable<GPUBindGroupLayoutEntry>;
  80881. }
  80882. interface GPUBlendDescriptor {
  80883. dstFactor?: GPUBlendFactor;
  80884. operation?: GPUBlendOperation;
  80885. srcFactor?: GPUBlendFactor;
  80886. }
  80887. interface GPUColorStateDescriptor {
  80888. format: GPUTextureFormat;
  80889. alphaBlend?: GPUBlendDescriptor;
  80890. colorBlend?: GPUBlendDescriptor;
  80891. writeMask?: GPUColorWriteFlags;
  80892. }
  80893. interface GPUBufferBinding {
  80894. buffer: GPUBuffer;
  80895. offset?: number;
  80896. size?: number;
  80897. }
  80898. interface GPUTextureDataLayout {
  80899. offset?: number;
  80900. bytesPerRow: number;
  80901. rowsPerImage?: number;
  80902. }
  80903. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80904. buffer: GPUBuffer;
  80905. }
  80906. interface GPUTextureCopyView {
  80907. texture: GPUTexture;
  80908. mipLevel?: number;
  80909. origin?: GPUOrigin3D;
  80910. }
  80911. interface GPUImageBitmapCopyView {
  80912. imageBitmap: ImageBitmap;
  80913. origin?: GPUOrigin2D;
  80914. }
  80915. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  80916. size: number;
  80917. usage: GPUBufferUsageFlags;
  80918. mappedAtCreation?: boolean;
  80919. }
  80920. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  80921. label?: string;
  80922. measureExecutionTime?: boolean;
  80923. }
  80924. interface GPUComputePipelineDescriptor
  80925. extends GPUPipelineDescriptorBase {
  80926. computeStage: GPUProgrammableStageDescriptor;
  80927. }
  80928. interface GPUDepthStencilStateDescriptor {
  80929. format: GPUTextureFormat;
  80930. depthWriteEnabled?: boolean;
  80931. depthCompare?: GPUCompareFunction;
  80932. stencilFront?: GPUStencilStateFaceDescriptor;
  80933. stencilBack?: GPUStencilStateFaceDescriptor;
  80934. stencilReadMask?: number;
  80935. stencilWriteMask?: number;
  80936. }
  80937. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  80938. extensions?: Iterable<GPUExtensionName>;
  80939. limits?: GPULimits;
  80940. }
  80941. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  80942. initialValue?: number;
  80943. label?: string;
  80944. signalQueue?: GPUQueue;
  80945. }
  80946. interface GPUVertexAttributeDescriptor {
  80947. format: GPUVertexFormat;
  80948. offset: number;
  80949. shaderLocation: number;
  80950. }
  80951. interface GPUVertexBufferLayoutDescriptor {
  80952. arrayStride: number;
  80953. stepMode?: GPUInputStepMode;
  80954. attributes: Iterable<GPUVertexAttributeDescriptor>;
  80955. }
  80956. interface GPUVertexStateDescriptor {
  80957. indexFormat?: GPUIndexFormat;
  80958. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  80959. }
  80960. interface GPULimits {
  80961. maxBindGroups?: number;
  80962. maxDynamicUniformBuffersPerPipelineLayout?: number;
  80963. maxDynamicStorageBuffersPerPipelineLayout?: number;
  80964. maxSampledTexturesPerShaderStage?: number;
  80965. maxSamplersPerShaderStage?: number;
  80966. maxStorageBuffersPerShaderStage?: number;
  80967. maxStorageTexturesPerShaderStage?: number;
  80968. maxUniformBuffersPerShaderStage?: number;
  80969. maxUniformBufferBindingSize?: number;
  80970. }
  80971. interface GPUPipelineDescriptorBase {
  80972. label?: string;
  80973. layout?: GPUPipelineLayout;
  80974. }
  80975. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  80976. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  80977. }
  80978. interface GPUProgrammableStageDescriptor {
  80979. module: GPUShaderModule;
  80980. entryPoint: string;
  80981. }
  80982. interface GPURasterizationStateDescriptor {
  80983. frontFace?: GPUFrontFace;
  80984. cullMode?: GPUCullMode;
  80985. clampDepth?: boolean;
  80986. depthBias?: number;
  80987. depthBiasSlopeScale?: number;
  80988. depthBiasClamp?: number;
  80989. }
  80990. interface GPURenderPassColorAttachmentDescriptor {
  80991. attachment: GPUTextureView;
  80992. resolveTarget?: GPUTextureView;
  80993. loadValue: GPULoadOp | GPUColor;
  80994. storeOp?: GPUStoreOp;
  80995. }
  80996. interface GPURenderPassDepthStencilAttachmentDescriptor {
  80997. attachment: GPUTextureView;
  80998. depthLoadValue: GPULoadOp | number;
  80999. depthStoreOp: GPUStoreOp;
  81000. depthReadOnly?: boolean;
  81001. stencilLoadValue: GPULoadOp | number;
  81002. stencilStoreOp: GPUStoreOp;
  81003. stencilReadOnly?: boolean;
  81004. }
  81005. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81006. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81007. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81008. }
  81009. interface GPURenderPipelineDescriptor
  81010. extends GPUPipelineDescriptorBase {
  81011. vertexStage: GPUProgrammableStageDescriptor;
  81012. fragmentStage?: GPUProgrammableStageDescriptor;
  81013. primitiveTopology: GPUPrimitiveTopology;
  81014. rasterizationState?: GPURasterizationStateDescriptor;
  81015. colorStates: Iterable<GPUColorStateDescriptor>;
  81016. depthStencilState?: GPUDepthStencilStateDescriptor;
  81017. vertexState?: GPUVertexStateDescriptor;
  81018. sampleCount?: number;
  81019. sampleMask?: number;
  81020. alphaToCoverageEnabled?: boolean;
  81021. }
  81022. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81023. addressModeU?: GPUAddressMode;
  81024. addressModeV?: GPUAddressMode;
  81025. addressModeW?: GPUAddressMode;
  81026. magFilter?: GPUFilterMode;
  81027. minFilter?: GPUFilterMode;
  81028. mipmapFilter?: GPUFilterMode;
  81029. lodMinClamp?: number;
  81030. lodMaxClamp?: number;
  81031. compare?: GPUCompareFunction;
  81032. maxAnisotropy?: number;
  81033. }
  81034. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81035. code: Uint32Array | string;
  81036. label?: string;
  81037. sourceMap?: object;
  81038. }
  81039. interface GPUStencilStateFaceDescriptor {
  81040. compare?: GPUCompareFunction;
  81041. depthFailOp?: GPUStencilOperation;
  81042. passOp?: GPUStencilOperation;
  81043. failOp?: GPUStencilOperation;
  81044. }
  81045. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81046. device: GPUDevice;
  81047. format: GPUTextureFormat;
  81048. usage?: GPUTextureUsageFlags;
  81049. }
  81050. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81051. size: GPUExtent3D;
  81052. mipLevelCount?: number;
  81053. sampleCount?: number;
  81054. dimension?: GPUTextureDimension;
  81055. format: GPUTextureFormat;
  81056. usage: GPUTextureUsageFlags;
  81057. }
  81058. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81059. format?: GPUTextureFormat;
  81060. dimension?: GPUTextureViewDimension;
  81061. aspect?: GPUTextureAspect;
  81062. baseArrayLayer?: number;
  81063. baseMipLevel?: number;
  81064. arrayLayerCount?: number;
  81065. mipLevelCount?: number;
  81066. }
  81067. declare class GPUAdapter {
  81068. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81069. private __brand: void;
  81070. readonly name: string;
  81071. readonly extensions: GPUExtensionName[];
  81072. readonly limits: Required<GPULimits>;
  81073. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81074. }
  81075. declare class GPUBindGroup implements GPUObjectBase {
  81076. private __brand: void;
  81077. label: string | undefined;
  81078. }
  81079. declare class GPUBindGroupLayout implements GPUObjectBase {
  81080. private __brand: void;
  81081. label: string | undefined;
  81082. }
  81083. declare class GPUBuffer implements GPUObjectBase {
  81084. private __brand: void;
  81085. label: string | undefined;
  81086. destroy(): void;
  81087. unmap(): void;
  81088. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81089. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81090. }
  81091. declare class GPUCommandBuffer implements GPUObjectBase {
  81092. private __brand: void;
  81093. label: string | undefined;
  81094. readonly executionTime: Promise<number>;
  81095. }
  81096. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81097. declare class GPUCommandEncoder implements GPUObjectBase {
  81098. private __brand: void;
  81099. label: string | undefined;
  81100. beginComputePass(
  81101. descriptor?: GPUComputePassDescriptor
  81102. ): GPUComputePassEncoder;
  81103. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81104. copyBufferToBuffer(
  81105. source: GPUBuffer,
  81106. sourceOffset: number,
  81107. destination: GPUBuffer,
  81108. destinationOffset: number,
  81109. size: number
  81110. ): void;
  81111. copyBufferToTexture(
  81112. source: GPUBufferCopyView,
  81113. destination: GPUTextureCopyView,
  81114. copySize: GPUExtent3D
  81115. ): void;
  81116. copyTextureToBuffer(
  81117. source: GPUTextureCopyView,
  81118. destination: GPUBufferCopyView,
  81119. copySize: GPUExtent3D
  81120. ): void;
  81121. copyTextureToTexture(
  81122. source: GPUTextureCopyView,
  81123. destination: GPUTextureCopyView,
  81124. copySize: GPUExtent3D
  81125. ): void;
  81126. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81127. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81128. popDebugGroup(): void;
  81129. pushDebugGroup(groupLabel: string): void;
  81130. insertDebugMarker(markerLabel: string): void;
  81131. }
  81132. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81133. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81134. private __brand: void;
  81135. label: string | undefined;
  81136. setBindGroup(
  81137. index: number,
  81138. bindGroup: GPUBindGroup,
  81139. dynamicOffsets?: Iterable<number>
  81140. ): void;
  81141. popDebugGroup(): void;
  81142. pushDebugGroup(groupLabel: string): void;
  81143. insertDebugMarker(markerLabel: string): void;
  81144. setPipeline(pipeline: GPUComputePipeline): void;
  81145. dispatch(x: number, y?: number, z?: number): void;
  81146. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81147. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81148. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81149. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81150. endPass(): void;
  81151. }
  81152. declare class GPUComputePipeline implements GPUPipelineBase {
  81153. private __brand: void;
  81154. label: string | undefined;
  81155. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81156. }
  81157. interface GPUObjectBase {
  81158. label: string | undefined;
  81159. }
  81160. interface GPUObjectDescriptorBase {
  81161. label?: string;
  81162. }
  81163. // SwapChain / CanvasContext
  81164. declare class GPUCanvasContext {
  81165. private __brand: void;
  81166. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81167. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81168. }
  81169. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81170. private __brand: void;
  81171. label: string | undefined;
  81172. readonly adapter: GPUAdapter;
  81173. readonly extensions: GPUExtensionName[];
  81174. readonly limits: Required<GPULimits>;
  81175. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81176. createBindGroupLayout(
  81177. descriptor: GPUBindGroupLayoutDescriptor
  81178. ): GPUBindGroupLayout;
  81179. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81180. createPipelineLayout(
  81181. descriptor: GPUPipelineLayoutDescriptor
  81182. ): GPUPipelineLayout;
  81183. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81184. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81185. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81186. createComputePipeline(
  81187. descriptor: GPUComputePipelineDescriptor
  81188. ): GPUComputePipeline;
  81189. createRenderPipeline(
  81190. descriptor: GPURenderPipelineDescriptor
  81191. ): GPURenderPipeline;
  81192. createReadyComputePipeline(
  81193. descriptor: GPUComputePipelineDescriptor
  81194. ): Promise<GPUComputePipeline>;
  81195. createReadyRenderPipeline(
  81196. descriptor: GPURenderPipelineDescriptor
  81197. ): Promise<GPURenderPipeline>;
  81198. createCommandEncoder(
  81199. descriptor?: GPUCommandEncoderDescriptor
  81200. ): GPUCommandEncoder;
  81201. createRenderBundleEncoder(
  81202. descriptor: GPURenderBundleEncoderDescriptor
  81203. ): GPURenderBundleEncoder;
  81204. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81205. defaultQueue: GPUQueue;
  81206. pushErrorScope(filter: GPUErrorFilter): void;
  81207. popErrorScope(): Promise<GPUError | null>;
  81208. onuncapturederror: Event | undefined;
  81209. readonly lost: Promise<GPUDeviceLostInfo>;
  81210. }
  81211. declare class GPUFence implements GPUObjectBase {
  81212. private __brand: void;
  81213. label: string | undefined;
  81214. getCompletedValue(): number;
  81215. onCompletion(completionValue: number): Promise<void>;
  81216. }
  81217. interface GPUPipelineBase extends GPUObjectBase {
  81218. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81219. }
  81220. declare class GPUPipelineLayout implements GPUObjectBase {
  81221. private __brand: void;
  81222. label: string | undefined;
  81223. }
  81224. interface GPUProgrammablePassEncoder {
  81225. setBindGroup(
  81226. index: number,
  81227. bindGroup: GPUBindGroup,
  81228. dynamicOffsets?: Iterable<number>
  81229. ): void;
  81230. popDebugGroup(): void;
  81231. pushDebugGroup(groupLabel: string): void;
  81232. insertDebugMarker(markerLabel: string): void;
  81233. }
  81234. declare class GPUQueue implements GPUObjectBase {
  81235. private __brand: void;
  81236. label: string | undefined;
  81237. signal(fence: GPUFence, signalValue: number): void;
  81238. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81239. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81240. writeBuffer(buffer: GPUBuffer,
  81241. bufferOffset: number,
  81242. data: BufferSource | ArrayBuffer,
  81243. dataOffset?: number,
  81244. size?: number): void;
  81245. writeTexture(destination: GPUTextureCopyView,
  81246. data: BufferSource | ArrayBuffer,
  81247. dataLayout: GPUTextureDataLayout,
  81248. size: GPUExtent3D): void;
  81249. copyImageBitmapToTexture(
  81250. source: GPUImageBitmapCopyView,
  81251. destination: GPUTextureCopyView,
  81252. copySize: GPUExtent3D
  81253. ): void;
  81254. }
  81255. type GPUQueryType =
  81256. | "occlusion"
  81257. | "timestamp"
  81258. | "pipeline-statistics";
  81259. type GPUPipelineStatisticName =
  81260. | "vertex-shader-invocations"
  81261. | "clipper-invocations"
  81262. | "clipper-primitives-out"
  81263. | "fragment-shader-invocations"
  81264. | "compute-shader-invocations";
  81265. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81266. type: GPUQueryType;
  81267. count: number;
  81268. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81269. }
  81270. declare class GPUQuerySet implements GPUObjectBase {
  81271. private __brand: void;
  81272. label: string | undefined;
  81273. destroy(): void;
  81274. }
  81275. interface GPURenderEncoderBase {
  81276. setPipeline(pipeline: GPURenderPipeline): void;
  81277. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81278. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81279. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81280. draw(
  81281. vertexCount: number,
  81282. instanceCount?: number,
  81283. firstVertex?: number,
  81284. firstInstance?: number
  81285. ): void;
  81286. drawIndexed(
  81287. indexCount: number,
  81288. instanceCount?: number,
  81289. firstIndex?: number,
  81290. baseVertex?: number,
  81291. firstInstance?: number
  81292. ): void;
  81293. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81294. drawIndexedIndirect(
  81295. indirectBuffer: GPUBuffer,
  81296. indirectOffset: number
  81297. ): void;
  81298. }
  81299. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81300. private __brand: void;
  81301. label: string | undefined;
  81302. setBindGroup(
  81303. index: number,
  81304. bindGroup: GPUBindGroup,
  81305. dynamicOffsets?: Iterable<number>
  81306. ): void;
  81307. popDebugGroup(): void;
  81308. pushDebugGroup(groupLabel: string): void;
  81309. insertDebugMarker(markerLabel: string): void;
  81310. setPipeline(pipeline: GPURenderPipeline): void;
  81311. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81312. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81313. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81314. draw(
  81315. vertexCount: number,
  81316. instanceCount?: number,
  81317. firstVertex?: number,
  81318. firstInstance?: number
  81319. ): void;
  81320. drawIndexed(
  81321. indexCount: number,
  81322. instanceCount?: number,
  81323. firstIndex?: number,
  81324. baseVertex?: number,
  81325. firstInstance?: number
  81326. ): void;
  81327. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81328. drawIndexedIndirect(
  81329. indirectBuffer: GPUBuffer,
  81330. indirectOffset: number
  81331. ): void;
  81332. setViewport(
  81333. x: number,
  81334. y: number,
  81335. width: number,
  81336. height: number,
  81337. minDepth: number,
  81338. maxDepth: number
  81339. ): void;
  81340. setScissorRect(x: number, y: number, width: number, height: number): void;
  81341. setBlendColor(color: GPUColor): void;
  81342. setStencilReference(reference: number): void;
  81343. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81344. beginOcclusionQuery(queryIndex: number): void;
  81345. endOcclusionQuery(): void;
  81346. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81347. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81348. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81349. endPass(): void;
  81350. }
  81351. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81352. declare class GPURenderBundle implements GPUObjectBase {
  81353. private __brand: void;
  81354. label: string | undefined;
  81355. }
  81356. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81357. private __brand: void;
  81358. label: string | undefined;
  81359. setBindGroup(
  81360. index: number,
  81361. bindGroup: GPUBindGroup,
  81362. dynamicOffsets?: Iterable<number>
  81363. ): void;
  81364. popDebugGroup(): void;
  81365. pushDebugGroup(groupLabel: string): void;
  81366. insertDebugMarker(markerLabel: string): void;
  81367. setPipeline(pipeline: GPURenderPipeline): void;
  81368. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81369. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81370. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81371. draw(
  81372. vertexCount: number,
  81373. instanceCount?: number,
  81374. firstVertex?: number,
  81375. firstInstance?: number
  81376. ): void;
  81377. drawIndexed(
  81378. indexCount: number,
  81379. instanceCount?: number,
  81380. firstIndex?: number,
  81381. baseVertex?: number,
  81382. firstInstance?: number
  81383. ): void;
  81384. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81385. drawIndexedIndirect(
  81386. indirectBuffer: GPUBuffer,
  81387. indirectOffset: number
  81388. ): void;
  81389. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81390. }
  81391. interface GPURenderBundleEncoderDescriptor
  81392. extends GPUObjectDescriptorBase {
  81393. colorFormats: Iterable<GPUTextureFormat>;
  81394. depthStencilFormat?: GPUTextureFormat;
  81395. sampleCount?: number;
  81396. }
  81397. declare class GPURenderPipeline implements GPUPipelineBase {
  81398. private __brand: void;
  81399. label: string | undefined;
  81400. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81401. }
  81402. declare class GPUSampler implements GPUObjectBase {
  81403. private __brand: void;
  81404. label: string | undefined;
  81405. }
  81406. type GPUCompilationMessageType =
  81407. | "error"
  81408. | "warning"
  81409. | "info";
  81410. interface GPUCompilationMessage {
  81411. readonly message: string;
  81412. readonly type: GPUCompilationMessageType;
  81413. readonly lineNum: number;
  81414. readonly linePos: number;
  81415. }
  81416. interface GPUCompilationInfo {
  81417. readonly messages: readonly GPUCompilationMessage[];
  81418. }
  81419. declare class GPUShaderModule implements GPUObjectBase {
  81420. private __brand: void;
  81421. label: string | undefined;
  81422. compilationInfo(): Promise<GPUCompilationInfo>;
  81423. }
  81424. declare class GPUSwapChain implements GPUObjectBase {
  81425. private __brand: void;
  81426. label: string | undefined;
  81427. getCurrentTexture(): GPUTexture;
  81428. }
  81429. declare class GPUTexture implements GPUObjectBase {
  81430. private __brand: void;
  81431. label: string | undefined;
  81432. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81433. destroy(): void;
  81434. }
  81435. declare class GPUTextureView implements GPUObjectBase {
  81436. private __brand: void;
  81437. label: string | undefined;
  81438. }
  81439. type GPUPowerPreference = "low-power" | "high-performance";
  81440. interface GPURequestAdapterOptions {
  81441. powerPreference?: GPUPowerPreference;
  81442. }
  81443. declare class GPU {
  81444. private __brand: void;
  81445. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81446. }
  81447. // ****************************************************************************
  81448. // ERROR SCOPES
  81449. // ****************************************************************************
  81450. type GPUErrorFilter = "out-of-memory" | "validation";
  81451. declare class GPUOutOfMemoryError {
  81452. private __brand: void;
  81453. constructor();
  81454. }
  81455. declare class GPUValidationError {
  81456. private __brand: void;
  81457. constructor(message: string);
  81458. readonly message: string;
  81459. }
  81460. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81461. // ****************************************************************************
  81462. // TELEMETRY
  81463. // ****************************************************************************
  81464. declare class GPUUncapturedErrorEvent extends Event {
  81465. private __brand: void;
  81466. constructor(
  81467. type: string,
  81468. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81469. );
  81470. readonly error: GPUError;
  81471. }
  81472. interface GPUUncapturedErrorEventInit extends EventInit {
  81473. error: GPUError;
  81474. }
  81475. declare class GPUDeviceLostInfo {
  81476. private __brand: void;
  81477. readonly message: string;
  81478. }
  81479. // Type definitions for WebVR API
  81480. // Project: https://w3c.github.io/webvr/
  81481. // Definitions by: six a <https://github.com/lostfictions>
  81482. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81483. interface VRDisplay extends EventTarget {
  81484. /**
  81485. * Dictionary of capabilities describing the VRDisplay.
  81486. */
  81487. readonly capabilities: VRDisplayCapabilities;
  81488. /**
  81489. * z-depth defining the far plane of the eye view frustum
  81490. * enables mapping of values in the render target depth
  81491. * attachment to scene coordinates. Initially set to 10000.0.
  81492. */
  81493. depthFar: number;
  81494. /**
  81495. * z-depth defining the near plane of the eye view frustum
  81496. * enables mapping of values in the render target depth
  81497. * attachment to scene coordinates. Initially set to 0.01.
  81498. */
  81499. depthNear: number;
  81500. /**
  81501. * An identifier for this distinct VRDisplay. Used as an
  81502. * association point in the Gamepad API.
  81503. */
  81504. readonly displayId: number;
  81505. /**
  81506. * A display name, a user-readable name identifying it.
  81507. */
  81508. readonly displayName: string;
  81509. readonly isConnected: boolean;
  81510. readonly isPresenting: boolean;
  81511. /**
  81512. * If this VRDisplay supports room-scale experiences, the optional
  81513. * stage attribute contains details on the room-scale parameters.
  81514. */
  81515. readonly stageParameters: VRStageParameters | null;
  81516. /**
  81517. * Passing the value returned by `requestAnimationFrame` to
  81518. * `cancelAnimationFrame` will unregister the callback.
  81519. * @param handle Define the hanle of the request to cancel
  81520. */
  81521. cancelAnimationFrame(handle: number): void;
  81522. /**
  81523. * Stops presenting to the VRDisplay.
  81524. * @returns a promise to know when it stopped
  81525. */
  81526. exitPresent(): Promise<void>;
  81527. /**
  81528. * Return the current VREyeParameters for the given eye.
  81529. * @param whichEye Define the eye we want the parameter for
  81530. * @returns the eye parameters
  81531. */
  81532. getEyeParameters(whichEye: string): VREyeParameters;
  81533. /**
  81534. * Populates the passed VRFrameData with the information required to render
  81535. * the current frame.
  81536. * @param frameData Define the data structure to populate
  81537. * @returns true if ok otherwise false
  81538. */
  81539. getFrameData(frameData: VRFrameData): boolean;
  81540. /**
  81541. * Get the layers currently being presented.
  81542. * @returns the list of VR layers
  81543. */
  81544. getLayers(): VRLayer[];
  81545. /**
  81546. * Return a VRPose containing the future predicted pose of the VRDisplay
  81547. * when the current frame will be presented. The value returned will not
  81548. * change until JavaScript has returned control to the browser.
  81549. *
  81550. * The VRPose will contain the position, orientation, velocity,
  81551. * and acceleration of each of these properties.
  81552. * @returns the pose object
  81553. */
  81554. getPose(): VRPose;
  81555. /**
  81556. * Return the current instantaneous pose of the VRDisplay, with no
  81557. * prediction applied.
  81558. * @returns the current instantaneous pose
  81559. */
  81560. getImmediatePose(): VRPose;
  81561. /**
  81562. * The callback passed to `requestAnimationFrame` will be called
  81563. * any time a new frame should be rendered. When the VRDisplay is
  81564. * presenting the callback will be called at the native refresh
  81565. * rate of the HMD. When not presenting this function acts
  81566. * identically to how window.requestAnimationFrame acts. Content should
  81567. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81568. * asynchronously from other displays and at differing refresh rates.
  81569. * @param callback Define the eaction to run next frame
  81570. * @returns the request handle it
  81571. */
  81572. requestAnimationFrame(callback: FrameRequestCallback): number;
  81573. /**
  81574. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81575. * Repeat calls while already presenting will update the VRLayers being displayed.
  81576. * @param layers Define the list of layer to present
  81577. * @returns a promise to know when the request has been fulfilled
  81578. */
  81579. requestPresent(layers: VRLayer[]): Promise<void>;
  81580. /**
  81581. * Reset the pose for this display, treating its current position and
  81582. * orientation as the "origin/zero" values. VRPose.position,
  81583. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81584. * updated when calling resetPose(). This should be called in only
  81585. * sitting-space experiences.
  81586. */
  81587. resetPose(): void;
  81588. /**
  81589. * The VRLayer provided to the VRDisplay will be captured and presented
  81590. * in the HMD. Calling this function has the same effect on the source
  81591. * canvas as any other operation that uses its source image, and canvases
  81592. * created without preserveDrawingBuffer set to true will be cleared.
  81593. * @param pose Define the pose to submit
  81594. */
  81595. submitFrame(pose?: VRPose): void;
  81596. }
  81597. declare var VRDisplay: {
  81598. prototype: VRDisplay;
  81599. new(): VRDisplay;
  81600. };
  81601. interface VRLayer {
  81602. leftBounds?: number[] | Float32Array | null;
  81603. rightBounds?: number[] | Float32Array | null;
  81604. source?: HTMLCanvasElement | null;
  81605. }
  81606. interface VRDisplayCapabilities {
  81607. readonly canPresent: boolean;
  81608. readonly hasExternalDisplay: boolean;
  81609. readonly hasOrientation: boolean;
  81610. readonly hasPosition: boolean;
  81611. readonly maxLayers: number;
  81612. }
  81613. interface VREyeParameters {
  81614. /** @deprecated */
  81615. readonly fieldOfView: VRFieldOfView;
  81616. readonly offset: Float32Array;
  81617. readonly renderHeight: number;
  81618. readonly renderWidth: number;
  81619. }
  81620. interface VRFieldOfView {
  81621. readonly downDegrees: number;
  81622. readonly leftDegrees: number;
  81623. readonly rightDegrees: number;
  81624. readonly upDegrees: number;
  81625. }
  81626. interface VRFrameData {
  81627. readonly leftProjectionMatrix: Float32Array;
  81628. readonly leftViewMatrix: Float32Array;
  81629. readonly pose: VRPose;
  81630. readonly rightProjectionMatrix: Float32Array;
  81631. readonly rightViewMatrix: Float32Array;
  81632. readonly timestamp: number;
  81633. }
  81634. interface VRPose {
  81635. readonly angularAcceleration: Float32Array | null;
  81636. readonly angularVelocity: Float32Array | null;
  81637. readonly linearAcceleration: Float32Array | null;
  81638. readonly linearVelocity: Float32Array | null;
  81639. readonly orientation: Float32Array | null;
  81640. readonly position: Float32Array | null;
  81641. readonly timestamp: number;
  81642. }
  81643. interface VRStageParameters {
  81644. sittingToStandingTransform?: Float32Array;
  81645. sizeX?: number;
  81646. sizeY?: number;
  81647. }
  81648. interface Navigator {
  81649. getVRDisplays(): Promise<VRDisplay[]>;
  81650. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81651. }
  81652. interface Window {
  81653. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81654. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81655. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81656. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81657. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81658. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81659. }
  81660. interface Gamepad {
  81661. readonly displayId: number;
  81662. }
  81663. /**
  81664. * Available session modes
  81665. */
  81666. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81667. /**
  81668. * Reference space types
  81669. */
  81670. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81671. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81672. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81673. /**
  81674. * Handedness types
  81675. */
  81676. type XRHandedness = "none" | "left" | "right";
  81677. /**
  81678. * InputSource target ray modes
  81679. */
  81680. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81681. /**
  81682. * Eye types
  81683. */
  81684. type XREye = "none" | "left" | "right";
  81685. /**
  81686. * Type of XR events available
  81687. */
  81688. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81689. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81690. type XRPlaneSet = Set<XRPlane>;
  81691. type XRAnchorSet = Set<XRAnchor>;
  81692. type XREventHandler = (callback: any) => void;
  81693. interface XRLayer extends EventTarget {}
  81694. interface XRSessionInit {
  81695. optionalFeatures?: string[];
  81696. requiredFeatures?: string[];
  81697. trackedImages?: XRTrackedImageInit[];
  81698. }
  81699. interface XRSessionEvent extends Event {
  81700. readonly session: XRSession;
  81701. }
  81702. interface XRSystem {
  81703. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81704. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81705. }
  81706. interface XRViewport {
  81707. readonly x: number;
  81708. readonly y: number;
  81709. readonly width: number;
  81710. readonly height: number;
  81711. }
  81712. interface XRWebGLLayerInit {
  81713. antialias?: boolean;
  81714. depth?: boolean;
  81715. stencil?: boolean;
  81716. alpha?: boolean;
  81717. multiview?: boolean;
  81718. framebufferScaleFactor?: number;
  81719. }
  81720. declare class XRWebGLLayer {
  81721. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81722. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81723. readonly antialias: boolean;
  81724. readonly framebuffer: WebGLFramebuffer;
  81725. readonly framebufferWidth: number;
  81726. readonly framebufferHeight: number;
  81727. readonly ignoreDepthValues: boolean;
  81728. getViewport: (view: XRView) => XRViewport;
  81729. }
  81730. // tslint:disable-next-line no-empty-interface
  81731. interface XRSpace extends EventTarget {}
  81732. interface XRRenderState {
  81733. readonly baseLayer?: XRWebGLLayer;
  81734. readonly depthFar: number;
  81735. readonly depthNear: number;
  81736. readonly inlineVerticalFieldOfView?: number;
  81737. }
  81738. interface XRRenderStateInit extends XRRenderState {
  81739. baseLayer: XRWebGLLayer;
  81740. depthFar: number;
  81741. depthNear: number;
  81742. inlineVerticalFieldOfView?: number;
  81743. layers?: XRLayer[];
  81744. }
  81745. interface XRReferenceSpace extends XRSpace {
  81746. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81747. onreset: XREventHandler;
  81748. }
  81749. interface XRBoundedReferenceSpace extends XRSpace {
  81750. readonly boundsGeometry: DOMPointReadOnly[];
  81751. }
  81752. interface XRInputSource {
  81753. readonly handedness: XRHandedness;
  81754. readonly targetRayMode: XRTargetRayMode;
  81755. readonly targetRaySpace: XRSpace;
  81756. readonly gripSpace?: XRSpace;
  81757. readonly gamepad?: Gamepad;
  81758. readonly profiles: Array<string>;
  81759. readonly hand?: XRHand;
  81760. }
  81761. interface XRPose {
  81762. readonly transform: XRRigidTransform;
  81763. readonly emulatedPosition: boolean;
  81764. }
  81765. interface XRWorldInformation {
  81766. detectedPlanes?: XRPlaneSet;
  81767. }
  81768. interface XRFrame {
  81769. readonly session: XRSession;
  81770. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81771. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81772. // AR
  81773. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81774. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81775. // Anchors
  81776. trackedAnchors?: XRAnchorSet;
  81777. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81778. // World geometries
  81779. worldInformation?: XRWorldInformation;
  81780. // Hand tracking
  81781. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81782. // Image tracking
  81783. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  81784. }
  81785. interface XRInputSourceEvent extends Event {
  81786. readonly frame: XRFrame;
  81787. readonly inputSource: XRInputSource;
  81788. }
  81789. type XRInputSourceArray = XRInputSource[];
  81790. interface XRSession {
  81791. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81792. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81793. /**
  81794. * Returns a list of this session's XRInputSources, each representing an input device
  81795. * used to control the camera and/or scene.
  81796. */
  81797. readonly inputSources: Array<XRInputSource>;
  81798. /**
  81799. * object which contains options affecting how the imagery is rendered.
  81800. * This includes things such as the near and far clipping planes
  81801. */
  81802. readonly renderState: XRRenderState;
  81803. readonly visibilityState: XRVisibilityState;
  81804. /**
  81805. * Removes a callback from the animation frame painting callback from
  81806. * XRSession's set of animation frame rendering callbacks, given the
  81807. * identifying handle returned by a previous call to requestAnimationFrame().
  81808. */
  81809. cancelAnimationFrame: (handle: number) => void;
  81810. /**
  81811. * Ends the WebXR session. Returns a promise which resolves when the
  81812. * session has been shut down.
  81813. */
  81814. end(): Promise<void>;
  81815. /**
  81816. * Schedules the specified method to be called the next time the user agent
  81817. * is working on rendering an animation frame for the WebXR device. Returns an
  81818. * integer value which can be used to identify the request for the purposes of
  81819. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81820. * to the Window.requestAnimationFrame() method.
  81821. */
  81822. requestAnimationFrame: XRFrameRequestCallback;
  81823. /**
  81824. * Requests that a new XRReferenceSpace of the specified type be created.
  81825. * Returns a promise which resolves with the XRReferenceSpace or
  81826. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81827. * the requested space type isn't supported by the device.
  81828. */
  81829. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81830. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81831. onend: XREventHandler;
  81832. oninputsourceschange: XREventHandler;
  81833. onselect: XREventHandler;
  81834. onselectstart: XREventHandler;
  81835. onselectend: XREventHandler;
  81836. onsqueeze: XREventHandler;
  81837. onsqueezestart: XREventHandler;
  81838. onsqueezeend: XREventHandler;
  81839. onvisibilitychange: XREventHandler;
  81840. // hit test
  81841. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81842. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81843. // legacy AR hit test
  81844. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81845. // legacy plane detection
  81846. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81847. // image tracking
  81848. getTrackedImageScores?(): XRImageTrackingScore[];
  81849. }
  81850. interface XRViewerPose extends XRPose {
  81851. readonly views: Array<XRView>;
  81852. }
  81853. declare class XRRigidTransform {
  81854. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81855. position: DOMPointReadOnly;
  81856. orientation: DOMPointReadOnly;
  81857. matrix: Float32Array;
  81858. inverse: XRRigidTransform;
  81859. }
  81860. interface XRView {
  81861. readonly eye: XREye;
  81862. readonly projectionMatrix: Float32Array;
  81863. readonly transform: XRRigidTransform;
  81864. readonly recommendedViewportScale?: number;
  81865. requestViewportScale(scale: number): void;
  81866. }
  81867. interface XRInputSourceChangeEvent extends Event {
  81868. session: XRSession;
  81869. removed: Array<XRInputSource>;
  81870. added: Array<XRInputSource>;
  81871. }
  81872. // Experimental/Draft features
  81873. declare class XRRay {
  81874. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81875. origin: DOMPointReadOnly;
  81876. direction: DOMPointReadOnly;
  81877. matrix: Float32Array;
  81878. }
  81879. declare enum XRHitTestTrackableType {
  81880. "point",
  81881. "plane",
  81882. "mesh",
  81883. }
  81884. interface XRHitResult {
  81885. hitMatrix: Float32Array;
  81886. }
  81887. interface XRTransientInputHitTestResult {
  81888. readonly inputSource: XRInputSource;
  81889. readonly results: Array<XRHitTestResult>;
  81890. }
  81891. interface XRHitTestResult {
  81892. getPose(baseSpace: XRSpace): XRPose | undefined;
  81893. // When anchor system is enabled
  81894. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81895. }
  81896. interface XRHitTestSource {
  81897. cancel(): void;
  81898. }
  81899. interface XRTransientInputHitTestSource {
  81900. cancel(): void;
  81901. }
  81902. interface XRHitTestOptionsInit {
  81903. space: XRSpace;
  81904. entityTypes?: Array<XRHitTestTrackableType>;
  81905. offsetRay?: XRRay;
  81906. }
  81907. interface XRTransientInputHitTestOptionsInit {
  81908. profile: string;
  81909. entityTypes?: Array<XRHitTestTrackableType>;
  81910. offsetRay?: XRRay;
  81911. }
  81912. interface XRAnchor {
  81913. anchorSpace: XRSpace;
  81914. delete(): void;
  81915. }
  81916. interface XRPlane {
  81917. orientation: "Horizontal" | "Vertical";
  81918. planeSpace: XRSpace;
  81919. polygon: Array<DOMPointReadOnly>;
  81920. lastChangedTime: number;
  81921. }
  81922. interface XRJointSpace extends XRSpace {}
  81923. interface XRJointPose extends XRPose {
  81924. radius: number | undefined;
  81925. }
  81926. interface XRHand extends Iterable<XRJointSpace> {
  81927. readonly length: number;
  81928. [index: number]: XRJointSpace;
  81929. readonly WRIST: number;
  81930. readonly THUMB_METACARPAL: number;
  81931. readonly THUMB_PHALANX_PROXIMAL: number;
  81932. readonly THUMB_PHALANX_DISTAL: number;
  81933. readonly THUMB_PHALANX_TIP: number;
  81934. readonly INDEX_METACARPAL: number;
  81935. readonly INDEX_PHALANX_PROXIMAL: number;
  81936. readonly INDEX_PHALANX_INTERMEDIATE: number;
  81937. readonly INDEX_PHALANX_DISTAL: number;
  81938. readonly INDEX_PHALANX_TIP: number;
  81939. readonly MIDDLE_METACARPAL: number;
  81940. readonly MIDDLE_PHALANX_PROXIMAL: number;
  81941. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  81942. readonly MIDDLE_PHALANX_DISTAL: number;
  81943. readonly MIDDLE_PHALANX_TIP: number;
  81944. readonly RING_METACARPAL: number;
  81945. readonly RING_PHALANX_PROXIMAL: number;
  81946. readonly RING_PHALANX_INTERMEDIATE: number;
  81947. readonly RING_PHALANX_DISTAL: number;
  81948. readonly RING_PHALANX_TIP: number;
  81949. readonly LITTLE_METACARPAL: number;
  81950. readonly LITTLE_PHALANX_PROXIMAL: number;
  81951. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  81952. readonly LITTLE_PHALANX_DISTAL: number;
  81953. readonly LITTLE_PHALANX_TIP: number;
  81954. }
  81955. type XRImageTrackingState = "tracked" | "emulated";
  81956. type XRImageTrackingScore = "untrackable" | "trackable";
  81957. interface XRTrackedImageInit {
  81958. image: ImageBitmap;
  81959. widthInMeters: number;
  81960. }
  81961. interface XRImageTrackingResult {
  81962. readonly imageSpace: XRSpace;
  81963. readonly index: number;
  81964. readonly trackingState: XRImageTrackingState;
  81965. readonly measuredWidthInMeters: number;
  81966. }
  81967. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  81968. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  81969. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  81970. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  81971. interface XRSceneObject {
  81972. type: XRSceneObjectType;
  81973. }
  81974. interface XRFieldOfView {
  81975. angleLeft: number;
  81976. angleRight: number;
  81977. angleUp: number;
  81978. angleDown: number;
  81979. }
  81980. interface XRFrustum {
  81981. position: DOMPointReadOnly;
  81982. orientation: DOMPointReadOnly;
  81983. fieldOfView: XRFieldOfView;
  81984. farDistance: number;
  81985. }
  81986. interface XRPlane {
  81987. parentSceneObject?: XRSceneObject;
  81988. }
  81989. interface XRMesh {
  81990. meshSpace: XRSpace;
  81991. positions: Float32Array;
  81992. indices: Uint32Array;
  81993. normals?: Float32Array;
  81994. lastChangedTime: number;
  81995. parentSceneObject?: XRSceneObject;
  81996. }
  81997. interface XRFrustumDetectionBoundary {
  81998. type: "frustum";
  81999. frustum: XRFrustum;
  82000. }
  82001. interface XRSphereDetectionBoundary {
  82002. type: "sphere";
  82003. radius: number;
  82004. }
  82005. interface XRBoxDetectionBoundary {
  82006. type: "box";
  82007. extent: DOMPointReadOnly;
  82008. }
  82009. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82010. interface XRGeometryDetectorOptions {
  82011. detectionBoundary?: XRDetectionBoundary;
  82012. updateInterval?: number;
  82013. }
  82014. interface XRSession {
  82015. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82016. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82017. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82018. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82019. }
  82020. interface XRFrame {
  82021. featurePointCloud?: Array<number>;
  82022. }
  82023. type XRMeshSet = Set<XRMesh>;
  82024. interface XRWorldInformation {
  82025. detectedMeshes?: XRMeshSet;
  82026. }